
Extract dimension from parameters in STAN parameter block
Source:R/helpers-model.R
extract_parameter_dimensions.RdThis functions extracts the names, dimensions, and types from a compiled STAN parameters blocks generated by bmm or brms. This function is used to specify initial values for bmm models.
Value
A list of all parameters, their types, and dimensions as as specified in
the STAN data generated by bmm and brms. A declaration whose type this
function does not model is returned with its name and NA for its type and
dimensions, so that only that parameter is left without initial values
Examples
# generate simple stan code from brms
stan_code <- stancode(brms::bf(x ~ 1 + cond + (1 + cond | ID)),
data = data.frame(
x = rnorm(100),
ID = rep(1:50, each = 2),
cond = rep(1:2, times = 50)
)
)
extracted_program_blocks <- extract_stan_blocks(stan_code)
par_dims <- extract_parameter_dimensions(extracted_program_blocks$parameters) #'