I used a glm model to estimate an outcome after applying multiple imputation for missing variables. My data is in wide style so I use this code:
For imputation
mi set wide
mi register regular intervention v1 v2
mi register imputed c1 c2 c3 q1 q2 q3
mi impute chained (pmm, knn(5)) c1 c2 c3 q1 q2 q3 =v1 v2, by(intervention) replace dots rseed(1710) add(20)
Then I calculated the totals
mi passive: gen total_c= c1 + c2 + c3
mi passive: gen total_q= q1 + q2 + q3
And then I runned the estimations for each variable
cap prog drop misim
program define misim,rclass
version 10.1
mim: glm total_c intervention, family(gamma) link(identity)
matrix define C=e(MIM_Q)
return scalar c_1=C[1,1]
mim: glm total_q intervention, family(gauss) link(identity)
matrix define Q=e(MIM_Q)
return scalar q_1=Q[1,1]
end
But when I try to run the boostrapping for the estimation of the confidence intervals I get an error:
Code:
bootstrap q_1=r(q_1) c_1=r(c_1),rep(1000) cluster(_mi) strata(intervention): misim
Error:
"imputation identifier variable _mj is either missing or not numeric an error occurred when bootstrap executed misim"
I think it has to do with the fact the structure of my data is wide and I do not have a panel.
Does anyone know how to apply the boostrapping in this case?
Kind regards,
Yaneth
For imputation
mi set wide
mi register regular intervention v1 v2
mi register imputed c1 c2 c3 q1 q2 q3
mi impute chained (pmm, knn(5)) c1 c2 c3 q1 q2 q3 =v1 v2, by(intervention) replace dots rseed(1710) add(20)
Then I calculated the totals
mi passive: gen total_c= c1 + c2 + c3
mi passive: gen total_q= q1 + q2 + q3
And then I runned the estimations for each variable
cap prog drop misim
program define misim,rclass
version 10.1
mim: glm total_c intervention, family(gamma) link(identity)
matrix define C=e(MIM_Q)
return scalar c_1=C[1,1]
mim: glm total_q intervention, family(gauss) link(identity)
matrix define Q=e(MIM_Q)
return scalar q_1=Q[1,1]
end
But when I try to run the boostrapping for the estimation of the confidence intervals I get an error:
Code:
bootstrap q_1=r(q_1) c_1=r(c_1),rep(1000) cluster(_mi) strata(intervention): misim
Error:
"imputation identifier variable _mj is either missing or not numeric an error occurred when bootstrap executed misim"
I think it has to do with the fact the structure of my data is wide and I do not have a panel.
Does anyone know how to apply the boostrapping in this case?
Kind regards,
Yaneth