Skip to contents

This function extracts the code from the different program blocks of a STAN program. This can be used in combination with the stancode function to access information about the STAN code generated by brms and bmm.

Usage

extract_stan_blocks(
  stan_code,
  blocks = c("functions", "data", "transformed data", "parameters",
    "transformed parameters", "model", "generated quantities")
)

Arguments

stan_code

The STAN code for which the elements should be extracted

blocks

A character vector specifying for which program blocks the code should be extracted. The default extracks all standard blocks: "functions", "data", "transformed data", "parameters", "transformed parameters", "model", and "generated quantities"

Value

A named list with each element containing the code of one of the STAN program blocks. If a block

Examples

# generate simple stan code from brms
stan_code <- stancode(brms::bf(x ~ 1), data = data.frame(x = rnorm(100)))

extracted_program_blocks <- extract_stan_blocks(stan_code)