modify_stancode: Modify stan code generated by 'brms' to fit a CAR(1) model

View source: R/modify_stancode.R

modify_stancodeR Documentation

Modify stan code generated by brms to fit a CAR(1) model

Description

N.B., modify_stancode(method = "car1") resets the lower bound on the ar parameter to zero. It is compatible with priors such as normal() (check to make sure it makes the expected modifications before using).

Usage

modify_stancode(
  scode_raw,
  modify = "car1",
  var_xcens = NULL,
  var_car1 = NULL,
  lower_bound = NULL,
  lcl = NULL
)

Arguments

scode_raw

Stan code generated by brms::make_stancode().

modify

Specify which modification to make. The default (and currently the only option) is "car1", which creates the CAR(1) error term.

var_xcens

For multivariate models, specify the names of censored predictor variables as a character vector.

var_car1

For multivariate models, specify which variable to generate CAR(1) errors for.

lower_bound

An optional lower bound for left-censored parameters. The default is no lower bound.

lcl

A numeric vector of censoring limits for left-censored variables. Alternatively, a list of numeric vectors with censoring limits for each variable and observation; the order should correspond to that of lcl and cens_ind.

Value

A Stan program of class brmsmodel.

Examples

library("brms")
data <- read.csv(paste0(system.file("extdata", package = "bgamcar1"), "/data_car1.csv"))
scode <- make_stancode(bf(y ~ ar(time = x)), data)
modify_stancode(scode)

bentrueman/bgamcar1 documentation built on July 6, 2024, 11:16 p.m.