mvrnorm_corr_gen: Generate Multivariate Random Normal Longitudinal Data

Description Usage Arguments Value Examples

View source: R/mvrnorm_sim.R

Description

For this methodology we assume that we draw a set of n independent each with q_{i} observations.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
mvrnorm_corr_gen(
  n,
  obs,
  t,
  mu,
  sigma,
  rho,
  corr_str = c("ar1", "compound", "ind"),
  zero_trunc = TRUE
)

Arguments

n

integer scalar representing the total number of individuals

obs

vector of length n specifying the number of observations per indivdiual.

t

vector corresponding to the timepoints for each individual.

mu

vector specifying the mean value for individuals.

sigma

scalar specifying the standard deviation for all observations.

rho

numeric scalar value between [0, 1] specifying the amount of correlation between. assumes that the correlation is consistent for all subjects.

corr_str

character value specifying the correlation structure. Currently available methods are \'ar1\', \'compound\', and \'ind\' which correspond to first-order autoregressive, compound or equicorrelation, and independence respecitvely.

zero_trunc

logical value to specifying whether the generating distribution should come from a multivariate zero truncated normal or an untruncated multivariate normal. by default we assume that zero truncation occurs since this is assummed in our microbiome setting.

Value

This function returns a list with the following objects:

df - data.frame object with complete outcome Y, subject ID, time, group, and outcome with missing data

Y - vector of complete outcome

Mu - vector of complete mean specifications used during simulation

Sigma - block diagonal symmetric matrix of complete data used during simulation

N - total number of observations

Examples

1
2
3
4
5
size <- 15
reps <- 4
N <- size*reps
mvrnorm_corr_gen(n=size, obs=rep(reps, size), t=rep(seq_len(4), size),
mu=rep(1, N), sigma=2, rho=0.9, corr_str="ar1")

microbiomeDASim documentation built on Nov. 8, 2020, 10:58 p.m.