DataLongGenerator {LongituRF} | R Documentation |
Longitudinal data generator
Description
Simulate longitudinal data according to the semi-parametric stochastic mixed-effects model given by:
with the output at time
for the
th individual;
the input predictors (fixed effects) at time
for the
th individual;
are the random effects at time
for the
th individual;
is a Brownian motion with volatility
at time
for the
th individual;
is the residual error with
variance
.
The data are simulated according to the simulations in low dimensional in the low dimensional scheme of the paper <doi:10.1177/0962280220946080>
Usage
DataLongGenerator(n = 50, p = 6, G = 6)
Arguments
n |
[numeric]: Number of individuals. The default value is |
p |
[numeric]: Number of predictors. The default value is |
G |
[numeric]: Number of groups of predictors with temporal behavior, generates |
Value
a list of the following elements:
-
Y:
vector of the output trajectories. -
X :
matrix of the fixed-effects predictors. -
Z:
matrix of the random-effects predictors. -
id:
vector of the identifiers for each individual. -
time:
vector the the time measurements for each individual.
Examples
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)