longDat {statVisual} | R Documentation |
A Simulated Dataset for Longitudinal Data Analysis
Description
A simulated dataset for longitudinal data analysis.
Usage
data("longDat")
Format
A data frame with 540 observations on the following 4 variables.
sid
subject id
time
time points. A factor with levels
time1
time2
time3
time4
time5
time6
y
numeric. outcome variable
grp
subject group. A factor with levels
grp1
grp2
grp3
Details
The dataset is generated from the following mixed effects model for repeated measures:
where is the outcome value for the
-th subject
measured at
-th time point
,
is a dummy variable indicating if the
-th subject
is from group 2,
is a dummy variable indicating if the
-th subject
is from group 3,
,
,
,
is the number of subjects, and
is the number of time points.
When , the expected outcome value is
Hence, we have at baseline
For dose 1 group, the expected outcome values across time is
We also can get the expected difference of outcome values between dose 2 group and dose 1 group, between dose 3 group and dose 1 group, and between dose 3 group and dose 2 group:
E\left(y_{ij} - y_{i'j}\right) =\beta_2+\beta_4 t_{j},\;\mbox{for subject $i$ in dose 2 group and subject $i'$ in dose 1 group},
E\left(y_{kj} - y_{i'j}\right) =\beta_3+\beta_5 t_{j},\;\mbox{for subject $k$ in dose 3 group and subject $i'$ in dose 1 group},
E\left(y_{kj} - y_{ij}\right) =\left(\beta_3-\beta_2\right)+\left(\beta_5-\beta_4\right) t_{j},\;\mbox{for subject $i$ in dose 3 group and subject $i$ in dose 2 group}.
We set ,
,
,
,
,
,
,
,
,
,
and
.
That is, the trajectories for dose 1 group are horizontal with mean intercept at , the trajectories for dose 2 group are linearly increasing with slope
and mean intercept
, and the trajectories for dose 3 group are linearly decreasing with slope
and mean intercept
.
Examples
data(longDat)
print(dim(longDat))
print(longDat[1:3,])
print(table(longDat$time, useNA = "ifany"))
print(table(longDat$grp, useNA = "ifany"))
print(table(longDat$sid, useNA = "ifany"))
print(table(longDat$time, longDat$grp))