Hi,
I am estimating a random effects logit model with panel data and I want to calculate McKelvey-Zavoina Pseudo R2. Genereally, I would calculate the R2 in this manner: After the xtlogit command, i would estimate:
predict Xb_ori, xb
sum Xb_ori
return list
gen R2MZ = r(Var)/(r(Var) + _pi^2/3)
sum R2MZ
I have learned that this calculation only estimates the within variance, and thus shows how much of the within variance can be explained by the regression of y on x. Thus, when adding time constant variables, the residual variance will not decrease.
However, I have also looked at the two stata ados meresc and r2_mz and they both calculate the McKelvey-Zavoina R2differently for xtmelogit,xtlogit,xtprobit. Instead of setting the variance of the level 1 random effect zero, as the calculation above does, they calcualte a value for e(Var_u1) - the variance of the level 1 - random effect and add that to the denominator:
// Random effects variance (for McKelvey-Zavoina R2)
// -------------------------------------------------
if inlist("`e(cmd)'","xtmelogit","xtlogit","xtprobit" ) {
mata: r2_mz_var_u()
}
else {
sca `Var_ut' = 0
}
predict double `Xb_ori', xb
sum `Xb_ori'
drop `Xb_ori'
scalar `R2_MZ' = r(Var)/(`Var_ut' + `Var_R' + r(Var))
}
With Var_R defined in the ado as _pi^2/3
Do I understand it correctly, that this way of calculating the Pseudo R2 shows how much of the within and between variance can be explained by the regression of y on x? Because know, when adding time constant variables, the residual variance will decrease?
Would it be generally recommended to report the calculation of the ados, and if yes, why?
Related Posts with McKelvey-Zavoina R2 Multilevel Model (Random Effects)
Help summing data for men and womenHi, I have data on the number of people of each age in each local authority. The problem at the mome…
Error message "invalid 'Drive'" when using spwmatrixHi all, I am trying to import a Geoda-generated .gal file into Stata and export it as a .txt file. …
Drop variables if no entry for monthly dates within a yearHello, I am new to Stata. Can you please help me with the following issue: for different companies,…
converting agregate data to individual data DAuid tot_pop tot_male 0_4male 5_9male 10_14male 15_19male 20_24male 25_29male 30_34male 35_3…
Dealing with (technical Stata) duplicates that are not real duplicatesHi, I imported data and merged it with other (pane)l data. Reshaping the data resulted in this mess…
Subscribe to:
Post Comments (Atom)
0 Response to McKelvey-Zavoina R2 Multilevel Model (Random Effects)
Post a Comment