# NOT RUN {
data(Bornmann07)
#### ML estimation method
## No predictor
summary( meta3(y=logOR, v=v, cluster=Cluster, data=Bornmann07) )
## Type as a predictor
## Grant: 0
## Fellowship: 1
summary( meta3(y=logOR, v=v, x=(as.numeric(Type)-1),
cluster=Cluster, data=Bornmann07) )
## Centered Year as a predictor
summary( meta3(y=logOR, v=v, x=scale(Year, scale=FALSE),
cluster=Cluster, data=Bornmann07) )
#### REML estimation method
## No predictor
summary( reml3(y=logOR, v=v, cluster=Cluster, data=Bornmann07) )
## Type as a predictor
## Grants: 0
## Fellowship: 1
summary( reml3(y=logOR, v=v, x=(as.numeric(Type)-1),
cluster=Cluster, data=Bornmann07) )
## Centered Year as a predictor
summary( reml3(y=logOR, v=v, x=scale(Year, scale=FALSE),
cluster=Cluster, data=Bornmann07) )
## Handling missing covariates with FIML
## MCAR
## Set seed for replication
set.seed(1000000)
## Copy Bornmann07 to my.df
my.df <- Bornmann07
## "Fellowship": 1; "Grant": 0
my.df$Type_MCAR <- ifelse(Bornmann07$Type=="Fellowship", yes=1, no=0)
## Create 17 out of 66 missingness with MCAR
my.df$Type_MCAR[sample(1:66, 17)] <- NA
summary(meta3X(y=logOR, v=v, cluster=Cluster, x2=Type_MCAR, data=my.df))
## MAR
Type_MAR <- ifelse(Bornmann07$Type=="Fellowship", yes=1, no=0)
## Create 27 out of 66 missingness with MAR for cases Year<1996
index_MAR <- ifelse(Bornmann07$Year<1996, yes=TRUE, no=FALSE)
Type_MAR[index_MAR] <- NA
## Include auxiliary variable
summary(meta3X(y=logOR, v=v, cluster=Cluster, x2=Type_MAR, av2=Year, data=my.df))
# }
Run the code above in your browser using DataLab