You are not logged in. You can browse but not post. Login or Register by clicking 'Login or Register' at the top-right of this page. For more information on Statalist, see the FAQ.
Thanks for posting this code Rich Goldstein! When I first ran it i got the same error code as Jean Keily, but I changed the line below and it then worked perfectly.
local M=r(M)
to (adding in the apostrophes)
local M=`r(M)'
I am running it following an ologit model, so not sure it is entriely appropriate for R-squared, does anyone know how to get a Hosmer-Lemeshow goodness of fit test, following an -mi estimate- command, using an ologit model? My code is as follows:
mi estimate, or saving(miest, replace): svyset: ologit outcome i.var1 i.var2 i.var3 var4 var5
Writing from the year 2021. I am using Stata /SE 15.1 and somehow when running RG's code from post #6 I kept getting the same error "type mismatch". Once one changes the name of the r2 scalar to something else, the code works nicely. Thanks RG!
Okay, here is what I put - I received a statistic...but I'm not sure if I did it right - I presume the "rhs" is the predictors and the Logistic is the outcome? What is supposed to go in the cluster? I used the outcome variable in both places...but I'm not sure that is what I'm supposed to do.
local rhs "AGE AGE2 woman2 nonhispblack other hisp SEX2 college_2 continc OWNRENT2 RURAL2 partnered SELFRATED PHYS_ABLE LONGLIVE AGEID"
noi mi estimate, or saving(miest, replace): logistic DRIVPLAN_LOT `rhs', vce(cluster DRIVPLAN_LOT)
qui mi query
local M=r(M)
scalar r2=0
scalar cstat=0
qui mi xeq 1/`M': logistic DRIVPLAN_LOT `rhs'; scalar r2=r2+e(r2_p); lroc, nog; 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
Comment