Announcement

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

  • Multiple imputation using mi impute with multi-level data

    Dear statalist users,

    This is the first time I'm using multiple imputations. I am using a multilevel data set with individuals clustered in countries. I want to impute missing values for income, and two anxiety measures. This is what I've come up with so far:

    Code:
    nscore inc stanx1 stanx2, gen(nscore)
    mi set mlong
    mi register imputed nscore* sex age educ empstat pdi idv gini_disp gdp country
    set seed 46352
    mi impute mvn nscore* sex age educ empstat pdi idv gini_disp gdp country, add(5) rseed(46352)
    invnscore inc stanx1 stanx2
    I'm happy with the values imputed for the variables that had missing values (inc, stanx1, stanx2). But this imputation method does not consider the clustering of the data. Also I have noticed that in the imputed observations, the level-2 variables are different than from the original data, e.g. gini-values of certain countries are not correct. Thus, I do not want the level-2 variables (pdi, idv, gini_disp, gdp) to change for the imputed observations. I also want to transform variables with missing values later on like this:

    Code:
    egen incrank = xtile(inc), n(100) by(country)   
    
    factor stanx1 stanx2, factors(1)
    predict stanx_factor
    I am not sure how I should do that with the mi estimate prefix.

    The final analysis step is a mixed-effects model that includes interactions. Is there something I need to consider for the inclusion of interaction terms?

    Code:
    mi estimate: mixed stanx_factor incrank inc educ age sex empstat pdi idv  gdp gini_disp c.incrank#c.pdi c.incrank#c.idv || country: incrank, mle
    I'd by very grateful for any advice on these questions. Thank you!



  • #2
    I have improved my code a bit:

    Code:
    egen incrank = xtile(inc), n(100) by(country)
    
    gen incrank_pdi = incrank * pdi // Interaction term
    gen incrank_idv = incrank * idv // Interaction term
    
    mi set mlong
    mi register imputed inc stanx1 stanx2
    mi register passive incrank incrank_pdi incrank_idv
    set seed 46352
    mi impute chained (pmm, knn(5)) inc stanx1 stanx2 incrank incrank_pdi incrank_idv = idv i.sex age i.educ i.empstat pdi idv gini_disp gdp i.country, add(5) rseed(46352)
    
    mi passive: gen sa = (stanx1 + stanx2) / 2
    
    mi estimate: mixed sa incrank inc educ age sex empstat pdi idv gdp gini_disp incrank_pdi incrank_idv || country: incrank, mle
    So now I have created separate variables before the imputation process and registered them as passive:

    1. Income rank out of income
    2. Interaction terms between income rank and Individualism / Power distance

    I would really appreciate if anyone could check whether the code is fine so far. Also I have some concrete questions:

    1. Is including the country-variable as a factor in the imputation model enough to take care of the multilevel structure of the data? What about the other level-2 variables, do they need to be specified?
    2. Is it right to include the passive variables income rank and the two interaction terms as dependent variables in the imputation model or should I create them after the imputation?
    3. is the estimation model including interaction terms and random slope working like this?

    Any help is very appreciated, thank you!


    Comment


    • #3
      Here is also an overview of the data I'm using

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input byte country int pdi byte idv double(gini_disp gdp inc) byte(stanx1 stanx2 sex age educ empstat)
      1 11 55 27.9 52684.01711307681  7414.272474513438 5 5 1 2 5 1
      1 11 55 27.9 52684.01711307681  573.7234652897304 5 4 0 2 2 2
      1 11 55 27.9 52684.01711307681                  . 3 4 1 2 7 1
      1 11 55 27.9 52684.01711307681  926.7840593141798 6 5 0 2 2 2
      1 11 55 27.9 52684.01711307681 1112.1408711770157 6 4 1 2 3 2
      1 11 55 27.9 52684.01711307681  2293.790546802595 4 5 0 2 4 1
      1 11 55 27.9 52684.01711307681 2641.3345690454125 4 4 1 2 5 1
      1 11 55 27.9 52684.01711307681  1969.416126042632 3 4 1 1 5 1
      1 11 55 27.9 52684.01711307681 2363.2993512511584 4 3 1 1 5 1
      1 11 55 27.9 52684.01711307681 296.57089898053755 3 4 1 1 4 1
      1 11 55 27.9 52684.01711307681 1731.2326227988879 4 4 1 2 5 4
      1 11 55 27.9 52684.01711307681  2692.616620327464 6 7 0 2 6 1
      1 11 55 27.9 52684.01711307681  2085.264133456905 4 4 1 2 4 1
      1 11 55 27.9 52684.01711307681 1668.2113067655237 5 3 1 3 6 4
      1 11 55 27.9 52684.01711307681  2710.843373493976 6 5 1 2 7 1
      1 11 55 27.9 52684.01711307681 1745.1343836886006 5 4 0 3 8 4
      1 11 55 27.9 52684.01711307681                  . 4 4 0 2 4 2
      1 11 55 27.9 52684.01711307681 2641.3345690454125 5 6 0 2 7 1
      1 11 55 27.9 52684.01711307681                  . 4 4 1 3 7 4
      1 11 55 27.9 52684.01711307681  741.4272474513439 5 5 1 1 7 1
      1 11 55 27.9 52684.01711307681                  . 3 3 0 2 7 1
      1 11 55 27.9 52684.01711307681                  . 4 4 1 1 5 6
      1 11 55 27.9 52684.01711307681                  . 6 6 1 2 4 1
      1 11 55 27.9 52684.01711307681   720.832046133251 4 4 0 2 2 1
      1 11 55 27.9 52684.01711307681  1977.139326536917 3 3 0 3 5 4
      1 11 55 27.9 52684.01711307681 1985.9658413875284 3 5 0 1 5 1
      1 11 55 27.9 52684.01711307681 2868.6173264486515 3 3 0 2 5 1
      1 11 55 27.9 52684.01711307681  991.6589434661724 3 4 1 1 4 1
      1 11 55 27.9 52684.01711307681 1853.5681186283598 3 3 0 2 6 1
      1 11 55 27.9 52684.01711307681                  . 4 4 1 2 7 1
      1 11 55 27.9 52684.01711307681 1575.5329008341057 4 5 0 2 6 1
      1 11 55 27.9 52684.01711307681 1235.7120790855731 4 4 0 3 4 4
      1 11 55 27.9 52684.01711307681 1000.9267840593142 6 6 1 2 7 5
      1 11 55 27.9 52684.01711307681 1390.1760889712698 3 3 1 2 7 1
      1 11 55 27.9 52684.01711307681  5560.704355885079 3 3 0 2 8 1
      1 11 55 27.9 52684.01711307681                  . 3 3 0 2 8 1
      1 11 55 27.9 52684.01711307681  988.5696632684585 3 3 1 1 4 1
      1 11 55 27.9 52684.01711307681  764.5968489341984 3 5 1 2 4 1
      1 11 55 27.9 52684.01711307681                  . 3 3 0 2 5 1
      1 11 55 27.9 52684.01711307681  741.4272474513439 3 3 1 1 6 1
      1 11 55 27.9 52684.01711307681                  . 5 4 1 2 4 1
      1 11 55 27.9 52684.01711307681                  . 3 7 1 2 0 5
      1 11 55 27.9 52684.01711307681 1092.2812127631405 4 6 1 1 3 1
      1 11 55 27.9 52684.01711307681 2641.3345690454125 3 3 0 2 6 1
      1 11 55 27.9 52684.01711307681 1390.1760889712698 4 4 1 2 6 1
      1 11 55 27.9 52684.01711307681 1807.2289156626505 4 5 1 2 6 1
      1 11 55 27.9 52684.01711307681                  . 5 4 1 1 3 6
      1 11 55 27.9 52684.01711307681  2085.264133456905 . . 1 2 8 1
      1 11 55 27.9 52684.01711307681 1390.1760889712698 6 3 1 2 4 4
      1 11 55 27.9 52684.01711307681 1807.2289156626505 3 3 0 2 4 4
      1 11 55 27.9 52684.01711307681  1969.416126042632 3 3 1 2 5 1
      1 11 55 27.9 52684.01711307681 1204.8192771084339 4 5 0 2 4 1
      1 11 55 27.9 52684.01711307681                  . 6 6 1 1 4 1
      1 11 55 27.9 52684.01711307681                  . 3 3 0 2 5 1
      1 11 55 27.9 52684.01711307681 1019.4624652455979 6 6 1 1 4 1
      1 11 55 27.9 52684.01711307681 1019.4624652455979 7 7 0 2 2 1
      1 11 55 27.9 52684.01711307681 1482.8544949026877 . 6 0 2 4 1
      1 11 55 27.9 52684.01711307681                  . 5 . 1 1 5 1
      1 11 55 27.9 52684.01711307681                  . 3 3 1 1 7 6
      1 11 55 27.9 52684.01711307681                  . 3 6 1 2 4 2
      1 11 55 27.9 52684.01711307681  591.7159763313609 5 5 0 2 3 1
      1 11 55 27.9 52684.01711307681                  . 3 3 0 2 4 1
      1 11 55 27.9 52684.01711307681  905.4680259499537 3 3 0 2 3 4
      1 11 55 27.9 52684.01711307681 1390.1760889712698 5 4 1 2 5 2
      1 11 55 27.9 52684.01711307681  617.8560395427864 3 3 1 1 6 5
      1 11 55 27.9 52684.01711307681 1069.3662222855921 3 3 1 1 7 1
      1 11 55 27.9 52684.01711307681                  . 3 3 0 2 7 1
      1 11 55 27.9 52684.01711307681 1359.2832869941305 3 3 0 3 4 4
      1 11 55 27.9 52684.01711307681                  . 3 3 1 2 3 1
      1 11 55 27.9 52684.01711307681                  . 3 3 0 3 4 4
      1 11 55 27.9 52684.01711307681 2687.6737720111214 7 7 1 2 4 1
      1 11 55 27.9 52684.01711307681  695.0880444856349 5 4 0 2 8 4
      1 11 55 27.9 52684.01711307681  1033.720681542739 6 4 1 1 5 2
      1 11 55 27.9 52684.01711307681 1853.5681186283596 3 3 0 2 7 1
      1 11 55 27.9 52684.01711307681  926.7840593141798 6 4 0 2 4 2
      1 11 55 27.9 52684.01711307681  1029.760065904644 5 4 1 2 6 1
      1 11 55 27.9 52684.01711307681  1441.664092266502 3 3 0 2 5 1
      1 11 55 27.9 52684.01711307681 1297.4976830398518 3 4 0 2 5 2
      It would be very helpful if anyone could give me a hint on where to continue.

      Comment


      • #4
        I am lacking the time to dive deeper into this, but make sure to read this FAQ if you have not done so already.

        Comment


        • #5
          Thanks for the reply Daniel. I have tried to follow the advice given in the FAQ by indicating country as a factor variable.

          Comment

          Working...
          X