metafor (version 2.4-0)

simulate.rma: Simulate Method for 'rma' Objects

Description

The function simulates observed outcomes based on "rma" model object.

Usage

# S3 method for rma
simulate(object, nsim = 1, seed = NULL, …)

Arguments

object

an object of class "rma".

nsim

number of response vectors to simulate (defaults to 1).

seed

an object specifying if and how the random number generator should be initialized (‘seeded’). Either NULL or an integer that will be used in a call to set.seed before simulating the response vectors. If set, the value is saved as the "seed" attribute of the returned value. The default, NULL will not change the random generator state, and return .Random.seed as the "seed" attribute; see ‘Value’.

other arguments.

Value

A data frame with nsim columns with the simulated outcomes.

The data frame comes with an attribute "seed". If argument seed is NULL, the attribute is the value of .Random.seed before the simulation was started; otherwise it is the value of the argument with a "kind" attribute with value as.list(RNGkind()).

Details

The model specified via object must be a model fitted with either the rma.uni or rma.mv function.

References

Viechtbauer, W. (2010). Conducting meta-analyses in R with the metafor package. Journal of Statistical Software, 36(3), 1--48. https://www.jstatsoft.org/v036/i03.

See Also

rma.uni, rma.mv

Examples

Run this code
# NOT RUN {
### copy BCG vaccine data into 'dat'
dat <- dat.bcg

### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat)
dat

### random-effects model
res <- rma(yi, vi, data=dat)
res

### simulate 10 sets of new outcomes based on the fitted model
newdat <- simulate(res, nsim=10, seed=1234)
newdat
# }

Run the code above in your browser using DataCamp Workspace