Format formula data for use with stan
Arguments
- formula
The output of
enw_formula()
.- prefix
A character string indicating variable label to use as a prefix.
- drop_intercept
Logical, defaults to
FALSE
. Should the intercept be included as a fixed effect or excluded. This is used internally in model modules where an intercept must be present/absent.
Value
A list defining the model formula. This includes:
prefix_fintercept:
Is an intercept present for the fixed effects design matrix.prefix_fdesign
: The fixed effects design matrixprefix_fnrow
: The number of rows of the fixed design matrixprefix_findex
: The index linking design matrix rows to observationsprefix_fnindex
: The length of the indexprefix_fncol
: The number of columns (i.e effects) in the fixed effect design matrix (minus 1 if an intercept is present).prefix_rdesign
: The random effects design matrixprefix_rncol
: The number of columns (i.e random effects) in the random effect design matrix (minus 1 as the intercept is dropped).
See also
Functions used to help convert models into the format required for stan
enw_get_cache()
,
enw_model()
,
enw_pathfinder()
,
enw_priors_as_data_list()
,
enw_replace_priors()
,
enw_sample()
,
enw_set_cache()
,
enw_stan_to_r()
,
enw_unset_cache()
,
remove_profiling()
,
write_stan_files_no_profile()
Examples
f <- enw_formula(~ 1 + (1 | cyl), mtcars)
enw_formula_as_data_list(f, "mtcars")
#> $mtcars_fintercept
#> [1] 1
#>
#> $mtcars_fnrow
#> [1] 3
#>
#> $mtcars_findex
#> [1] 1 1 2 1 3 1 3 2 2 1 1 3 3 3 3 3 3 2 2 2 2 3 3 3 3 2 2 2 3 1 3 2
#>
#> $mtcars_fnindex
#> [1] 32
#>
#> $mtcars_fncol
#> [1] 3
#>
#> $mtcars_rncol
#> [1] 1
#>
#> $mtcars_fdesign
#> cyl4 cyl6 cyl8
#> 1 0 1 0
#> 3 1 0 0
#> 5 0 0 1
#>
#> $mtcars_rdesign
#> fixed cyl
#> 1 0 1
#> 2 0 1
#> 3 0 1
#> attr(,"assign")
#> [1] 1 2
#>
# A missing formula produces the default list
enw_formula_as_data_list(prefix = "missing")
#> $missing_fintercept
#> [1] 0
#>
#> $missing_fnrow
#> [1] 0
#>
#> $missing_findex
#> numeric(0)
#>
#> $missing_fnindex
#> [1] 0
#>
#> $missing_fncol
#> [1] 0
#>
#> $missing_rncol
#> [1] 0
#>
#> $missing_fdesign
#> numeric(0)
#>
#> $missing_rdesign
#> numeric(0)
#>