Skip to contents

Builds a Laplace prior on parameters as an objective function.

Usage

constraintL1(mu, ...)

# Default S3 method
constraintL1(mu, sigma = 1, attrName = "prior", condition = NULL, ...)

Arguments

mu

Named numeric vector of prior locations. The names select the constrained parameters.

...

Passed to the method.

sigma

Numeric, scalar or named and aligned with mu, default 1. The Laplace scale, the reciprocal penalty strength.

attrName

Character. Name of the attribute holding the constraint value, default "prior".

condition

Character vector, the conditions of a sum of objectives in which the term is evaluated. NULL (default) evaluates it in every one.

Value

An objective function of class objfn, called as obj(pars, ...), see dModfn. The objective value is the full -2 log density, while constraintL2() returns the penalty form without the constant.

Details

Computes the Laplace prior on the -2 log scale, $$2\log(2\sigma) + 2|p-\mu|/\sigma,$$ the L1 counterpart of constraintL2(). At \(p = \mu\) the term is not differentiable and the gradient is returned as 0.

See also

Examples

prior <- constraintL1(mu = c(k1 = 0), sigma = 2)
prior(pars = c(k1 = 1))$value
#> [1] 3.772589