sampleRem: Sample Longuitudinal Data

Description Usage Arguments Details Value Examples

View source: R/sampleRem.R

Description

Sample longuitudinal data with covariates

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
sampleRem(
  n,
  n.times,
  mu = 1:n.times,
  sigma = rep(1, n.times),
  lambda = rep(1, n.times),
  beta = c(2, 1, 0, 0, 0, 1, 1, 0, 0, 0),
  gamma = matrix(0, nrow = n.times, ncol = 10),
  format = "wide",
  latent = FALSE
)

Arguments

n

[integer,>0] sample size

n.times

[integer,>0] number of visits (i.e. measurements per individual).

mu

[numeric vector] expected measurement value at each visit (when all covariates are fixed to 0). Must have length n.times.

sigma

[numeric vector,>0] standard error of the measurements at each visit (when all covariates are fixed to 0). Must have length n.times.

lambda

[numeric vector] covariance between the measurement at each visit and the individual latent variable. Must have length n.times.

beta

[numeric vector of length 10] regression coefficient between the covariates and the latent variable.

gamma

[numeric matrix with n.times rows and 10 columns] regression coefficient specific to each timepoint (i.e. interaction with time).

format

[character] Return the data in the wide format ("wide") or long format ("long")

latent

[logical] Should the latent variable be output?

Details

The generative model is a latent variable model where each outcome (Y_j) load on the latent variable (η) with a coefficient lambda:

Y_j = μ_j + λ_j*η + σ_jε_j

The latent variable is related to the covariates (X_1,…,X_(10)):

η = α + β_1 X_1 + ... + β_{10} X_{10} + ξ

ε_j and ξ are independent random variables with standard normal distribution.

Value

a data.frame

Examples

1
2
3
4
set.seed(10)
dW <- sampleRem(100, n.times = 3, format = "wide")
set.seed(10)
dL <- sampleRem(100, n.times = 3, format = "long")

LMMstar documentation built on Nov. 5, 2021, 1:07 a.m.