6.1nopauseTRUEWorkflow for module 6 of LEMMA training materials (practical by Fiona Steele) Workflow written by Chris Charlton and William Browne 6.1Here is the dataset summary (page 3)tableantemed summaryopcountscolsantemedrowsconssubsetNocolpropNorowpropYestotalpropNochiNoTabulateHere is the numbers in each category of antemed (page4)tablenopausecolsdo you want to continue?antemed averageopaveragesvarsantemedAverageAndCorrelationHere is the average of antemed (page 4)tablenopausecolsdo you want to continue?plot of antemed vs mageyaxisantemedxaxismageXYPlotHere is the plot of antemed vs mage (page 6) which is not very informative!graphxy.svgnopausecolsdo you want to continue?block average antemednumkeys1key0mageoutdata6.1sortedEnginePython_scriptSortlast986.1sortedopAveragemlblockmageincolantemedoutcolantemedoutdata6.1sortedMultilevelDataManipulationnopausecolsdo you want to continue?Plot block average antemedlast1176.1sortedyaxisantemedxaxismageXYPlotHere is the plot of block averages of antemed vs mage (page 7) which is more informativegraphxy.svgnopausecolsdo you want to continue?Tabulate urban vs antemed6.1opcountscolsurbanrowsantemedsubsetNocolpropYesrowpropNototalpropNochiNoTabulateHere is the tabulation of urban vs antemed (page 8)tablenopausecolsdo you want to continue?Tabulate meduc vs antemedopcountscolsmeducrowsantemedsubsetNocolpropYesrowpropNototalpropNochiNoTabulateHere is the tabulation of meduc vs antemed (page 9)table6.2Create avgmageopAveragemlblockconsincolmageoutcolavgmageoutdata6.2aMultilevelDataManipulationlast2236.2aCreate magecentoutcolmagecentexprmage - avgmageoutdata6.2aCalculatelast2376.2aCreate magecent2outcolmagecent2exprmagecent*magecentoutdata6.2aCalculatelast2516.2aCreate meduc_2outcolmeduc_2exprmeduc == 2outdata6.2aCalculatelast2656.2aCreate meduc_3outcolmeduc_3exprmeduc == 3outdata6.2aCalculatelast2796.2aLinear Regression modelyantemedxcons, magecent, magecent2, urban, meduc_2, meduc_3nchains3seed1burnin500iterations2000thinning1defaultalgYesmakepredYesdefaultsvYesoutdatachainsRegression1Here is the equation and estimates (page 12)equation.texmodelparameters.dtamodelfit.dtabeta_0last317modelparameters.dta2meanbeta_1last317modelparameters.dta3meanbeta_2last317modelparameters.dta4meanbeta_3last317modelparameters.dta5meanbeta_4last317modelparameters.dta6meanbeta_5last317modelparameters.dta7meanCreate avgurbanlast317prediction_datafileopAveragemlblockconsincolurbanoutcolavgurbanoutdataprediction_datafileMultilevelDataManipulationCreate avgmeduc2last377prediction_datafileopAveragemlblockconsincolmeduc_2outcolavgmeduc_2outdataprediction_datafileMultilevelDataManipulationCreate avgmeduc3last397prediction_datafileopAveragemlblockconsincolmeduc_3outcolavgmeduc_3outdataprediction_datafileMultilevelDataManipulationCalculate predictionlast417prediction_datafileoutcolpredscore1exprbeta_0 + beta_1*magecent +beta_2*magecent2 +beta_3*avgurbanoutdataprediction_datafileCalculategroup descriptionlast439prediction_datafileoutcolpredscoreexprpredscore1 +beta_4*avgmeduc_2 +beta_5*avgmeduc_3outdataprediction_datafileCalculateplot of fitted valueslast458prediction_datafileyaxispredscorexaxismageXYLinePlotHere is the plot of the fitted values (page 13)graphxy.svgCalculate residuallast317prediction_datafileoutcolresidualexprantemed-pred_fulloutdataresidual_datafileCalculateplot of residual vs fitted valueslast487residual_datafileyaxisresidualxaxispred_fullXYPlotHere is the plot of residuals vs fitted values (page 15) which is not very informative!graphxy.svg