modify_standata: Modify Stan data to include left-censoring limits on...

View source: R/modify_standata.R

modify_standataR Documentation

Modify Stan data to include left-censoring limits on predictor variables.

Description

Modify Stan data to include left-censoring limits on predictor variables.

Usage

modify_standata(sdata, data, lcl, var_xcens, cens_ind)

Arguments

sdata

A list generated by brms::make_standata()

data

A dataframe containing the model variables.

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.

var_xcens

A character vector containing the names of predictor variables with left-censoring; the order should correspond to that of lcl and cens_ind.

cens_ind

A character vector containing the names of left-censoring indicators variables corresponding to the contents of var_xcens.

Value

A list that can be passed to rstan::stan() or cmdstanr::cmdstan_model.

Examples

library("brms")
data <- read.csv(paste0(system.file("extdata", package = "bgamcar1"), "/data_gam.csv"))
data$f_cens <- ifelse(data$f < 5, "left", "none")
sdata <- make_standata(bf(y ~ f), data)
sdata_modified <- modify_standata(sdata, data, lcl = 5, var_xcens = "f", cens_ind = "f_cens")
str(sdata_modified)

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