srtBayes: Analysis of Simple Randomised Education Trials using Bayesian...

Description Usage Arguments Value Examples

View source: R/srtBayes.R

Description

srtBayes performs analysis of educational trials under the assumption of independent errors among pupils using Bayesian framework with Stan. This can also be used with schools as fixed effects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
srtBayes(
  formula,
  intervention,
  baseln,
  adaptD,
  nsim = 2000,
  data,
  threshold = 1:10/10,
  ...
)

Arguments

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.

adaptD

As this function uses rstanarm, this term provides the target average proposal acceptance probability during Stan’s adaptation period. Default is NULL.

nsim

A number of MCMC iterations per chain. Default is 2000.

data

Data frame containing the data to be analysed.

threshold

a scalar or vector of pre-specified threshold(s) for estimating Bayesian posterior probability such that the observed effect size is greater than or equal to the threshold(s).

...

Additional arguments of stan_glm to be passed to the function.

Value

S3 object; a list consisting of

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
if(interactive()){

data(mstData)

########################################################
## Bayesian analysis of cluster randomised trials     ##
########################################################

output <- srtBayes(Posttest~ Intervention+Prettest,
		intervention="Intervention",nsim=2000,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)
}

germaine86/eefAnalytics_v10 documentation built on Feb. 20, 2021, 12:13 a.m.