### copy data into 'dat' and examine data
dat <- dat.crede2010
head(dat, 18)
if (FALSE) {
### load metafor package
library(metafor)
### calculate r-to-z transformed correlations and corresponding sampling variances
dat <- escalc(measure="ZCOR", ri=ri, ni=ni, data=dat)
############################################################################
### meta-analysis for the relationship between attendance and grades
res <- rma(yi, vi, data=dat, subset=criterion=="grade")
res
### estimated average correlation with 95% CI/PI
predict(res, transf=transf.ztor, digits=2)
### examine if relationship between attendance and grades differs for nonscience/science classes
res <- rma(yi, vi, mods = ~ class, data=dat, subset=criterion=="grade")
res
### estimated average correlations for nonscience and science classes
predict(res, newmods=c(0,1), transf=transf.ztor, digits=2)
### examine if relationship between attendance and grades has changed over time
res <- rma(yi, vi, mods = ~ year, data=dat, subset=criterion=="grade")
res
############################################################################
### meta-analysis for the relationship between attendance and GPA
res <- rma(yi, vi, data=dat, subset=criterion=="gpa")
res
### estimated average correlation with 95% CI/PI
predict(res, transf=transf.ztor, digits=2)
### examine if relationship between attendance and GPA has changed over time
res <- rma(yi, vi, mods = ~ year, data=dat, subset=criterion=="gpa")
res
############################################################################
### use a multilevel model to examine the relationship between attendance and grades
res <- rma.mv(yi, vi, random = ~ 1 | studyid/sampleid, data=dat, subset=criterion=="grade")
res
predict(res, transf=transf.ztor, digits=2)
### use a multilevel model to examine the relationship between attendance and gpa
res <- rma.mv(yi, vi, random = ~ 1 | studyid/sampleid, data=dat, subset=criterion=="gpa")
res
predict(res, transf=transf.ztor, digits=2)
}
Run the code above in your browser using DataLab