Title: | Recursive Partitioning of Longitudinal Data |
---|---|
Description: | Performs recursive partitioning of linear and nonlinear mixed effects models, specifically for longitudinal data. The package is an extension of the original 'longRPart' package by Stewart and Abdolell (2013) <https://cran.r-project.org/package=longRPart>. |
Authors: | Ross Jacobucci [aut,cre], Sam Stewart[aut], Mohamed Abdolell [aut], Sarfaraz Serang [ctb], Gabriela Stegmann [ctb] |
Maintainer: | Ross Jacobucci <[email protected]> |
License: | GPL |
Version: | 0.2.5 |
Built: | 2024-10-25 03:31:21 UTC |
Source: | https://github.com/rjacobucci/longrpart2 |
A dataset used as an example for longRPart2
ex.data.3
ex.data.3
A data frame with 600 rows and 4 variables:
id number
covariate
time variable
outcome
...
A saved image with rp object
lcart.mod1
lcart.mod1
An object of class "lrp"
Longitudinal Recursive Partitioning
lrp( method, nlme.model = NULL, randomFormula, fixedFormula = NULL, data, start, group, rPartFormula, weight = NULL, use_parallel = FALSE, R = NULL, min.dev = NULL, control = rpart.control() )
lrp( method, nlme.model = NULL, randomFormula, fixedFormula = NULL, data, start, group, rPartFormula, weight = NULL, use_parallel = FALSE, R = NULL, min.dev = NULL, control = rpart.control() )
method |
Whether to use lme() or nlme(). Use either method="lme" or method="nlme". This changes what additional arguments need to be passed. |
nlme.model |
Necessary to specify if method="nlme" |
randomFormula |
Random effects to include for nlme() or lme() |
fixedFormula |
Fixed effects to include for nlme() or lme() |
data |
Dataset |
start |
Starting values for nlme() |
group |
Grouping for nlme() |
rPartFormula |
Not sure yet |
weight |
Sample weights to be passed to rpart |
use_parallel |
Whether to parallelize the split models |
R |
Correlation matrix to use for nlme. this is correlation= |
min.dev |
The minimum decrease in deviance to choose a split. Note that this overrides the default cp criterion in rpart.control() |
control |
Control function to be passed to rpart() |
library(longRPart2) data(ex.data.3) model.0 = nlme(y~b0i+b1i*time, data=ex.data.3, fixed=b0i+b1i~1, random=b0i+b1i~1, group=~id, start=c(10,5)) lcart.mod1 <- lrp(method="nlme", nlme.model=y~b0i+b1i*time, fixedFormula=b0i+b1i~1, rPartFormula = ~ z, group= ~ id, randomFormula=b0i+b1i~1, data=ex.data.3, start=c(10,5)) data(lcart.mod1) summary(lcart.mod1) plot(lcart.mod1) # for smooth_method, "loess" is recommend but "gam" faster lrp2Plot(lcart.mod1,smooth_method="gam")
library(longRPart2) data(ex.data.3) model.0 = nlme(y~b0i+b1i*time, data=ex.data.3, fixed=b0i+b1i~1, random=b0i+b1i~1, group=~id, start=c(10,5)) lcart.mod1 <- lrp(method="nlme", nlme.model=y~b0i+b1i*time, fixedFormula=b0i+b1i~1, rPartFormula = ~ z, group= ~ id, randomFormula=b0i+b1i~1, data=ex.data.3, start=c(10,5)) data(lcart.mod1) summary(lcart.mod1) plot(lcart.mod1) # for smooth_method, "loess" is recommend but "gam" faster lrp2Plot(lcart.mod1,smooth_method="gam")
Longitudinal Recursive Partitioning Plotting Function
lrp2Plot(model, smooth_method = "loess")
lrp2Plot(model, smooth_method = "loess")
model |
A longrpart2 model. |
smooth_method |
Whether to use generalized additive models, smooth_method="gam", or loess, smooth_method="loess". Defaults to loess. |
library(longRPart2)
library(longRPart2)
Plot Expected Trajectories
lrpPlot(model, smoothing = "n", color = NULL, place = "bottomright")
lrpPlot(model, smoothing = "n", color = NULL, place = "bottomright")
model |
Model object from longRPart2() |
smoothing |
Type of smoothing for trajectoris |
color |
Color to use |
place |
Where to place the plot |
Plot function for longRPart2
## S3 method for class 'lrp' plot(x, box.palette = "auto", ...)
## S3 method for class 'lrp' plot(x, box.palette = "auto", ...)
x |
A model from lrp. |
box.palette |
Color scheme for rpart.plot |
... |
Other arguments. |
Summary results from lrp.
## S3 method for class 'lrp' summary(object, ...)
## S3 method for class 'lrp' summary(object, ...)
object |
An object from lrp. |
... |
Other arguments. |