make_formulas: Process formulas and store in nested list

View source: R/make_formulas.R

make_formulasR Documentation

Process formulas and store in nested list

Description

Process formulas and store in nested list

Usage

make_formulas(input_forms, var_names, par_names, n_states)

Arguments

input_forms

Nested list of formulas, with two levels: observed variable, and parameter of the observation distribution. The formulas can contain state-specific terms, e.g. "~ state1(x1) + x2".

var_names

character vector name of each observation variable

par_names

list with element for each observation variable that contains character vector of name of each parameter in its distribution

n_states

Number of states

Details

Formulas for the observation parameters can be different for the different states, using special functions of the form "state1", "state2", etc. This method processes the list of formulas passed by the user to extract the state-specific formulas. Missing formulas are assumed to be intercept-only ~1.

Value

Nested list of formulas, with three levels: observed variable, parameter of the observation distribution, and state.

Examples

input_forms <- list(step = list(shape = ~ state1(x1) + x2,
                                scale = ~ x1),
                    count = list(lambda = ~ state1(x1) + state2(s(x2, bs = "cs"))))

make_formulas(input_forms = input_forms, 
              var_names = names(input_forms), 
              par_names = lapply(input_forms, names), 
              n_states = 2)
              

TheoMichelot/hmmTMB documentation built on Dec. 13, 2024, 11:52 a.m.