Skip to contents

This function uses a series internal functions to break an input formula into its component parts each of which can then be handled separately. Currently supported components are fixed effects, lme4 style random effects, and random walks using the rw() helper function.

Usage

parse_formula(formula)

Arguments

formula

A model formula that may use standard fixed effects, random effects using lme4 syntax (see re()), and random walks defined using the rw() helper function.

Value

A list of formula components. These currently include:

  • fixed: A character vector of fixed effect terms

  • random: A list of of lme4 style random effects

  • rw: A character vector of rw() random walk terms.

Reference

The random walk functions used internally by this function were adapted from code written by J Scott (under an MIT license) as part of the epidemia package (https://github.com/ImperialCollegeLondon/epidemia/).

See also

Functions used to help convert formulas into model designs as_string_formula(), construct_re(), construct_rw(), enw_formula(), enw_manual_formula(), remove_rw_terms(), re(), rw_terms(), rw(), split_formula_to_terms()

Examples

epinowcast:::parse_formula(~ 1 + age_group + location)
#> $fixed
#> [1] "1"         "age_group" "location" 
#> 
#> $random
#> NULL
#> 
#> $rw
#> character(0)
#> 

epinowcast:::parse_formula(~ 1 + age_group + (1 | location))
#> $fixed
#> [1] "1"         "age_group"
#> 
#> $random
#> $random[[1]]
#> 1 | location
#> 
#> 
#> $rw
#> character(0)
#> 

epinowcast:::parse_formula(~ 1 + (age_group | location))
#> $fixed
#> [1] "1"
#> 
#> $random
#> $random[[1]]
#> age_group | location
#> 
#> 
#> $rw
#> character(0)
#> 

epinowcast:::parse_formula(~ 1 + (1 | location) + rw(week, location))
#> $fixed
#> [1] "1"
#> 
#> $random
#> $random[[1]]
#> 1 | location
#> 
#> 
#> $rw
#> [1] "rw(week, location)"
#>