update.RprobitB_fit: Update and refit a choice model

View source: R/model.R

update.RprobitB_fitR Documentation

Update and refit a choice model

Description

Refits a choice model with a modified specification.

Usage

## S3 method for class 'RprobitB_fit'
update(object, formula., ..., evaluate = TRUE)

Arguments

object

[RprobitB_fit]
Fitted choice model.

formula.

[formula]
Changes to the model formula, see the details.

...

Arguments of fit() that replace the ones of object.

evaluate

[logical(1)]
Refit the model? If FALSE, the updated call is returned, where data stands for the choice data of object.

Details

Arguments that are not specified are taken from object.

The model formula is updated part by part, so . ~ . + income extends the covariates that are constant across alternatives and leaves the other two formula parts unchanged.

The choice data of object are reused, also if they were simulated, which makes the updated model comparable to object. Supply data to fit the updated model to other choice data.

Value

An object of class RprobitB_fit, or the updated call if evaluate is FALSE.

Examples

### simulate choice data and fit a model with two covariates
set.seed(1)
model <- fit(
  choice ~ x + y | 0, dgp_parameters = list(beta = c(x = 1, y = -0.5)),
  chains = 1
)
summary(model)

### drop `y` from the formula, the other formula parts stay as they are
model_2 <- update(model, . ~ . - y)
summary(model_2)

### let the coefficient of `x` vary across deciders instead
model_3 <- update(model, random_effects = "x")
summary(model_3)

RprobitB documentation built on Sept. 20, 2026, 9:07 a.m.