Package 'longRPart2'

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

Help Index


A dataset used as an example for longRPart2

Description

A dataset used as an example for longRPart2

Usage

ex.data.3

Format

A data frame with 600 rows and 4 variables:

id

id number

z

covariate

time

time variable

y

outcome

...


Longitudinal data with groups

Description

A saved image with rp object

Usage

lcart.mod1

Format

An object of class "lrp"


Trying to suppress notes from lrp2Plot

Description

Trying to suppress notes from lrp2Plot


Longitudinal Recursive Partitioning

Description

Longitudinal Recursive Partitioning

Usage

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()
)

Arguments

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()

Examples

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

Description

Longitudinal Recursive Partitioning Plotting Function

Usage

lrp2Plot(model, smooth_method = "loess")

Arguments

model

A longrpart2 model.

smooth_method

Whether to use generalized additive models, smooth_method="gam", or loess, smooth_method="loess". Defaults to loess.

Examples

library(longRPart2)

Plot Expected Trajectories

Description

Plot Expected Trajectories

Usage

lrpPlot(model, smoothing = "n", color = NULL, place = "bottomright")

Arguments

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

Description

Plot function for longRPart2

Usage

## S3 method for class 'lrp'
plot(x, box.palette = "auto", ...)

Arguments

x

A model from lrp.

box.palette

Color scheme for rpart.plot

...

Other arguments.


Summary results from lrp.

Description

Summary results from lrp.

Usage

## S3 method for class 'lrp'
summary(object, ...)

Arguments

object

An object from lrp.

...

Other arguments.