# NOT RUN {
data(Cooper03)
#### ML estimation method
## No predictor
summary( model1 <- meta3(y=y, v=v, cluster=District, data=Cooper03) )
## Show all heterogeneity indices and their 95% confidence intervals
summary( meta3(y=y, v=v, cluster=District, data=Cooper03,
intervals.type="LB", I2=c("I2q", "I2hm", "I2am", "ICC")) )
## Year as a predictor
summary( meta3(y=y, v=v, cluster=District, x=scale(Year, scale=FALSE),
data=Cooper03, model.name="Year as a predictor") )
## Equality of level-2 and level-3 heterogeneity
summary( model2 <- meta3(y=y, v=v, cluster=District, data=Cooper03,
RE2.constraints="0.2*EqTau2",
RE3.constraints="0.2*EqTau2",
model.name="Equal Tau2") )
## Compare model2 vs. model1
anova(model1, model2)
#### REML estimation method
## No predictor
summary( reml3(y=y, v=v, cluster=District, data=Cooper03) )
## Level-2 and level-3 variances are constrained equally
summary( reml3(y=y, v=v, cluster=District, data=Cooper03,
RE.equal=TRUE, model.name="Equal Tau2") )
## Year as a predictor
summary( reml3(y=y, v=v, cluster=District, x=scale(Year, scale=FALSE),
data=Cooper03, intervals.type="LB") )
## Handling missing covariates with FIML
## Create 20/56 MCAR data in Year
set.seed(10000)
Year_MCAR <- Cooper03$Year
Year_MCAR[sample(56, 20)] <- NA
summary( meta3X(y=y, v=v, cluster=District, x2=scale(Year_MCAR, scale=FALSE),
data=Cooper03, model.name="NA in Year_MCAR") )
# }
Run the code above in your browser using DataLab