sampleRem | R Documentation |
Sample longuitudinal data with covariates
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 )
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? |
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.
a data.frame
set.seed(10) dW <- sampleRem(100, n.times = 3, format = "wide") set.seed(10) dL <- sampleRem(100, n.times = 3, format = "long")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.