Skip to contents

The density objects set_prior() takes as its prior argument, the same densities its strings parse into: set_prior(prior_normal(0, 5), class = "b") is set_prior("normal(0, 5)", class = "b"). A density is put on a parameter only through set_prior()'s classes, which are brms's, so each parameter has one prior slot. The named list of these objects that frm(prior = ) took until this release, keyed by internal parameter names, was a second slot on the same parameters, and is refused.

Usage

prior_normal(location = 0, scale = 1)

prior_t(df = 3, location = 0, scale = 1)

prior_logistic(location = 0, scale = 1)

prior_gamma(shape = 1, rate = 1)

prior_inv_gamma(shape = 1, scale = 1)

prior_beta(shape1 = 1, shape2 = 1)

prior_lkj(eta = 1)

prior_dirichlet(alpha = 1)

Arguments

location, scale, df

Prior parameters. scale is also the second argument of prior_inv_gamma(), brms's inv_gamma(shape, scale).

shape, rate

Gamma prior parameters, brms's spelling (gamma(shape, rate)), both positive. The density has support on the positive line, so it belongs to a quantity that lives there: a brms shape, phi, nu or kappa row, which arrives on the parameter's own scale.

shape1, shape2

Beta prior parameters, both positive. The density has support on (0, 1), so it belongs to a quantity that lives there: brms's default on a zero-inflation zi or a hurdle hu, which reach it through their logit link.

eta

LKJ shape. 1 is uniform over correlation matrices, larger values concentrate toward the identity, and 0 < eta < 1 pushes toward the boundary.

alpha

Dirichlet concentrations, positive: one number for every weight of the simplex, or one per weight. brms's dirichlet(alpha), the density of a mo() simplex (class "simo"); alpha = 1 is uniform on the simplex.

Value

A frmtmb_prior object.

See also

set_prior(), which puts these densities on parameters.

Examples

# the objects themselves are cheap descriptions
prior_normal(0, 2)
#> $kind
#> [1] "normal"
#> 
#> $location
#> [1] 0
#> 
#> $scale
#> [1] 2
#> 
#> attr(,"class")
#> [1] "frmtmb_prior"
prior_t(df = 3, location = 0, scale = 1)
#> $kind
#> [1] "t"
#> 
#> $df
#> [1] 3
#> 
#> $location
#> [1] 0
#> 
#> $scale
#> [1] 1
#> 
#> attr(,"class")
#> [1] "frmtmb_prior"

set.seed(9)
dd <- data.frame(x = rnorm(80), g = factor(rep(1:8, 10)))
dd$y <- rnorm(80, 1 + 0.5 * dd$x + rnorm(8, 0, 0.5)[dd$g], 1)

# a density object in place of the string, on brms's classes
fit <- frm(bf(y ~ x + (1 | g)) + gaussian(), data = dd,
           prior = set_prior(prior_normal(0, 5), class = "b") +
             set_prior(prior_t(3, 0, 1), class = "sd"))
prior_summary(fit)
#>               prior class coef group resp dpar nlpar   lb   ub source
#>        normal(0, 5)     b                            <NA> <NA>   user
#>  student_t(3, 0, 1)    sd                            <NA> <NA>   user