# penmlogl: Penalized Minus Log Likelihood for Aster Models In aster: Aster Models

## Description

Penalized minus log likelihood for an aster model, and its first and second derivative. The penalization allows for (approximate) random effects. These functions are called inside `pickle`, `pickle1`, `pickle2`, `pickle3`, and `reaster`.

## Usage

 ```1 2``` ```penmlogl(parm, sigma, fixed, random, obj, y, origin, deriv = 2) penmlogl2(parm, alpha, sigma, fixed, random, obj, y, origin) ```

## Arguments

 `parm` for `penmlogl`, parameter value (vector of regression coefficients and rescaled random effects) at which we evaluate the penalized log likelihood. For `penmlogl2` the vector of rescaled random effects only (see next item). `alpha` the vector of fixed effects. For `penmlogl2`, the concatenation `c(alpha, parm)` is the same as `parm` that is supplied to `pemnmlogl`. `sigma` vector of square roots of variance components, one component for each group of random effects. `fixed` the model matrix for fixed effects. The number of rows is `nrow(obj\$data)`. The number of columns is the number of fixed effects. `random` the model matrix or matrices for random effects. Each has the same number of rows as `fixed`. The number of columns is the number of random effects in a group. Either a matrix or a list of matrices. `obj` aster model object, the result of a call to `aster`. `y` response vector. May be omitted, in which case `obj\$x` is used. If supplied, must be a matrix of the same dimensions as `obj\$x`. `origin` origin of aster model. May be omitted, in which case default origin (see `aster`) is used. If supplied, must be a matrix of the same dimensions `obj\$x`. `deriv` number of derivatives wanted. Allowed values are 0, 1, or 2.

## Details

Consider an aster model with random effects and canonical parameter vector of the form

M alpha + Z[1] b[1] + … + Z[k] b[k]

where M and each Z[j] are known matrices having the same row dimension, where alpha is a vector of unknown parameters (the fixed effects) and each b[j] is a vector of random effects that are supposed to be (marginally) independent and identically distributed mean-zero normal with variance `sigma[j]^2`.

These functions evaluate minus the “penalized log likelihood” for this model, which considers the random effects as parameters but adds a penalization term

b[1]^2 / (2 * sigma[1]^2) + … + b[k]^2 / (2 sigma[k]^2)

to minus the log likelihood.

To properly deal with random effects that are zero, random effects are rescaled by their standard deviation. The rescaled random effects are c[i] = b[i] / sigma[i]. If sigma[i] = 0, then the corresponding rescaled random effects c[i] are also zero.

## Value

a list containing some of the following components:

 `value` minus the penalized log likelihood. `gradient` minus the first derivative vector of the penalized log likelihood. `hessian` minus the second derivative matrix of the penalized log likelihood. `argument` the value of the `parm` argument for this function. `scale` the vector by which `parm` must be scaled to obtain the true random effects. `mlogl.gradient` gradient for evaluation of log likelihood; `gradient` is this plus gradient of penalty. `mlogl.hessian` hessian for evaluation of log likelihood; `hessian` is this plus hessian of penalty.

## Note

Not intended for use by naive users. Use `reaster`, which calls them.

For an example using this function see the example for `pickle`.