Last data update: 2014.03.03

R: simulate data
datageneratorR Documentation

simulate data

Description

Simulate data for demonstration of flarcc.

Usage

datagenerator(n = n, beta0 = beta0, family = "gaussian", seed = seed)

Arguments

n

sample size for each study, a vector of length K, the number of studies; can also be an scalar, to specify equal sample size

beta0

coefficient matrix, with dimension K * p, where K is the number of studies and p is the number of covariates

family

"gaussian" for continuous response, "binomial" for binary response, "poisson" for count response

seed

set random seed for data generation

Details

These data sets are artifical, and used to test out some features of flarcc.

Value

a simulated data frame will be returned, containing y, X, and study ID sid

Examples

n <- 200    # sample size in each study
K <- 10     # number of studies
p <- 3      # number of covariates in X (including intercept)
N <- n*K    # total sample size

# the coefficient matrix, used this to set desired heterogeneous pattern (depends on p and K)
beta0 <- matrix(c(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0, # intercept
                  0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0, # beta_1, etc.
                  0.0,0.0,0.0,0.0,0.5,0.5,0.5,1.0,1.0,1.0), K, p)

# generate a data set, family=c("gaussian", "binomial", "poisson")
data <- datagenerator(n=n, beta0=beta0, family="gaussian", seed=123)

Results