Announcement

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

  • misum error: variable _mj not found

    Dear all,

    I had used Daniel Klein's misum command in the past and never had an issue until now. I am using Stata version 15.1.

    Here an example of the code I run and the error message I get
    Code:
    . misum siblings
    variable _mj not found
    r(111);
    Has anyone experienced this issue lately and know how to solve it? Your help would be very much appreciated!

    Thanks,
    Nicole

  • #2
    Please show the output of

    Code:
    which misum
    mi query
    The latest version of misum (from SSC) is

    Code:
    *! version 1.0.4 05jul2011 Daniel Klein
    and it uses _mj when the imputed data is in ice (SSC, SJ) format.

    If you have used ice to impute missing values, make sure you keep all variables that it creates or use mi import ice to convert to Stata's mi format.

    Best
    Daniel

    Comment


    • #3
      Hi Daniel,

      Thanks for your reply.

      Code:
      . which misum
      c:\ado\plus\m\misum.ado
      *! version 1.0.4 05jul2011 Daniel Klein
      
      . mi query
      data mi set wide, M = 5
      last mi update 18jun2019 11:41:56, approximately 1 hours ago
      I use mi impute for the imputations. Here my imputation attempt:

      Code:
      ****************************************************************************************************************
      ***imputation of wealth data done by SOEP survey team is registered
      // mi import - imports imputed data e.g. imports the data the SOEP team has provided
      
      mi import wide, imputed    (wealth_h_ihs= wealth_h_ihsa wealth_h_ihsb wealth_h_ihsc wealth_h_ihsd wealth_h_ihse /// Housing wealth, ihs                
                              asset_f_ihs= asset_f_ihsa asset_f_ihsb asset_f_ihsc asset_f_ihsd asset_f_ihse /// Financial wealth, ihs
                              wealth_r_ihs = wealth_r_ihsa wealth_r_ihsb wealth_r_ihsc wealth_r_ihsd wealth_r_ihse /// Wealth non-house & non-financial-asset, ihs 
                              ) drop clear
      
      
                              
      ****************************************************************************************************************
      ***imputation of other variables
       
      *reshape to wide format for time-varying variables (time-constant don't need reshape)
      global reshaper "mar_di_pro expft age age0t17 edu  wealth* asset* mar_max sep_max bulab wum3b netto mar_dur* inherit inherit_v partnr xrwght" 
       
      mi reshape wide $reshaper, i(id) j(year)    
                              
      *describe patterns of missing values in wide format
      mi misstable sum
      
      *mechanically impute age for years in which respondents not directly observed
      foreach y in 2002 2007 2012{
          foreach x in 2002 2007 2012{
              replace age`y'=age`x'+(`y'-`x') if missing(age`y') & ~missing(age`x')
              }
          }
                              
      *register variables that should be imputed
      mi register imputed     mar_di_pro???? /// marital dissolution process
                              mar_dur???? /// mean centred marital duration for married respondents
                              age0t17???? /// number of children living in houshold
                              k_dis_tag /// separation with kids
                              inherit_v???? /// personal inheritance value
                              mar_max???? /// marital duration for sep/div respondents
                              sep_max???? /// duration separated for divorced respondents
                              siblings /// ADDITIONAL siblings
                              bulab???? /// federal state
                              wum3b???? /// living area
                              east1989  /// lived in East Germany in 1989
                              pedu /// parental education
                              edu2002 /// education
                              expft???? /// labour force experience
                              
      *register variables without missings that should not be impute
      mi register regular psample cohort mig age2002
      
      global nonmissing "mig cohort i.psample age2002"
      
      *impute other variables
      mi impute chained     (ologit, augment omit(i.mar_di_pro2012 i.mar_di_pro2017 c.mar_dur???? i.k_dis_tag c.inherit_v2007 c.inherit_v2012 c.inherit_v2017)) mar_di_pro2002  /// Dissolution process variable
                          (ologit, augment omit(i.mar_di_pro2002 i.mar_di_pro2017 c.mar_dur???? i.k_dis_tag c.inherit_v2002 c.inherit_v2012 c.inherit_v2017)) mar_di_pro2007  /// 
                          (ologit, augment omit(i.mar_di_pro2002 i.mar_di_pro2007 c.mar_dur???? i.k_dis_tag c.inherit_v2007 c.inherit_v2002 c.inherit_v2017)) mar_di_pro2012  /// 
                          (ologit, augment omit(i.mar_di_pro2002 i.mar_di_pro2007 i.mar_di_pro2012 c.mar_dur???? i.k_dis_tag c.inherit_v2007 c.inherit_v2012 c.inherit_v2002)) mar_di_pro2017  /// 
                          (pmm,knn(10) omit(i.mar_di_pro2007 i.mar_di_pro2012 i.mar_di_pro2017 i.k_dis_tag c.inherit_v????)) mar_dur2002 ///
                          (pmm,knn(10) omit(i.mar_di_pro2002 i.mar_di_pro2012 i.mar_di_pro2017 i.k_dis_tag c.inherit_v????)) mar_dur2007 ///
                          (pmm,knn(10) omit(i.mar_di_pro2007 i.mar_di_pro2002 i.mar_di_pro2017 i.k_dis_tag c.inherit_v????)) mar_dur2012 ///
                          (pmm,knn(10) omit(i.mar_di_pro2007 i.mar_di_pro2012 i.mar_di_pro2002 i.k_dis_tag c.inherit_v????)) mar_dur2017 /// marital duration for cont. married
                          (pmm,knn(10)) age0t172002 age0t172007 age0t172012 age0t172017 /// children in household
                          (logit, augment conditional(if sampled ==1) omit(i.mar_di_pro2002 i.mar_di_pro2007 i.mar_di_pro2012 i.mar_di_pro2017 c.inherit_v????))  k_dis_tag /// Dissolution with kids
                          (pmm,knn(10)) inherit_v2002 inherit_v2007 inherit_v2012 inherit_v2017 /// Personal inheritance 
                          (pmm,knn(10)  conditional(if sampled ==1) omit( c.inherit_v???? c.mar_max2007 c.mar_max2012 c.mar_max2017 c.sep_max20??)) mar_max2002 ///
                          (pmm,knn(10)  conditional(if sampled ==1) omit( c.inherit_v???? c.mar_max2002 c.mar_max2012 c.mar_max2017 c.sep_max20??)) mar_max2007 ///
                          (pmm,knn(10)  conditional(if sampled ==1) omit( c.inherit_v???? c.mar_max2007 c.mar_max2002 c.mar_max2017 c.sep_max20??)) mar_max2012 ///
                          (pmm,knn(10)  conditional(if sampled ==1) omit( c.inherit_v???? c.mar_max2007 c.mar_max2012 c.mar_max2002 c.sep_max20??)) mar_max2017 ///
                          (pmm,knn(10)  conditional(if sampled ==1) omit( c.inherit_v???? c.sep_max2007 c.sep_max2012 c.sep_max2017 c.mar_max20??)) sep_max2002 ///
                          (pmm,knn(10)  conditional(if sampled ==1) omit( c.inherit_v???? c.sep_max2002 c.sep_max2012 c.sep_max2017 c.mar_max20??)) sep_max2007 ///
                          (pmm,knn(10)  conditional(if sampled ==1) omit( c.inherit_v???? c.sep_max2007 c.sep_max2002 c.sep_max2017 c.mar_max20??)) sep_max2012 ///
                          (pmm,knn(10)  conditional(if sampled ==1) omit( c.inherit_v???? c.sep_max2007 c.sep_max2012 c.sep_max2002 c.mar_max20??)) sep_max2017 /// Duration married or separated for sep/div respondents 
                          (pmm,knn(10)) siblings /// siblings 
                          bulab2002 bulab2007 bulab2012 bulab2017 /// federal state
                          wum3b2002 wum3b2007 wum3b2012 wum3b2017 /// living area 
                          (logit, augment) east1989 /// Lived in East Germany in 1989
                          (ologit, augment) edu2002 /// Highest education
                          pedu  /// parental education
                          (pmm,knn(10)) expft2002 expft2007 expft2012 expft2017 /// siblings 
                          = $nonmissing  ///
                          ,by(female) chaindots replace  rseed(109104547)  burnin(5) noisily        
                          
          
      ***Back to long format
      
      global reshaper "mar_di_pro expft age age0t17 edu  wealth_h_ihs wealth_h_flag wealth_r_ihs asset_f_flag asset_f_ihs mar_max sep_max mar_dur mar_dur_c bulab wum3b netto inherit inherit_v partnr xrwght" 
      
      *going back to long format
      mi reshape long $reshaper, i(id) j(year)
      
      *only keep observed years
      keep if netto<20
      
      
      misum siblings
      And then I get the error message as shown in my first post. Do you have any suggestions on how to get this to work/where I'm going wrong?

      Comment


      • #4
        I did not go through your entire code, so I will not comment on that. My guess is that the people at SOEP have imputed using the ice procedure which leaves behind the characteristic _dta[mi_id] which misum uses to determine the data format. You can probably just delete the respective characteristic after importing the data:

        Code:
        char _dta[mi_id] // void
        As stated in the help file, misum also requires the mi data to be in flong style rather than wide.

        Best
        Daniel

        Comment


        • #5
          Brilliant!

          Code:
          mi convert flong,clear
          char _dta[mi_id] // void
          misum siblings
          And it all works smoothly now
          Thanks so much for your help!

          Best,
          Nicole

          Comment

          Working...
          X