make_stancode: Stan Code for PStrata Models

View source: R/make_stancode.R

make_stancodeR Documentation

Stan Code for PStrata Models

Description

Generate the Stan code corresponding to the model. This is called internally by fit; use stancode.PStrataFit to retrieve the code from a fitted model.

Usage

make_stancode(object, filename = NULL, debug = FALSE)

Arguments

object

An internal model specification object.

filename

(optional) string. If not NULL, the Stan file is saved to this path.

debug

only for development/testing use.

Value

A string containing the Stan program.

Examples


data(sim_data_normal)
model <- PStrataModel(
  S.formula = Z + D ~ 1,
  Y.formula = Y ~ 1,
  Y.family  = gaussian(),
  strata    = c(n = "00", c = "01", a = "11"),
  ER        = c("n", "a")
)
ps_fit <- fit(model, data = sim_data_normal, chains = 2, iter = 500)
cat(stancode(ps_fit))



PStrata documentation built on May 14, 2026, 5:06 p.m.