7. Likelihood Ratio Test


Model Data

Stata

Model needs to be restriced to same sample with if e(sample)

use "_data/ess50prep.dta", clear

quietly: xtmixed stfdem || cntry: || region: 
est store level3

quietly: xtmixed stfdem || cntry: if e(sample)
est store level2
lrtest level2 level3

. use "_data/ess50prep.dta", clear

. 
. quietly: xtmixed stfdem || cntry: || region: 

. est store level3

. 
. quietly: xtmixed stfdem || cntry: if e(sample)

. est store level2

. lrtest level2 level3

Likelihood-ratio test                                 LR chi2(1)  =     84.19
(Assumption: level2 nested in level3)                 Prob > chi2 =    0.0000

Note: The reported degrees of freedom assumes the null hypothesis is not on
      the boundary of the parameter space.  If this is not true, then the
      reported test is conservative.

R

Model needs to be restriced to same sample with ess[esample, ]

level2 <- lmer(stfdem ~ (1|cntry/region), data = ess, REML = FALSE)
esample<-rownames(as.matrix(resid(level2)))  # restricts model to same sample
level3 <- lmer(stfdem ~ (1|cntry), data = ess[esample, ], REML = FALSE)
lrtest(level2, level3)
r2(level2, level3)
## R-squared (tau-00): 0.7914
## R-squared (tau-11): NA
##  R-squared (tau-00): 0.0345
## R-squared (tau-11): NA
##      Omega-squared: 0.1050
##          R-squared: 0.0228
##       Omega-squared: 0.0240
##          R-squared: 0.0228