Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with "mi predict" after Multiple Imputation

    Dear all,

    so I run my MI model on my data set.
    Afterwards, I run a linear regression model and it is still working, and seems logical.
    However, as soon as want to mi predict for different treatments (t_s0) I get following error message:


    *mi predict: prediction sets vary across imputations
    * The set of observations used to compute predictions varies between imputations m=1 and m=2; this is not allowed.
    *r(459);

    The point is that I have imputed also my treatment variable, therefore there are of course some variation in each dataset.
    As soon as I do not impute t_s0 all is fine and working.... but that was not the idea of using MI...

    Does someone has an idea how to solve this issue?
    Thanks a lot!

    Below is my code!

    local he31 i.t_s0 alterdiag alterdiag2 diagjahr i.comon_herz
    local outc pf rf ef cf sf ql fa nv pa dy sl ap co di fi pr25_us pr25_bs pr25_sys pr25_sa pr25_sx pr25_aid
    foreach var of varlist `outc' {
    xi: mi estimate, saving (`var'_mi_est, replace) : regress `var' `he31'
    mi predict `var'_not using `var'_mi_est if t_s0==0, xb
    mi predict `var'_op using `var'_mi_est if t_s0==1, xb
    mi predict `var'_radia using `var'_mi_est if t_s0==2, xb
    mi predict `var'_opradia using `var'_mi_est if t_s0==3, xb
    mi predict `var'_hormo using `var'_mi_est if t_s0==4, xb
    sum `var'_not
    sum `var'_op
    sum `var'_radia
    sum `var'_opradia
    sum `var'_hormo
    }


Working...
X