Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

simulate.rma

Simulate Method for 'rma' Objects


Description

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

Usage

## S3 method for class '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.

Details

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

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()).

Author(s)

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

Examples

### 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

metafor

Meta-Analysis Package for R

v2.4-0
GPL (>= 2)
Authors
Wolfgang Viechtbauer [aut, cre] (<https://orcid.org/0000-0003-3463-4063>)
Initial release
2020-03-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.