Skip to contents

Specify a prior distribution for an intercept, a main effect, or an interaction.

Usage

set_prior(mod, formula)

Arguments

mod

A bage_mod object, created with mod_pois(), mod_binom(), or mod_norm().

formula

A formula giving the term and a function for creating a prior.

Value

A modified bage_mod object.

Details

If set_prior() is applied to a fitted model, it 'unfits' the model, deleting existing estimates.

See also

Examples

mod <- mod_pois(injuries ~ age + year,
                data = injuries,
                exposure = popn)
mod
#> -- Unfitted Poisson model --
#> 
#>    injuries ~ age + year
#> 
#> (Intercept) ~ NFix()
#>         age ~ RW()
#>        year ~ RW()
#> 
#>  term n_par n_par_free
#>   age    12         12
#>  year    19         19
#> 
#>      dispersion: mean=1
#>        exposure: popn
#>         var_age: age
#>        var_time: year
#>          n_draw: 1000
mod |> set_prior(age ~ RW2())
#> -- Unfitted Poisson model --
#> 
#>    injuries ~ age + year
#> 
#> (Intercept) ~ NFix()
#>         age ~ RW2()
#>        year ~ RW()
#> 
#>  term n_par n_par_free
#>   age    12         12
#>  year    19         19
#> 
#>      dispersion: mean=1
#>        exposure: popn
#>         var_age: age
#>        var_time: year
#>          n_draw: 1000