make_one_dataset: Simulate time-varying covariates

Description Usage Arguments Details Examples

Description

Simulates a dataset with correlated time-varying covariates with an exchangeable correlation structure. Covariates can be normal or binary and can be static within a cluster or time-varying. Time-varying normal variables can optionally have linear trajectories within each cluster.

Usage

1
make_one_dataset(n, obs, n.TBins, pcor, wcor, parameters, cat.parameters)

Arguments

n

The number of clusters.

obs

The number of observations per cluster.

n.TBins

Number of time-varying binary variables.

pcor

The across-subject correlation matrix. See Details.

wcor

The within-subject correlation matrix. See Details.

parameters

A dataframe containing the general simulation parameters. See Details.

cat.parameters

A dataframe containing parameters for the categorical variables. See Details.

Details

SPECIFYING THE PARAMETERS MATRIX

The matrix parameters contains parameters required to generate all non-categorical variables. It must contain column names name, type, across.mean, across.SD, across.var, within.var, prop, and error.SD. (To see an example, use data(params).) Each variable to be generated requires either one or two rows in parameters, depending on the variable type.

The possible variable types and their corresponding specifications are:

SPECIFYING THE CATEGORICAL PARAMETERS MATRIX

The matrix cat.parameters contains parameters required to generate the single categorical variable, if any. It must contain column names level, parameter, and beta. (To see an example, use data(cat.params).)

SPECIFYING THE POPULATION CORRELATION MATRIX

Matrix pcor specifies the population (i.e., across-cluster) correlation matrix. It should have the same number of rows and columns as parameters as well as the same variable names and ordering of variables.

SPECIFYING THE WITHIN-CLUSTER CORRELATION MATRIX

Matrix wcor specifies the within-cluster correlation matrix. The order of the variables listed in this file should be consistent with the order in params and pcor. However, static.binary and subject.prop variables should not be included in wcor since they are static within a cluster. Static continuous variables should be included, but all the correlations should be set to zero.

Examples

1
2
data = make_one_dataset(n=10, obs=10, n.TBins=2, pcor=pcor, wcor=wcor, 
parameters=complete_parameters(params, n=10), cat.parameters=cat.params)$data

SimTimeVar documentation built on May 2, 2019, 8:31 a.m.