// MI example 2
use spanking age educ income91 sex race marital region childs god using "C:\Users\User\Dropbox (FAMSIZEMATTERS)\methods and data\GSS1994.dta", clear
recode spanking (1 = 4) (2 = 3) (3 = 2) (4 = 1)
generate female = (sex == 2)
generate black = (race == 2)
recode income91 ( 1 = 500) ( 2 = 2000) ( 3 = 3500) ( 4 = 4500) ( 5 = 5500) ///
( 6 = 6500) ( 7 = 7500) ( 8 = 9000) ( 9 = 11250) (10 = 13750) ///
(11 = 16250) (12 = 18750) (13 = 21250) (14 = 23750) (15 = 27500) ///
(16 = 32500) (17 = 37500) (18 = 45000) (19 = 55000) (20 = 67500) ///
(21 = 75000), gen(income)
replace income = income / 1000
generate nochild = (childs == 0) if !missing(childs)
generate nodoubt = (god == 6) if !missing(god)
generate nevmar = (marital == 5) if !missing(marital)
generate divsep = inlist(marital, 3, 4) if !missing(marital)
generate widow = (marital == 2) if !missing(marital)
generate east = inlist(region, 1, 2)
generate midwest = inlist(region, 3, 4)
generate south = inlist(region, 5, 6, 7)
misschk spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow
eststo clear
eststo: ologit spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow
drop if missing(marital)
preserve
recode educ (.d .n = .)
recode spanking (.d .i .n = .)
mi set mlong
mi register imputed spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow
mi impute mvn spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow, ///
add(5) burnin(500) burnbetween(200) emlog emoutput
foreach x of varlist female black nodoubt nochild east midwest south nevmar divsep widow {
replace `x' = 0 if `x' < .5 & _mi_m != 0
replace `x' = 1 if `x' >= .5 & _mi_m != 0
}
replace spanking = 1 if spanking < 1.5 & _mi_m != 0
replace spanking = 2 if spanking >= 1.5 & spanking < 2.5 & _mi_m != 0
replace spanking = 3 if spanking >= 2.5 & spanking < 3.5 & _mi_m != 0
replace spanking = 4 if spanking >= 3.5 & _mi_m != 0
eststo: mi estimate, post: ologit spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow
restore
preserve
recode educ (.d .n = .)
recode spanking (.d .i .n = .)
mi set mlong
mi register imputed spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow
mi impute chained (mlogit) spanking (regress) income educ (logit) nodoubt nochild = female black age east midwest south nevmar divsep widow, ///
add(5) burnin(20) force
eststo: mi estimate, post: ologit spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow
restore
preserve
mi set mlong
mi register imputed spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow
drop if missing(spanking)
mi impute chained (mlogit) spanking (regress) income educ (logit) nodoubt nochild = female black age east midwest south nevmar divsep widow, ///
add(5) burnin(20) force
eststo: mi estimate, post: ologit spanking female black income educ nodoubt nochild age east midwest south nevmar divsep widow
restore
esttab, wide se keep(spanking:) nonumbers modelwidth(15) ///
mtitle("Listwise deletion" "Normal data augmentation" "Sequential regression" "Seq. regression w/out missings") ///
title(Coefficient estimates and standatd errors for cumulative logit models predicting SPANKING)
Showing posts with label mi register. Show all posts
Showing posts with label mi register. Show all posts
Feb 14, 2018
Handling missing values in Stata
This allows replicating the analyses in Allison (2002, pp. 68-73).
Labels:
esttab,
General Social Survey,
mi impute,
mi register,
misschk,
Missing values,
ologit,
Textbooks
Feb 13, 2018
Using additional variables in multiple imputation
This allows replicating Table 6.2 in Allison (2002).
// Table 6.2
use "https://statisticalhorizons.com/wp-content/uploads/college.dta", clear
mi set mlong
mi register imputed csat act gradrat
eststo clear
eststo: regress csat
// Impute using ACT
mi impute mvn csat act, ///
add(5) burnin(500) burnbetween(200) emlog emoutput
eststo: mi estimate, post: regress csat
// PCT25 is missing altogether in the data
// Impute using ACT and GRADRAT
mi impute mvn csat act gradrat, ///
add(5) burnin(500) burnbetween(200) emlog emoutput
eststo: mi estimate, post: regress csat
esttab, not se mtitle("No imputation" "ACT" "ACT and GRADRAT") nonumbers ///
coeflabel(_cons "Mean") modelwidth(15) title("Mean (and standard errors) of CSAT with different variables used in imputation")
Reference
Allison, Paul D. 2002. Missing Data. Sage. doi: 10.4135/9781412985079
Labels:
esttab,
mi estimate,
mi register,
mi set,
Missing values,
Textbooks
Feb 12, 2018
Interactions in multiple imputation
This replicates the analyses for Table 6.1 for Allison (2002).
// Table 6.1
// Method 1
use "https://statisticalhorizons.com/wp-content/uploads/college.dta", clear
mi set mlong
mi register imputed gradrat csat private lenroll stufac rmbrd act
mi impute mvn gradrat csat private lenroll stufac rmbrd act, ///
add(5) burnin(500) burnbetween(200) emlog emoutput
eststo clear
eststo: mi estimate, post: regress gradrat lenroll i.private##c.csat stufac rmbrd
// Method 2
use "https://statisticalhorizons.com/wp-content/uploads/college.dta", clear
mi set mlong
mi register imputed gradrat csat lenroll stufac rmbrd act
mi impute mvn gradrat csat lenroll stufac rmbrd act, ///
add(5) burnin(500) burnbetween(200) emlog emoutput ///
by(private)
eststo: mi estimate, post: regress gradrat lenroll i.private##c.csat stufac rmbrd
// Method 3
use "https://statisticalhorizons.com/wp-content/uploads/college.dta", clear
generate privateXcsat = private * csat
mi set mlong
mi register imputed gradrat csat private lenroll stufac rmbrd act privateXcsat
mi impute mvn gradrat csat private lenroll stufac rmbrd act privateXcsat, ///
add(5) burnin(500) burnbetween(200) emlog emoutput
eststo: mi estimate, post: regress gradrat lenroll i.private csat privateXcsat stufac rmbrd
esttab, not p wide nostar noobs varlabel(_cons "Intercept") ///
order(_cons csat lenroll stufac 1.private rmbrd) ///
rename(privateXcsat 1.private#c.csat) varwidth(25) nobaselevels ///
title(Regression with interaction terms--three methods) ///
mtitle("Method 1" "Method 2" "Method 3") nonumbers
Reference
Allison, Paul D. 2002. Missing Data. Sage. doi: 10.4135/9781412985079
Labels:
esttab,
mi estimate,
mi impute,
mi register,
mi set,
Textbooks
Subscribe to:
Posts (Atom)