GrowthCurveDemo | R Documentation |
Artificial dataset to illustrate fitting of LMM trees with growth curve models in the terminal nodes.
data("GrowthCurveDemo")
A data frame containing 1250 repeated observations on 250 persons. x1 - x8 are time-invariant partitioning variables. Thus, they are measurements on the person (i.e., cluster) level, not on the individual observation level.
numeric. Indicator linking repeated measurements to persons.
factor. Indicator for timepoint.
numeric. Response variable.
numeric. Potential partitioning variable.
numeric. Potential partitioning variable.
numeric. Potential partitioning variable.
numeric. Potential partitioning variable.
numeric. Potential partitioning variable.
numeric. Potential partitioning variable.
numeric. Potential partitioning variable.
numeric. Potential partitioning variable.
Data were generated so that x1
, x2
and x3
are
true partitioning variables, x4
through x8
are noise
variables. The (potential) partitioning variables are time invariant.
Time-varying covariates can also be included in the model. For partitioning
growth curves these should probably not be potential partitioning variables,
as this could result in observations from the same person ending up in
different terminal nodes. Thus, time-varying covariates are probably
best included as predictors in the node-specific regression model. E.g.:
y ~ time + timevarying_cov | person | x1 + x2 + x3 + x4
.
Fokkema M & Zeileis A (2024). Subgroup detection in linear growth curve models with generalized linear mixed model (GLMM) trees. Behavior Research Methods. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3758/s13428-024-02389-1")}
lmertree
, glmertree
data("GrowthCurveDemo", package = "glmertree")
head(GrowthCurveDemo)
## Fit LMM tree with a random intercept w.r.t. person:
form <- y ~ time | person | x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8
lt.default <- lmertree(form, data = GrowthCurveDemo)
plot(lt.default, which = "tree") ## yields too large tree
VarCorr(lt.default)
## Account for measurement level of the partitioning variables:
lt.cluster <- lmertree(form, cluster = person, data = GrowthCurveDemo)
plot(lt.cluster, which = "tree") ## yields correct tree
plot(lt.cluster, which = "growth") ## plot individual growth curves not datapoints
coef(lt.cluster) ## node-specific fixed effects
VarCorr(lt.cluster) ## with smaller trees random effects explain more variance
## Fit LMM tree with random intercept and random slope of time w.r.t. person:
form.s <- y ~ time | (1 + time | person) | x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8
lt.s.cluster <- lmertree(form.s, cluster = person, data = GrowthCurveDemo)
plot(lt.s.cluster, which = "tree") ## same tree as before
coef(lt.cluster)
VarCorr(lt.s.cluster)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.