mlrcs {merlin}R Documentation

Fit multi-level restricted cubic spline model

Description

Fit multi-level restricted cubic spline model

Usage

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

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



[Package merlin version 0.1.0 Index]