Title: | Robust Analytical Methods for Evaluating Educational Interventions using Randomised Controlled Trials Designs |
---|---|
Description: | Analysing data from evaluations of educational interventions using a randomised controlled trial design. Various analytical tools to perform sensitivity analysis using different methods are supported (e.g. frequentist models with bootstrapping and permutations options, Bayesian models). The included commands can be used for simple randomised trials, cluster randomised trials and multisite trials. The methods can also be used more widely beyond education trials. This package can be used to evaluate other intervention designs using Frequentist and Bayesian multilevel models. |
Authors: | Germaine Uwimpuhwe [aut, cre], Qing Zhang [aut], Akansha Singh [aut], Dimitris Vallis [aut], Jochen Einbeck [aut], Steve Higgins [aut], ZhiMin Xiao [aut], Ewoud De Troyer [aut], Adetayo Kasim [aut] |
Maintainer: | Germaine Uwimpuhwe <[email protected]> |
License: | AGPL (>= 3) |
Version: | 1.1.3 |
Built: | 2024-11-20 06:24:10 UTC |
Source: | CRAN |
It generates bar plot that compares the effect size from eefAnalytics' methods.
ComparePlot( eefAnalyticsList, group, Conditional = TRUE, ES_Total = TRUE, modelNames )
ComparePlot( eefAnalyticsList, group, Conditional = TRUE, ES_Total = TRUE, modelNames )
eefAnalyticsList |
A list of eefAnalytics S3 objects from eefAnalytics package. |
group |
a string/scalar value indicating which intervention to plot. This must be one of the values of intervention variable excluding the control group. For a two arm trial, the maximum number of values to consider is 1 and 2 for three arm trial. |
Conditional |
a logical value to indicate whether to plot conditional effect size. The default is Conditional=TRUE, otherwise Conditional=FALSE should be specified for plot based on unconditional effect size. Conditional variance is total or residual variance a multilevel model with fixed effects, whilst unconditional variance is total variance or residual variance from a multilevel model with only intercept as fixed effect. |
ES_Total |
A logical value indicating whether to plot the effect size based on total variance or within school variance. The default is ES_Total=TRUE, to plot effect size using total variance. ES_Total=FALSE should be specified for effect size based on within school or residuals variance. |
modelNames |
a string factor containing the names of model to compare. See examples below. |
ComparePlot
produces a bar plot which compares the effect sizes and the associated confidence intervals from the different models.
For a multilevel model, it shows the effect size based on residual variance and total variance.
Returns a bar plot to compare the different methods. The returned figure can be further modified as any ggplot
if(interactive()){ data(mstData) ############### ##### SRT ##### ############### outputSRT <- srtFREQ(Posttest~ Intervention + Prettest, intervention = "Intervention", data = mstData) outputSRTBoot <- srtFREQ(Posttest~ Intervention + Prettest, intervention = "Intervention",nBoot=1000, data = mstData) ############### ##### MST ##### ############### outputMST <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", data = mstData) outputMSTBoot <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nBoot = 1000, data = mstData) ################## ##### Bayesian ##### ################## outputSRTbayes <- srtBayes(Posttest~ Intervention + Prettest, intervention = "Intervention", nsim = 2000, data = mstData) ## comparing different results ComparePlot(list(outputSRT,outputSRTBoot,outputMST,outputMSTBoot,outputSRTbayes), modelNames =c("ols", "olsBoot","MLM","MLMBoot","OLSBayes"),group=1) }
if(interactive()){ data(mstData) ############### ##### SRT ##### ############### outputSRT <- srtFREQ(Posttest~ Intervention + Prettest, intervention = "Intervention", data = mstData) outputSRTBoot <- srtFREQ(Posttest~ Intervention + Prettest, intervention = "Intervention",nBoot=1000, data = mstData) ############### ##### MST ##### ############### outputMST <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", data = mstData) outputMSTBoot <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nBoot = 1000, data = mstData) ################## ##### Bayesian ##### ################## outputSRTbayes <- srtBayes(Posttest~ Intervention + Prettest, intervention = "Intervention", nsim = 2000, data = mstData) ## comparing different results ComparePlot(list(outputSRT,outputSRTBoot,outputMST,outputMSTBoot,outputSRTbayes), modelNames =c("ols", "olsBoot","MLM","MLMBoot","OLSBayes"),group=1) }
crtBayes
performs Bayesian multilevel analysis of cluster randomised education trials, utilising vague priors
and JAGS language to fit the model. It assumes hierarchical clustering, such as students within schools, and estimates
treatment effects while accounting for this structure.
crtBayes(formula, random, intervention, nsim = 10000, data)
crtBayes(formula, random, intervention, nsim = 10000, data)
formula |
The model to be analysed. It should be of the form y ~ x1 + x2 + ..., where y is the outcome variable and Xs are the predictors. |
random |
A string specifying the "clustering variable" (e.g., schools or sites) as found in the dataset. |
intervention |
A string specifying the "intervention variable" as it appears in the formula. |
nsim |
Number of MCMC iterations to be performed. A minimum of 10,000 is recommended to ensure convergence. |
data |
A data frame containing the variables referenced in the formula, including predictors, the clustering variable, and the intervention. |
The function provides posterior estimates for fixed effects (predictors) and random effects (clustering) under a Bayesian framework. Effect sizes are computed using Hedges' g, and variance components are decomposed into between-cluster and within-cluster variances.
S3 object; a list consisting of:
Beta
: Estimates and credible intervals for the predictors specified in the model (posterior distributions).
ES
: Hedges' g effect size for the intervention(s). If bootstrapping is not used, 95% credible intervals are computed based on MCMC sampling.
covParm
: Variance components broken down into between-cluster variance (e.g., between schools), within-cluster variance (e.g., within pupils), and intra-cluster correlation (ICC)..
ProbES
: A matrix showing the probability of observing an effect size larger than various thresholds (0, 0.05, 0.10, ...).
Unconditional
: A list containing the unconditional effect size and variance decomposition.
if(interactive()){ data(crtData) ######################################################## ## Bayesian analysis of cluster randomised trials ## ######################################################## output <- crtBayes(formula = Posttest ~ Prettest + Intervention, random = "School", intervention = "Intervention", nsim = 10000, data = crtData) output ### Fixed effects beta <- output$Beta beta ### Effect size ES1 <- output$ES ES1 ## Covariance matrix covParm <- output$covParm covParm ## Prob ES ProbES <- output$ProbES ProbES ## Unconditional Unconditional <- output$Unconditional Unconditional ### plot random effects for schools plot(output) ### plot posterior probability of an effect size to be bigger than a pre-specified threshold plot(output,group=1) ########################################################################################### ## Bayesian analysis of cluster randomised trials using informative priors for treatment ## ########################################################################################### ### define priors for explanatory variables my_prior <- normal(location = c(0,6), scale = c(10,1)) ### specify the priors for the conditional model only output2 <- crtBayes(Posttest~ Prettest+Intervention,random="School", intervention="Intervention",nsim=2000,data=crtData, condopt=list(prior=my_prior)) ### Fixed effects beta2 <- output2$Beta beta2 ### Effect size ES2 <- output2$ES ES2 }
if(interactive()){ data(crtData) ######################################################## ## Bayesian analysis of cluster randomised trials ## ######################################################## output <- crtBayes(formula = Posttest ~ Prettest + Intervention, random = "School", intervention = "Intervention", nsim = 10000, data = crtData) output ### Fixed effects beta <- output$Beta beta ### Effect size ES1 <- output$ES ES1 ## Covariance matrix covParm <- output$covParm covParm ## Prob ES ProbES <- output$ProbES ProbES ## Unconditional Unconditional <- output$Unconditional Unconditional ### plot random effects for schools plot(output) ### plot posterior probability of an effect size to be bigger than a pre-specified threshold plot(output,group=1) ########################################################################################### ## Bayesian analysis of cluster randomised trials using informative priors for treatment ## ########################################################################################### ### define priors for explanatory variables my_prior <- normal(location = c(0,6), scale = c(10,1)) ### specify the priors for the conditional model only output2 <- crtBayes(Posttest~ Prettest+Intervention,random="School", intervention="Intervention",nsim=2000,data=crtData, condopt=list(prior=my_prior)) ### Fixed effects beta2 <- output2$Beta beta2 ### Effect size ES2 <- output2$ES ES2 }
A cluster randomised trial dataset containing 22 schools. The data contains a random sample of test data of pupils and not actual trial data.
A data frame with 265 rows and 5 variables
Posttest: posttest scores
Prettest: prettest scores
Intervention: the indicator for intervention groups in a two arm trial, coded as 1 for intervention group and 0 for control group.
Intervention2: a simulated indicator for intervention groups in a three arm trial.
School: numeric school identifier
crtFREQ
performs analysis of cluster randomised education trials using a multilevel model under a frequentist setting.
crtFREQ( formula, random, intervention, baseln, nPerm, nBoot, type, ci, seed, data )
crtFREQ( formula, random, intervention, baseln, nPerm, nBoot, type, ci, seed, data )
formula |
the model to be analysed is of the form y ~ x1+x2+.... Where y is the outcome variable and Xs are the independent variables. |
random |
a string variable specifying the "clustering variable" as contained in the data. See example below. |
intervention |
a string variable specifying the "intervention variable" as appearing in the formula and the data. See example below. |
baseln |
A string variable allowing the user to specify the reference category for intervention variable. When not specified, the first level will be used as a reference. |
nPerm |
number of permutations required to generate a permutated p-value. |
nBoot |
number of bootstraps required to generate bootstrap confidence intervals. |
type |
method of bootstrapping including case re-sampling at student level "case(1)", case re-sampling at school level "case(2)", case re-sampling at both levels "case(1,2)" and residual bootstrapping using "residual". If not provided, default will be case re-sampling at student level. |
ci |
method for bootstrap confidence interval calculations; options are the Basic (Hall's) confidence interval "basic" or the simple percentile confidence interval "percentile". If not provided default will be percentile. |
seed |
seed required for bootstrapping and permutation procedure, if not provided default seed will be used. |
data |
data frame containing the data to be analysed. |
S3 object; a list consisting of
Beta
: Estimates and confidence intervals for variables specified in the model.
ES
: Conditional Hedges' g effect size and its 95% confidence intervals. If nBoot is not specified, 95% confidence intervals are based on standard errors. If nBoot is specified, they are non-parametric bootstrapped confidence intervals.
covParm
: A vector of variance decomposition into between cluster variance (Schools) and within cluster variance (Pupils). It also contains intra-cluster correlation (ICC).
SchEffects
: A vector of the estimated deviation of each school from the intercept.
Perm
: A "nPerm x 2w" matrix containing permutated effect sizes using residual variance and total variance. "w" denotes number of intervention. "w=1" for two arm trial and "w=2" for three arm trial excluding the control group. It is produced only when nPerm
is specified.
Bootstrap
: A "nBoot x 2w" matrix containing the bootstrapped effect sizes using residual variance (Within) and total variance (Total). "w" denotes number of intervention. "w=1" for two arm trial and "w=2" for three arm trial excluding the control group. It is only produced when nBoot
is specified.
Unconditional
: A list of unconditional effect sizes, covParm, Perm and Bootstrap obtained based on variances from the unconditional model (model with only the intercept as a fixed effect).
if(interactive()){ data(crtData) ######################################################## ## MLM analysis of cluster randomised trials + 1.96SE ## ######################################################## output1 <- crtFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",data=crtData) ### Fixed effects beta <- output1$Beta beta ### Effect size ES1 <- output1$ES ES1 ## Covariance matrix covParm <- output1$covParm covParm ### plot random effects for schools plot(output1) ################################################## ## MLM analysis of cluster randomised trials ## ## with residual bootstrap confidence intervals ## ################################################## output2 <- crtFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",nBoot=1000,type="residual",data=crtData) ### Effect size ES2 <- output2$ES ES2 ### plot bootstrapped values plot(output2, group=1) ####################################################################### ## MLM analysis of cluster randomised trials with permutation p-value## ####################################################################### output3 <- crtFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",nPerm=1000,data=crtData) ### Effect size ES3 <- output3$ES ES3 ### plot permutated values plot(output3, group=1) }
if(interactive()){ data(crtData) ######################################################## ## MLM analysis of cluster randomised trials + 1.96SE ## ######################################################## output1 <- crtFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",data=crtData) ### Fixed effects beta <- output1$Beta beta ### Effect size ES1 <- output1$ES ES1 ## Covariance matrix covParm <- output1$covParm covParm ### plot random effects for schools plot(output1) ################################################## ## MLM analysis of cluster randomised trials ## ## with residual bootstrap confidence intervals ## ################################################## output2 <- crtFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",nBoot=1000,type="residual",data=crtData) ### Effect size ES2 <- output2$ES ES2 ### plot bootstrapped values plot(output2, group=1) ####################################################################### ## MLM analysis of cluster randomised trials with permutation p-value## ####################################################################### output3 <- crtFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",nPerm=1000,data=crtData) ### Effect size ES3 <- output3$ES ES3 ### plot permutated values plot(output3, group=1) }
This function computes the Gain Index and other related statistics for educational trials. Gain index provides a proportion of pupils who would not have make good progress without intervention. This function supports flexible configurations for JAGS modeling.
GainIndex( data, formula, random, intervention, NA.omit = TRUE, n.iter = 20000, n.chains = 3, n.burnin = 10000, inits = NULL, model.file = NULL, alpha = 0.05 )
GainIndex( data, formula, random, intervention, NA.omit = TRUE, n.iter = 20000, n.chains = 3, n.burnin = 10000, inits = NULL, model.file = NULL, alpha = 0.05 )
data |
A list containing the data for the JAGS model which must include columns: School, Posttest, Pretest, Intervention. Data should not have any missing values in these columns. |
formula |
the model to be analysed is of the form y ~ x1+x2+.... Where y is the outcome variable and Xs are the independent variables. Formula does not need to include |
random |
a string variable specifying the "clustering variable" as contained in the data. See example below. |
intervention |
a string variable specifying the "intervention variable" as appearing in the formula and the data. See example below. |
NA.omit |
Optional; a logic to check if omitting missing value. If NA.omit = TRUE, results will output the percentage of missing value in the four required columns and then JAGS results. If NA.omit = FALSE, will give a warning "Please handle missing values before using GainIndex()." If not provided, the function uses default TRUE. |
n.iter |
Total number of iterations for the MCMC simulation. |
n.chains |
Number of chains to run in the MCMC simulation. |
n.burnin |
Number of burn-in iterations to be discarded before analysis. |
inits |
Optional; a list of initial values for the JAGS model. If NULL, the function generates default initial values. |
model.file |
Optional; a custom path to the JAGS model file. If not provided, the function uses default path. |
alpha |
significant level, default alpha = 0.05. |
An S3 object containing the following components:
A data frame containing the Gain Index and its 95% confidence intervals, as well as the Progress Index and its 95% confidence intervals.
A data frame showing the proportion of participants achieving each level of gain (low and high) for both control and intervention groups.
A vector with execution time details, including user and elapsed time in seconds.
######### EXAMPLE ONE: crtData ######### ## Not run: data(crtData) output1 <- GainIndex(data = crtData, formula = Posttest~Prettest, random = "School",n.iter = 200, intervention = "Intervention", NA.omit = T, alpha = 0.05) output1 ########## EXAMPLE TWO: mstData ###### data(mstData) output1 <- GainIndex(data = mstData, formula = Posttest~Prettest, random = "School",n.iter = 200, intervention = "Intervention", NA.omit = T, alpha = 0.05) output1 ## End(Not run)
######### EXAMPLE ONE: crtData ######### ## Not run: data(crtData) output1 <- GainIndex(data = crtData, formula = Posttest~Prettest, random = "School",n.iter = 200, intervention = "Intervention", NA.omit = T, alpha = 0.05) output1 ########## EXAMPLE TWO: mstData ###### data(mstData) output1 <- GainIndex(data = mstData, formula = Posttest~Prettest, random = "School",n.iter = 200, intervention = "Intervention", NA.omit = T, alpha = 0.05) output1 ## End(Not run)
mstBayes
performs Bayesian multilevel analysis of multisite randomised education trials, utilising vague priors
and JAGS language to fit the model. It assumes hierarchical clustering, such as students within schools, and estimates
treatment effects while accounting for this structure.
mstBayes(formula, random, intervention, nsim, data)
mstBayes(formula, random, intervention, nsim, data)
formula |
The model to be analysed. It should be of the form y ~ x1 + x2 + ..., where y is the outcome variable and Xs are the predictors. |
random |
A string specifying the "clustering variable" (e.g., schools or sites) as found in the dataset. |
intervention |
A string specifying the "intervention variable" as it appears in the formula. |
nsim |
Number of MCMC iterations to be performed. A minimum of 10,000 is recommended to ensure convergence. |
data |
A data frame containing the variables referenced in the formula, including predictors, the clustering variable, and the intervention. |
The function provides posterior estimates for fixed effects (predictors) and random effects (clustering) under a Bayesian framework. Effect sizes are computed using Hedges' g, and variance components are decomposed into between-cluster and within-cluster variances.
S3 object; a list consisting of:
Beta
: Estimates and credible intervals for the predictors specified in the model (posterior distributions).
ES
: Hedges' g effect size for the intervention(s). If bootstrapping is not used, 95% credible intervals are computed based on MCMC sampling.
covParm
: Variance components broken down into between-cluster variance (e.g., between schools), within-cluster variance (e.g., within pupils), and intra-cluster correlation (ICC)..
randomEffects
: Posterior estimates of random intercepts for each cluster (e.g., schools).
ProbES
: A matrix showing the probability of observing an effect size larger than various thresholds (0, 0.05, 0.10, ...).
Unconditional
: A list containing the unconditional effect size and variance decomposition.
if(interactive()){ data(mstData) ######################################################## ## Bayesian analysis of multisite randomised trials ## ######################################################## output <- mstBayes(formula = Posttest ~ Prettest + Intervention, random = "School", intervention = "Intervention", nsim = 10000, data = mstData) output ### Fixed effects beta <- output$Beta beta ### Effect size ES1 <- output$ES ES1 ## Covariance matrix covParm <- output$covParm covParm ## Prob ES ProbES <- output$ProbES ProbES ## Unconditional Unconditional <- output$Unconditional Unconditional ## Random Effect randomEffects <- output$SchEffects randomEffects ### plot random effects for schools plot(output) ### plot posterior probability of an effect size to be bigger than a pre-specified threshold plot(output,group=1) ############################################################################################# ## Bayesian analysis of multisite randomised trials using informative priors for treatment ## ############################################################################################# ### define priors for explanatory variables my_prior <- normal(location = c(0,6), scale = c(10,1)) ### specify the priors for the conditional model only output2 <- mstBayes(Posttest~ Prettest+Intervention,random="School", intervention="Intervention",nsim=2000,data=mstData, condopt=list(prior=my_prior)) ### Fixed effects beta2 <- output2$Beta beta2 ### Effect size ES2 <- output2$ES ES2 }
if(interactive()){ data(mstData) ######################################################## ## Bayesian analysis of multisite randomised trials ## ######################################################## output <- mstBayes(formula = Posttest ~ Prettest + Intervention, random = "School", intervention = "Intervention", nsim = 10000, data = mstData) output ### Fixed effects beta <- output$Beta beta ### Effect size ES1 <- output$ES ES1 ## Covariance matrix covParm <- output$covParm covParm ## Prob ES ProbES <- output$ProbES ProbES ## Unconditional Unconditional <- output$Unconditional Unconditional ## Random Effect randomEffects <- output$SchEffects randomEffects ### plot random effects for schools plot(output) ### plot posterior probability of an effect size to be bigger than a pre-specified threshold plot(output,group=1) ############################################################################################# ## Bayesian analysis of multisite randomised trials using informative priors for treatment ## ############################################################################################# ### define priors for explanatory variables my_prior <- normal(location = c(0,6), scale = c(10,1)) ### specify the priors for the conditional model only output2 <- mstBayes(Posttest~ Prettest+Intervention,random="School", intervention="Intervention",nsim=2000,data=mstData, condopt=list(prior=my_prior)) ### Fixed effects beta2 <- output2$Beta beta2 ### Effect size ES2 <- output2$ES ES2 }
A multisite trial dataset containing 54 schools. This data contains a random sample of test data of pupils and not actual trial data.
A data frame with 210 rows and 5 variables
Posttest: posttest scores
Prettest: prettest scores
Intervention: the indicator for the intervention groups in a two arm trial, coded as 1 for intervention group and 0 for control group.
Intervention2: a simulated indicator for intervention groups in a three arm trial.
School: numeric school identifier
mstFREQ
performs analysis of multisite randomised education trials using a multilevel model under a frequentist setting.
mstFREQ( formula, random, intervention, baseln, nPerm, data, type, ci, seed, nBoot )
mstFREQ( formula, random, intervention, baseln, nPerm, data, type, ci, seed, nBoot )
formula |
the model to be analysed is of the form y ~ x1+x2+.... Where y is the outcome variable and Xs are the independent variables. |
random |
a string variable specifying the "clustering variable" as contained in the data. See example below. |
intervention |
a string variable specifying the "intervention variable" as appearing in the formula and the data. See example below. |
baseln |
A string variable allowing the user to specify the reference category for intervention variable. When not specified, the first level will be used as a reference. |
nPerm |
number of permutations required to generate permutated p-value. |
data |
data frame containing the data to be analysed. |
type |
method of bootstrapping including case re-sampling at student level "case(1)", case re-sampling at school level "case(2)", case re-sampling at both levels "case(1,2)" and residual bootstrapping using "residual". If not provided, default will be case re-sampling at student level. |
ci |
method for bootstrap confidence interval calculations; options are the Basic (Hall's) confidence interval "basic" or the simple percentile confidence interval "percentile". If not provided default will be percentile. |
seed |
seed required for bootstrapping and permutation procedure, if not provided default seed will be used. |
nBoot |
number of bootstraps required to generate bootstrap confidence intervals. |
S3 object; a list consisting of
Beta
: Estimates and confidence intervals for variables specified in the model.
ES
: Conditional Hedge's g effect size (ES) and its 95% confidence intervals. If nBoot is not specified, 95% confidence intervals are based on standard errors. If nBoot is specified, they are non-parametric bootstrapped confidence intervals.
covParm
: A list of variance decomposition into between cluster variance-covariance matrix (schools and school by intervention) and within cluster variance (Pupils). It also contains intra-cluster correlation (ICC).
SchEffects
: A vector of the estimated deviation of each school from the intercept and intervention slope.
Perm
: A "nPerm x 2w" matrix containing permutated effect sizes using residual variance and total variance. "w" denotes number of intervention. "w=1" for two arm trial and "w=2" for three arm trial excluding the control group. It is produced only when nPerm
is specified.
Bootstrap
: A "nBoot x 2w" matrix containing the bootstrapped effect sizes using residual variance (Within) and total variance (Total). "w" denotes number of intervention. "w=1" for two arm trial and "w=2" for three arm trial excluding the control group. It is only produced when nBoot
is specified.
Unconditional
: A list of unconditional effect sizes, covParm, Perm and Bootstrap obtained based on variances from the unconditional model (model with only the intercept as a fixed effect).
if(interactive()){ data(mstData) ############################################### ## MLM analysis of multisite trials + 1.96SE ## ############################################### output1 <- mstFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",data=mstData) ### Fixed effects beta <- output1$Beta beta ### Effect size ES1 <- output1$ES ES1 ## Covariance matrix covParm <- output1$covParm covParm ### plot random effects for schools plot(output1) ################################################## ## MLM analysis of multisite trials ## ## with residual bootstrap confidence intervals ## ################################################## output2 <- mstFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",nBoot=1000,type="residual",data=mstData) tp <- output2$Bootstrap ### Effect size ES2 <- output2$ES ES2 ### plot bootstrapped values plot(output2, group=1) ####################################################################### ## MLM analysis of mutltisite trials with permutation p-value## ####################################################################### output3 <- mstFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",nPerm=1000,data=mstData) ES3 <- output3$ES ES3 #### plot permutated values plot(output3, group=1) }
if(interactive()){ data(mstData) ############################################### ## MLM analysis of multisite trials + 1.96SE ## ############################################### output1 <- mstFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",data=mstData) ### Fixed effects beta <- output1$Beta beta ### Effect size ES1 <- output1$ES ES1 ## Covariance matrix covParm <- output1$covParm covParm ### plot random effects for schools plot(output1) ################################################## ## MLM analysis of multisite trials ## ## with residual bootstrap confidence intervals ## ################################################## output2 <- mstFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",nBoot=1000,type="residual",data=mstData) tp <- output2$Bootstrap ### Effect size ES2 <- output2$ES ES2 ### plot bootstrapped values plot(output2, group=1) ####################################################################### ## MLM analysis of mutltisite trials with permutation p-value## ####################################################################### output3 <- mstFREQ(Posttest~ Intervention+Prettest,random="School", intervention="Intervention",nPerm=1000,data=mstData) ES3 <- output3$ES ES3 #### plot permutated values plot(output3, group=1) }
Plots different figures based on output from eefAnalytics package.
## S3 method for class 'eefAnalytics' plot(x, group, Conditional = TRUE, ES_Total = TRUE, slope = FALSE, ...)
## S3 method for class 'eefAnalytics' plot(x, group, Conditional = TRUE, ES_Total = TRUE, slope = FALSE, ...)
x |
an output object from the eefAnalytics package. |
group |
a string/scalar value indicating which intervention to plot. This must be one of the values of intervention variable excluding the control group. For a two arm trial, the maximum number of values to consider is 1 and 2 for three arm trial. |
Conditional |
a logical value to indicate whether to plot the conditional effect size. The default is Conditional=TRUE, otherwise Conditional=FALSE should be specified for plot based on the unconditional effect size. Conditional variance is total or residual variance from a multilevel model with fixed effects, whilst unconditional variance is total variance or residual variance from a multilevel model with only intercept as fixed effect. |
ES_Total |
A logical value indicating whether to plot the effect size based on total variance or within school variance. The default is ES_Total=TRUE, to plot the effect size using total variance. ES_Total=FALSE should be specified for the effect size based on within school or residuals variance. |
slope |
A logical value indicating whether to return the plot of random intercept (default is slope=FALSE). return other school-by-intervention interaction random slope (s) is slope=TRUE. This argument is suitable only for mstBayes and mstFREQ functions. |
... |
arguments passed to |
Plot produces a graphical visualisation depending on which model is fitted:
For srtFREQ()
, plot can only be used when nBoot
or nPerm
is specified to visualise the distribution of bootstrapped or permutated values.
For crtFREQ()
or mstFREQ()
, plot shows the distribution of random intercepts when group=NULL
.
It produces histogram of permutated or bootstrapped values when group
is specified and either nBoot
or nPerm
is also specified.
Returns relevant plots for each model.
if(interactive()){ #### read data data(mstData) data(crtData) ############### ##### SRT ##### ############### ##### Bootstrapped outputSRTBoot <- srtFREQ(Posttest~ Intervention + Prettest, intervention = "Intervention",nBoot=1000, data = mstData) plot(outputSRTBoot,group=1) ##### Permutation outputSRTPerm <- srtFREQ(Posttest~ Intervention + Prettest, intervention = "Intervention",nPerm=1000, data = mstData) plot(outputSRTPerm,group=1) ############### ##### MST ##### ############### #### Random intercepts outputMST <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", data = mstData) plot(outputMST) #### Bootstrapped outputMSTBoot <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nBoot = 1000, data = mstData) plot(outputMSTBoot) plot(outputMSTBoot,group=1) #### Permutation outputMSTPerm <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nPerm = 1000, data = mstData) plot(outputMSTPerm) plot(outputMSTPerm,group=1) ############### ##### CRT ##### ############### #### Random intercepts outputCRT <- crtFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", data = crtData) plot(outputCRT) ## Bootstrapped outputCRTBoot <- crtFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nBoot = 1000, data = crtData) plot(outputCRTBoot,group=1) ##Permutation outputCRTPerm <- crtFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nPerm = 1000, data = crtData) plot(outputCRTPerm,group=1) }
if(interactive()){ #### read data data(mstData) data(crtData) ############### ##### SRT ##### ############### ##### Bootstrapped outputSRTBoot <- srtFREQ(Posttest~ Intervention + Prettest, intervention = "Intervention",nBoot=1000, data = mstData) plot(outputSRTBoot,group=1) ##### Permutation outputSRTPerm <- srtFREQ(Posttest~ Intervention + Prettest, intervention = "Intervention",nPerm=1000, data = mstData) plot(outputSRTPerm,group=1) ############### ##### MST ##### ############### #### Random intercepts outputMST <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", data = mstData) plot(outputMST) #### Bootstrapped outputMSTBoot <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nBoot = 1000, data = mstData) plot(outputMSTBoot) plot(outputMSTBoot,group=1) #### Permutation outputMSTPerm <- mstFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nPerm = 1000, data = mstData) plot(outputMSTPerm) plot(outputMSTPerm,group=1) ############### ##### CRT ##### ############### #### Random intercepts outputCRT <- crtFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", data = crtData) plot(outputCRT) ## Bootstrapped outputCRTBoot <- crtFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nBoot = 1000, data = crtData) plot(outputCRTBoot,group=1) ##Permutation outputCRTPerm <- crtFREQ(Posttest~ Intervention + Prettest, random = "School", intervention = "Intervention", nPerm = 1000, data = crtData) plot(outputCRTPerm,group=1) }
eefAnalytics
object.Print for a fitted model represented by an eefAnalytics
object.
## S3 method for class 'eefAnalytics' print(x, ...)
## S3 method for class 'eefAnalytics' print(x, ...)
x |
Object of class |
... |
Additional arguments of |
Print conditional and unconditional effect sizes.
srtBayes
performs Bayesian multilevel analysis of Simple Randomised Education Trials (SRT), utilising vague priors
and JAGS language to fit the model.
This can also be used with schools as fixed effects.
srtBayes(formula, intervention, nsim = 10000, data)
srtBayes(formula, intervention, nsim = 10000, data)
formula |
The model to be analysed is of the form y~x1+x2+.... Where y is the outcome variable and Xs are the independent variables. |
intervention |
A string variable specifying the "intervention variable" as appearing in the formula and the data. See example below. |
nsim |
number of MCMC iterations per chain. Default is 2000. |
data |
Data frame containing the data to be analysed. |
S3 object; a list consisting of
Beta
: Estimates and credible intervals for the variables specified in the model. Use summary.eefAnalytics
to get Rhat and effective sample size for each estimate.
ES
: Conditional Hedges' g effect size and its 95% credible intervals.
sigma
: Residual variance.
ProbES
: A matrix of Bayesian posterior probabilities such that the observed effect size is greater than or equal to a pre-specified threshold(s).
Unconditional
: A list of unconditional effect sizes, sigma2 and ProbES obtained based on residual variance from the unconditional model (model with only the intercept as a fixed effect).
if(interactive()){ data(mstData) ######################################################## ## Bayesian analysis of simple randomised trials ## ######################################################## output <- srtBayes(Posttest~ Intervention+Prettest, intervention="Intervention",nsim=10000,data=mstData) ### Fixed effects beta <- output$Beta beta ### Effect size ES1 <- output$ES ES1 ## Covariance matrix covParm <- output$covParm covParm ### plot random effects for schools plot(output) ### plot posterior probability of an effect size to be bigger than a pre-specified threshold plot(output,group=1) ########################################################################################### ## Bayesian analysis of simple randomised trials using informative priors for treatment ## ########################################################################################### ### define priors for explanatory variables my_prior <- normal(location = c(0,6), scale = c(10,1)) ### specify the priors for the conditional model only output2 <- srtBayes(Posttest~ Prettest+Intervention, intervention="Intervention", nsim=2000,data=mstData, condopt=list(prior=my_prior)) ### Fixed effects beta2 <- output2$Beta beta2 ### Effect size ES2 <- output2$ES ES2 }
if(interactive()){ data(mstData) ######################################################## ## Bayesian analysis of simple randomised trials ## ######################################################## output <- srtBayes(Posttest~ Intervention+Prettest, intervention="Intervention",nsim=10000,data=mstData) ### Fixed effects beta <- output$Beta beta ### Effect size ES1 <- output$ES ES1 ## Covariance matrix covParm <- output$covParm covParm ### plot random effects for schools plot(output) ### plot posterior probability of an effect size to be bigger than a pre-specified threshold plot(output,group=1) ########################################################################################### ## Bayesian analysis of simple randomised trials using informative priors for treatment ## ########################################################################################### ### define priors for explanatory variables my_prior <- normal(location = c(0,6), scale = c(10,1)) ### specify the priors for the conditional model only output2 <- srtBayes(Posttest~ Prettest+Intervention, intervention="Intervention", nsim=2000,data=mstData, condopt=list(prior=my_prior)) ### Fixed effects beta2 <- output2$Beta beta2 ### Effect size ES2 <- output2$ES ES2 }
srtFREQ
performs analysis of educational trials under the assumption of independent errors among pupils.
This can also be used with schools as fixed effects.
srtFREQ(formula, intervention, baseln, nBoot, nPerm, ci, seed, data)
srtFREQ(formula, intervention, baseln, nBoot, nPerm, ci, seed, data)
formula |
the model to be analysed is of the form y~x1+x2+.... Where y is the outcome variable and Xs are the independent variables. |
intervention |
a string variable specifying the "intervention variable" as appearing in the formula and the data. See example below. |
baseln |
A string variable allowing the user to specify the reference category for intervention variable. When not specified, the first level will be used as a reference. |
nBoot |
number of bootstraps required to generate bootstrap confidence intervals. |
nPerm |
number of permutations required to generate permutated p-value. |
ci |
method for bootstrap confidence interval calculations; options are the Basic (Hall's) confidence interval "basic" or the simple percentile confidence interval "percentile". If not provided default will be percentile. |
seed |
seed required for bootstrapping and permutation procedure, if not provided default seed will be used. |
data |
data frame containing the data to be analysed. |
S3 object; a list consisting of
Beta
: Estimates and confidence intervals for the variables specified in the model.
ES
: Conditional Hedges'g effect size and its 95% confidence intervals. If nBoot is not specified, 95% confidence intervals are based on standard errors. If nBoot is specified, they are non-parametric bootstrapped confidence intervals.
sigma2
: Residual variance.
Perm
: A "nPerm x w" matrix containing permutated effect sizes using residual variance. "w" denotes number of intervention. "w=1" for two arm trial and "w=2" for three arm trial excluding the control group. It is produced only if nPerm
is specified.
Bootstrap
: A "nBoot x w" matrix containing the bootstrapped effect sizes using residual variance. "w" denotes number of intervention. "w=1" for two arm trial and "w=2" for three arm trial excluding the control group. It is produced only if nBoot
is specified.
Unconditional
: A list of unconditional effect size, sigma2, Perm and Bootstrap obtained based on variances from the unconditional model (model with only intercept as fixed effect).
if(interactive()){ data(mstData) ################################################################### ## Analysis of simple randomised trials using Hedges Effect Size ## ################################################################### output1 <- srtFREQ(Posttest~ Intervention+Prettest, intervention="Intervention",data=mstData ) ES1 <- output1$ES ES1 ################################################################### ## Analysis of simple randomised trials using Hedges Effect Size ## ## with Permutation p-value ## ################################################################### output2 <- srtFREQ(Posttest~ Intervention+Prettest, intervention="Intervention",nPerm=1000,data=mstData ) ES2 <- output2$ES ES2 #### plot permutated values plot(output2, group=1) ################################################################### ## Analysis of simple randomised trials using Hedges Effect Size ## ## with non-parametric Basic bootstrap confidence intervals ## ################################################################### output3 <- srtFREQ(Posttest~ Intervention+Prettest, intervention="Intervention",nBoot=1000,ci="basic",data=mstData) ES3 <- output3$ES ES3 ### plot bootstrapped values plot(output3, group=1) #################################################################### ## Analysis of simple randomised trials using Hedges' effect size ## ## with schools as fixed effects ## #################################################################### output4 <- srtFREQ(Posttest~ Intervention+Prettest+as.factor(School), intervention="Intervention",data=mstData ) ES4 <- output4$ES ES4 #################################################################### ## Analysis of simple randomised trials using Hedges' effect size ## ## with schools as fixed effects and with permutation p-value ## #################################################################### output5 <- srtFREQ(Posttest~ Intervention+Prettest+as.factor(School), intervention="Intervention",nPerm=1000,data=mstData ) ES5 <- output5$ES ES5 #### plot permutated values plot(output5, group=1) #################################################################### ## Analysis of simple randomised trials using Hedges' effect size ## ## with schools as fixed effects and with permutation p-value ## #################################################################### output6 <- srtFREQ(Posttest~ Intervention+Prettest+as.factor(School), intervention="Intervention",nBoot=1000,data=mstData) ES6 <- output6$ES ES6 ### plot bootstrapped values plot(output6, group=1) }
if(interactive()){ data(mstData) ################################################################### ## Analysis of simple randomised trials using Hedges Effect Size ## ################################################################### output1 <- srtFREQ(Posttest~ Intervention+Prettest, intervention="Intervention",data=mstData ) ES1 <- output1$ES ES1 ################################################################### ## Analysis of simple randomised trials using Hedges Effect Size ## ## with Permutation p-value ## ################################################################### output2 <- srtFREQ(Posttest~ Intervention+Prettest, intervention="Intervention",nPerm=1000,data=mstData ) ES2 <- output2$ES ES2 #### plot permutated values plot(output2, group=1) ################################################################### ## Analysis of simple randomised trials using Hedges Effect Size ## ## with non-parametric Basic bootstrap confidence intervals ## ################################################################### output3 <- srtFREQ(Posttest~ Intervention+Prettest, intervention="Intervention",nBoot=1000,ci="basic",data=mstData) ES3 <- output3$ES ES3 ### plot bootstrapped values plot(output3, group=1) #################################################################### ## Analysis of simple randomised trials using Hedges' effect size ## ## with schools as fixed effects ## #################################################################### output4 <- srtFREQ(Posttest~ Intervention+Prettest+as.factor(School), intervention="Intervention",data=mstData ) ES4 <- output4$ES ES4 #################################################################### ## Analysis of simple randomised trials using Hedges' effect size ## ## with schools as fixed effects and with permutation p-value ## #################################################################### output5 <- srtFREQ(Posttest~ Intervention+Prettest+as.factor(School), intervention="Intervention",nPerm=1000,data=mstData ) ES5 <- output5$ES ES5 #### plot permutated values plot(output5, group=1) #################################################################### ## Analysis of simple randomised trials using Hedges' effect size ## ## with schools as fixed effects and with permutation p-value ## #################################################################### output6 <- srtFREQ(Posttest~ Intervention+Prettest+as.factor(School), intervention="Intervention",nBoot=1000,data=mstData) ES6 <- output6$ES ES6 ### plot bootstrapped values plot(output6, group=1) }
eefAnalytics
object.Summary for a fitted model represented by an eefAnalytics
object.
## S3 method for class 'eefAnalytics' summary(object, ...)
## S3 method for class 'eefAnalytics' summary(object, ...)
object |
Object of class |
... |
Additional arguments of |
Returns relevant summary including Rhat and effective sample sizes.