mlrcs: Fit multi-level restricted cubic spline model

Description Usage Arguments Value Examples

View source: R/mlrcs.R

Description

Fit multi-level restricted cubic spline model

Usage

1
mlrcs(formula, random = NULL, data, ...)

Arguments

formula

A model formula for the fixed-effects in the model. Must include one restricted cubic spline term, specified as rcs(variable, df = #).

random

A formula for the random-effects in the model. Random-effects should be specified as a one-sided formula, e.g. ~ 1 + trt | id for random effect on the intercept and treatment at the id level. Random-effects can be estimated at any number of nested random-effect levels by providing a list of one-sided formulas. When specifying random-effect at multiple levels. The one-sided formula should be given in order, starting with the highest level. Only required when rcs = TRUE.

data

A data frame containing all variables required for fitting the model.

...

Further arguments passed to merlin.

Value

An object of class mlrcs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
# Two-level model
data("pbc.merlin", package = "merlin")
fit <- mlrcs(formula = logp ~ 1 + rcs(year, df = 4) + age + trt,
             random  = ~ 1 + trt | id,
             data = pbc.merlin
)
summary(fit)

# Three-level model
fit <- mlrcs(formula = logp ~ 1 + rcs(year, df = 4) + age + trt,
             random  = list(~ 1 | region,
                            ~ 1 + trt | id),
             data = pbc.merlin
)
summary(fit)

## End(Not run)

merlin documentation built on July 8, 2020, 7:31 p.m.