DataLongGenerator: Longitudinal data generator

Description Usage Arguments Value Examples

View source: R/LongituRF.R

Description

Simulate longitudinal data according to the semi-parametric stochastic mixed-effects model given by:

Y_i(t)=f(X_i(t))+Z_i(t)β_i + ω_i(t)+ε_i

with Y_i(t) the output at time t for the ith individual; X_i(t) the input predictors (fixed effects) at time t for the ith individual; Z_i(t) are the random effects at time t for the ith individual; ω_i(t) is a Brownian motion with volatility γ^2=0.8 at time t for the ith individual; ε_i is the residual error with variance σ^2=0.5. The data are simulated according to the simulations in low dimensional in the low dimensional scheme of the paper <doi:10.1177/0962280220946080>

Usage

1
DataLongGenerator(n = 50, p = 6, G = 6)

Arguments

n

[numeric]: Number of individuals. The default value is n=50.

p

[numeric]: Number of predictors. The default value is p=6.

G

[numeric]: Number of groups of predictors with temporal behavior, generates p-G input variables with no temporal behavior.

Value

a list of the following elements:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
oldpar <- par()
oldopt <- options()
data <- DataLongGenerator(n=17, p=6,G=6) # Generate the data
# Let's see the output :
w <- which(data$id==1)
plot(data$time[w],data$Y[w],type="l",ylim=c(min(data$Y),max(data$Y)), col="grey")
for (i in unique(data$id)){
  w <- which(data$id==i)
  lines(data$time[w],data$Y[w], col='grey')
}
# Let's see the fixed effects predictors:
par(mfrow=c(2,3), mar=c(2,3,3,2))
for (i in 1:ncol(data$X)){
  w <- which(data$id==1)
  plot(data$time[w],data$X[w,i], col="grey",ylim=c(min(data$X[,i]),
  max(data$X[,i])),xlim=c(1,max(data$time)),main=latex2exp::TeX(paste0("$X^{(",i,")}$")))
  for (k in unique(data$id)){
    w <- which(data$id==k)
    lines(data$time[w],data$X[w,i], col="grey")
  }
}
par(oldpar)
options(oldopt)

LongituRF documentation built on Aug. 31, 2020, 5:07 p.m.