Announcement

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

  • How to obtain predictions with both fixed and random parts with -xtmixed- after multiple imputation

    Dear Statalisters,

    I've been trying to understand -xtmixed- and multiple imputation. Rabe-Hesketh & Skrondal's book has been really useful, but it does not address multiple imputation.

    So, I've prepared a small script to make myself clearer. See it below. My questions are:

    1. Is there any straightforward, non-flamboyant way to obtain predictions with both fixed and random parts after -xtmixed- and multiple imputation?
    2. If I have a variable, say "weight", measured over time (week=1,2,3,4,5,6,7,8 and 9), and need that predictions for variable weight at time 2 need to be adjusted for weight at time 1 (baseline), how do I do that ?

    I will be extremely thankful for any help.

    All the best,

    Tiago

    */ ----------------------------------------- start ------------------------------------------------------------------------
    */ Download the dataset used by Ruppert, Wand, and Carroll (2003) and Diggle et al. (2002)
    */ It is a longitudinal study. 48 pigs were followed up for 9 weeks and their weight was recorded.

    set seed 2017
    use http://www.stata-press.com/data/r13/pig.dta, clear

    */ reshape for multiple imputation
    reshape wide weight, i(id) j(week)

    */ generate 4 hypothetical auxiliary variables, 3 continuous and 1 binary (1 = male, 0 = female)
    gene cov1 = rnormal(10,3)*weight9
    gene cov2 = rnormal(10,4)*weight9
    gene cov3 = rnormal(10,5)*weight9
    gene gender = runiform()>0.5

    */ generate 30% of missing data at random for week 9
    replace weight9 = cond(runiform()<0.30,.,weight9)

    */imputation
    mi set flong
    mi register imputed weight9
    mi impute monotone (regress) weight9 = cov1 cov2 cov3 weight8 gender, add(5)
    mi reshape long weight, i(id) j(week)


    */ I would like to allow for a random slope on week, an unstructured covariance structure and that results are adjusted for gender.
    */ So, I added gender (1= male,0 = female) to the fixed part of the random-effects coefficient model

    mi estimate: xtmixed weight i.week i.gender || id: week, covariance(unstructured)
    mi estimate, saving(myestimates, replace): xtmixed weight week gender || id: week, covariance(unstructured)
    mi predict myprediction using myestimates
    mi estimate : mean weight, over(week)
    mi xeq 0: mean myprediction, over(week)
    */ ----------------------------------------- end ------------------------------------------------------------------------












  • #2
    I do not fully follow the example. In the first model, week is treated as a categorical variable, right? How can such a variable have a random slope?

    Anyway, have you looked at mimrgns (SSC)? Figure out the margins command that you would use with non-imputed data, first. Then replace margins with mimrgns and see whether it gives you what you want.

    Best
    Daniel

    Comment


    • #3
      Dear Daniel,

      Thanks very much. Forget those i.'s. My bad.

      I do know your command, and have been using it several times. Always wanted to say thanks, so this is a nice opportunity: thank you so much for your time in writing such a useful command.

      However, for my case, -mimrgns- gives 95% confidence intervals for the grand mean for week each. Apparently, they are based on the fixed-effects portion only. What I would like to compute is the 95% predictive interval, that is, the interval of weight that will contain approximately 95% of all pigs at week 4.

      Do you have any suggestions?

      All the best,

      Tiago

      Comment

      Working...
      X