set logtype text, perm capture log close cd "C:\Users\tneilands\Box Sync\My Documents\CAPS\Methods Core\Presentations\Missing Data 2015\Part 1\Example 1 and 2" log using Tobacco_Bar_Planned_Missingness_Study_FIML.log, replace set more off use addict_demo3.dta, clear // The simplest way to start exploring amounts of missingness with Stata // is to use the -summarize- command summarize venueid smokdays age race male lgbtcat /// srsmokr ntwrksmk extrindx addict // Use Stata built-in command -misstable- to summarize missing data patterns misstable summarize venueid smokdays age race male lgbtcat /// srsmokr ntwrksmk extrindx addict, all // Scott Long's -misschk- is an alternative for describing missing data patterns misschk venueid smokdays age race male lgbtcat /// srsmokr ntwrksmk extrindx addict, help // Try running OLS regression. capture noisily regress smokdays age i.race male i.lgbtcat srsmokr ntwrksmk extrindx, /// vce(cluster venueid) // OLS regression reports no observations? Why? Intersection of planned // missingness patterns means 0 observations in common for // variables srsmokr ntwrksmk extrindx misstable patterns srsmokr ntwrksmk extrindx, freq // Example 1: SEM using FIML estimation method can handle this design easily for // continuous outcomes xi: sem (smokdays <- age i.race male i.lgbtcat srsmokr ntwrksmk extrindx), /// method(mlmv) // Single equation syntax for race effect test _Irace_2 _Irace_3 _Irace_4 _Irace_5 testparm _Irace* // Multiple equation syntax for race effect test [smokdays]_Irace_2 [smokdays]_Irace_3 [smokdays]_Irace_4 [smokdays]_Irace_5 testparm _Irace_*, eq(smokdays) // Single equation syntax for LGBT effect test _Ilgbtcat_2 _Ilgbtcat_3 _Ilgbtcat_4 testparm _Ilgb* // Multiple equation syntax for LGBT effect test [smokdays]_Ilgbtcat_2 [smokdays]_Ilgbtcat_3 [smokdays]_Ilgbtcat_4 testparm _Ilgbtcat_*, eq(smokdays) // Example 2: Analysis of binary daily smoking variabile using logistic regression // Generate dummy variables for sexual orientation and race quietly: tab lgbtcat, gen(lgb) quietly: tab race, gen(race) // Fit logistic model using -runmplus-. Peform Wald test for overall race effect runmplus smkdaily age race2 race3 race4 race5 male lgb2 lgb3 lgb4 /// srsmokr ntwrksmk extrindx venueid, /// variable(cluster = venueid;) /// analysis(type = complex ; /// estimator = MLR; /// algorithm = integration; /// integration=montecarlo; /// processors = 4;) /// categorical(smkdaily) /// model(smkdaily ON race2 (r2) ; /// smkdaily ON race3 (r3) ; /// smkdaily ON race4 (r4) ; /// smkdaily ON race5 (r5) ; /// smkdaily ON lgb2 (s2) ; /// smkdaily ON lgb3 (s3) ; /// smkdaily ON lgb4 (s4) ; /// smkdaily ON age male srsmokr ntwrksmk extrindx ; /// age; /// race2 ; /// race3 ; /// race4 ; /// race5 ; /// male ; /// lgb2 ; /// lgb3 ; /// lgb4 ; /// srsmokr ; /// ntwrksmk ; /// extrindx ; /// model test: /// r2 = 0; r3 = 0 ; r4 = 0 ; r5 = 0 ;) /// output(cinterval;) // Fit logistic model using -runmplus-. Peform Wald test for overall LGBT effect runmplus smkdaily age race2 race3 race4 race5 male lgb2 lgb3 lgb4 /// srsmokr ntwrksmk extrindx venueid, /// variable(cluster = venueid;) /// analysis(type = complex ; /// estimator = MLR; /// algorithm = integration; /// integration=montecarlo; /// processors = 4;) /// categorical(smkdaily) /// model(smkdaily ON race2 (r2) ; /// smkdaily ON race3 (r3) ; /// smkdaily ON race4 (r4) ; /// smkdaily ON race5 (r5) ; /// smkdaily ON lgb2 (s2) ; /// smkdaily ON lgb3 (s3) ; /// smkdaily ON lgb4 (s4) ; /// smkdaily ON age male srsmokr ntwrksmk extrindx ; /// age; /// race2 ; /// race3 ; /// race4 ; /// race5 ; /// male ; /// lgb2 ; /// lgb3 ; /// lgb4 ; /// srsmokr ; /// ntwrksmk ; /// extrindx ; /// model test: /// s2 = 0; s3 = 0 ; s4 = 0 ;) /// output(cinterval;) log close