Announcement

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

  • calculating r square for a model estimated with multiply imputed data (mi estimate)

    Dear all,

    I would very much appreciate your help with calculating r-squared for models estimated with mi estimate command. I´ve read many discussions on statalist and elsewhere (for example https://stats.idre.ucla.edu/stata/fa...-imputed-data/) but I am still not able to do that (probably not modifying codes correctly). Could you please give me an example of how to calculate it using one of my models below (with notes suggesting what has to be modified for using it on different models in the future)?

    My basic model. For the sake of this example let´s say the number of imputed datasets is 5.

    Code:
    mi estimate, dots cmdok: melogit volba vzdelani c.egalitarstvi##c.narodovectvi euroskepticismus_rek apatie populismus i.man i.bydliste i.religiozita cynismus c.vek_rek##c.vek_rek migranti_2011_bezS [pweight=VAHA] || okres_cd:
    I am using Stata 16.1 MP

    Thank you in advance.

  • #2
    one example of code for use (but be sure you actually want r-squared for a logit model) is given in #6 of https://www.statalist.org/forums/for...ng-mi-estimate

    Comment


    • #3
      I tried that one this morning with no success.

      Thats how I modified it:

      Code:
      local model "vzdelani c.egalitarstvi##c.narodovectvi euroskepticismus_rek apatie populismus i.man i.bydliste i.religiozita cynismus c.vek_rek##c.vek_rek migranti_2011_bezS [pweight=VAHA] || okres_cd:"
      noi mi estimate, or saving(miest999, replace) cmdok: melogit volba `model'
      qui mi query
      local M=r(M)
      scalar r2=0
      scalar cstat=0
      qui mi xeq 1/`M': melogit volba `model'; scalar r2=r2+e(r2_p); scalar cstat=cstat+r(area)
      scalar r2=r2/`M'
      scalar cstat=cstat/`M'
      noi di "Pseudo R=squared over imputed data = " r2
      noi di "C statistic over imputed data = " cstat
      It runs correctly (as far as I can tell = no stata error) but Rsquared is not computed. See the output:

      Code:
      . noi di "Pseudo R=squared over imputed data = " r2
      Pseudo R=squared over imputed data = .
      
      .
      . noi di "C statistic over imputed data = " cstat
      C statistic over imputed data = .
      Last edited by Filip Safr; 13 Mar 2021, 07:46.

      Comment


      • #4
        -melogit- does not save those returned values (not to mention that you left out some of the material (though that is not relevant here)); so, you will need to modify more heavily; you need to decide what "classvar"/predicted value you want (my guess is that you want "mu") and get them after each xeq estimate and decide what pseudo-r^2 you want and how you want to get C (one relatively easy way is the user-contributed -somersd-; you can download this from SSC) and modify the code to use those; you cannot use my prior code directly as -melogit- does not return the values you are asking for

        Comment


        • #5
          I very much appreciate that you are trying to help me but I have no idea how to carry out modifications you are suggesting. Do you know of some text or thread on statalist with actual examples that could help me to understand it?

          Comment

          Working...
          X