sampleRem {LMMstar} | R Documentation |
Sample Longuitudinal Data
Description
Sample longuitudinal data with covariates
Usage
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 |
sigma |
[numeric vector,>0] standard error of the measurements at each visit (when all covariates are fixed to 0). Must have length |
lambda |
[numeric vector] covariance between the measurement at each visit and the individual latent variable. Must have length |
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 ( |
latent |
[logical] Should the latent variable be output? |
Details
The generative model is a latent variable model where each outcome () load on the latent variable (
) with a coefficient lambda:
The latent variable is related to the covariates ():
and
are independent random variables with standard normal distribution.
Value
a data.frame
Examples
#### generate data in the wide format ####
set.seed(10)
dW <- sampleRem(100, n.times = 3, format = "wide")
head(dW)
#### generate data in the long format ####
set.seed(10)
dL <- sampleRem(100, n.times = 3, format = "long")
head(dL)