Announcement

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

  • mi reshape after mi impute chained

    Dear everybody,

    First post on Statalist, so first of all thanks for providing this great forum, which has already been of great help to me!

    Back to my problem, which is an error message I haven't got the slightest idea where it's coming from. Some words on the background: We are running FE and RE models on some panel data with 3 waves. I would like to impute missing values and use at least imputed values for independent variables in the models. (I am aware of the problems related to using imputed values for the dependent variable, raised by Hippel 2007.)

    Most importantly, I had to decide whether to impute across all data or only within waves (i.e. doing one big imputation with all variables for all 3 waves or doing three smaller imputations for one wave each). I opted for imputation only within waves because the "big imputation" didn't go through, I think mostly because of collinearity between variables (I suspect it was a variable indicating # of siblings and/or a binary indicating whether fathers were employed or not - these are, unfortunately, indispensable for the analysis). Also, literature seems to suggest that within wave imputation wouldn't yield results very different to across wave imputation. (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4477955/)

    For illustration purposes, here is the code for the "big" imputation (DEP is the dependent variable, it's categorical - INDEP is the independent variable; smoke, educ, gender, age and ethnic are time-invariant):

    Code:
    mi impute chained (logit, augment) fath_emp1 care1 fath_emp2 care2 fath_emp3 care3 ethnic ///
    (ologit, augment) DEP1 DEP2 DEP3 sibling1 income1 sibling2 income2 sibling3 income3 smoke educ ///
    (regress) INDEP1 INDEP2 INDEP3 = gender age, add(10)
    And here is as example one of the three within wave imputations (this, of course, is for wave 1):

    Code:
    mi impute chained (logit) fath_emp1 care1 ethnic ///
    (ologit) DEP1 sibling1 income1 smoke educ ///
    (regress) INDEP1 = gender age, add(10)
    So, I tried three things (which after reshaping all amounted to the same error):

    1. Start with wide data, one dataset for each wave, run mi impute chained as above (which works) and then merge the three datasets
    2. Start with wide data, all variables for all waves in one dataset, run three mi imputed chained models, each with the variables for one wave (for that purpose I create wave-specific copies of the time-invariant variables)
    3. Start with long data, reshape it to wide, run three mi imputed chained models, each with the variables for one wave (for that purpose I wave-specific copies of the time-invariant variables) (similar to http://stats.idre.ucla.edu/stata/faq...ata-using-ice/ only doing within wave imputation instead of across wave imputation)

    No matter which option I took, after the command

    Code:
    mi reshape long DEP INDEP fath_emp sibling income care, i(ID) j(followup)
    I got the error:

    Code:
    DEP#: variable registration conflict;
        All variables corresponding to the same stub (DEP) must be registered the same, as imputed, passive, or regular.
    And this despite mi describe showing me that the dependent variables for all three waves are registered as imputed. If I drop the dependent variable from mi reshape I get the same message, only with "INDEP" in place of "DEP" (and so on for the controls if I drop the independent variable).

    Here is one example of mi describe (with precise names of the variables omitted due to confidentiality):
    Code:
      Style:  wide
              last mi update 09mar2017 15:53:25, approximately 1 minute ago
    
      Obs.:   complete           53
              incomplete      2,155  (M = 10 imputations)
              ---------------------
              total           2,208
    
      Vars.:  imputed:  26; all the imputed variables
    
              passive:  0
    
              regular:  28; all the regular variables [Here I created some dummies, that's why the number is so high)
    
              system:   1; _mi_miss
    
             (there is one unregistered variable; ID)
    Of course, if I start out in long format mi describe will return "Style: mlong".

    My apologies for the long text, but I am completely at a loss as to what I can do to solve this problem and thought it needed some background information to be comprehensible. Thanks very much indeed for any recommendations or responds in advance!

    Best,
    Jakob

  • #2
    Of course, as so often, this was just a question of using the right syntax. The code below worked (moccup is an additional control and INDEP is categorical here as opposed to above, but shouldn't make any difference). It looks a bit messy, but the basic idea is to use option "omit" (as documented in the Stata Manual) in the model specification "(logit)" or "(ologit)" in my case so as to only allow variables from the same wave in the imputation model for each wave-specific variable..

    Code:
    mi impute chained ///
    (logit, augment) ethnic ///
    (logit, augment omit (i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) fath_emp1 ///
    (logit, augment omit (i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) care1 ///
    (logit, augment omit (i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) DEP1 ///
    (logit, augment omit (i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) fath_emp2 ///
    (logit, augment omit (i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) care2 ///
    (logit, augment omit (i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) DEP2 ///
    (logit, augment omit (i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2)) fath_emp3 ///
    (logit, augment omit (i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2)) care3 ///
    (logit, augment omit (i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2)) DEP3 ///
    (ologit, omit(i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) Sibling1 ///
    (ologit, omit(i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) income1 ///
    (ologit, omit(i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) moccup1 ///
    (ologit, omit(i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) INDEP1 ///
    (ologit, omit(i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) Sibling2 ///
    (ologit, omit(i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) income2 ///
    (ologit, omit(i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) moccup2 ///
    (ologit, omit(i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp3 i.care3 i.DEP3 i.income3 i.moccup3 i.INDEP3 i.Sibling3)) INDEP2 ///
    (ologit, omit(i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2)) Sibling3 ///
    (ologit, omit(i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2)) income3 ///
    (ologit, omit(i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2)) moccup3 ///
    (ologit, omit(i.fath_emp1 i.care1 i.DEP1 i.income1 i.moccup1 i.INDEP1 i.Sibling1 i.fath_emp2 i.care2 i.DEP2 i.income2 i.moccup2 i.INDEP2 i.Sibling2)) INDEP3 ///
    (ologit) smoke educ ///
    = gender age, add(10)

    Comment

    Working...
    X