egg_model: Fit a cubic splines mixed model.

View source: R/egg_model.R

egg_modelR Documentation

Fit a cubic splines mixed model.

Description

Fit a cubic splines mixed model regression with three splines parametrisation as random effect. This function is a specific version of time_model().

Usage

egg_model(
  formula,
  data,
  id_var,
  random_complexity = "auto",
  use_car1 = FALSE,
  knots = c(1, 8, 12),
  quiet = FALSE
)

Arguments

formula

An object of class "formula": a symbolic description of the model to be fitted with, time component as the first term in the right-hand side.

data

A data.frame containing the variables defined in formula.

id_var

A string indicating the name of the variable to be used as the individual identifier.

random_complexity

A numeric (1-3) indicating the complexity of the random effect term. Default, "auto" will try from the more complex to the less complex if no success.

use_car1

A logical indicating whether to use continuous auto-correlation, i.e., CAR(1) as correlation structure.

knots

The knots defining the splines.

quiet

A logical indicating whether to suppress the output.

Value

An object of class "lme" representing the linear mixed-effects model fit.

Examples

data("bmigrowth")
res <- egg_model(
  formula = log(bmi) ~ age,
  data = bmigrowth[bmigrowth[["sex"]] == 0, ],
  id_var = "ID",
  random_complexity = 1
)
sres <- as.data.frame(summary(res)[["tTable"]])
rownames(sres) <- sub("gsp\\(.*\\)\\)", "gsp(...)", rownames(sres))
sres

mcanouil/eggla documentation built on April 5, 2025, 3:06 a.m.