update.brmcoda: Update 'brmcoda' models

View source: R/update.R

update.brmcodaR Documentation

Update brmcoda models

Description

This method allows for updating an existing brmcoda object.

Usage

## S3 method for class 'brmcoda'
update(object, formula. = NULL, newdata = NULL, newcomplr = NULL, ...)

Arguments

object

A fitted brmcoda object to be updated.

formula.

Changes to the formula; for details see update.formula and brmsformula.

newdata

A data.frame or data.table containing data of all variables used in the analysis. It must include a composition and the same ID variable as the existing complr object.

newcomplr

A complr object containing data of composition, ILR coordinates, and other variables used in the updated model.

...

Further arguments passed to brm.

Value

A brmcoda with two elements

complr

An object of class complr used in the brm model.

model

An object of class brmsfit, which contains the posterior draws along with many other useful information about the model.

See Also

brmcoda

Examples


if(requireNamespace("cmdstanr")){

# model with compositional predictor at between and within-person levels
fit <- brmcoda(complr = complr(data = mcompd, sbp = sbp, 
                               parts = c("TST", "WAKE", "MVPA", "LPA", "SB"), 
                               idvar = "ID"), 
              formula = Stress ~ bilr1 + bilr2 + bilr3 + bilr4 +
                                 wilr1 + wilr2 + wilr3 + wilr4 + (1 | ID), 
              chain = 1, iter = 500,
              backend = "cmdstanr")

# removing the effect of wilr1
fit1 <- update(fit, formula. = ~ . - wilr1)

# using only a subset
fit2 <- update(fit, newdata = mcompd[ID != 1])
}

florale/multilevelcoda documentation built on April 21, 2024, 9:44 a.m.