Compute the marginal likelihood of a GLLAMM or GALAMM
Source:R/marginal_likelihood.R
marginal_likelihood.Rd
This function computes the Laplace approximate marginal likelihood.
Usage
marginal_likelihood(
y,
trials = NULL,
X,
Zt,
Lambdat,
beta,
theta,
theta_mapping,
u_init = rep(0, nrow(Zt)),
lambda = numeric(),
lambda_mapping_X = integer(),
lambda_mapping_X_covs = integer(),
lambda_mapping_Zt = integer(),
lambda_mapping_Zt_covs = integer(),
weights = numeric(),
weights_mapping = integer(),
family = "gaussian",
family_mapping = rep(0L, length(y)),
maxit_conditional_modes = 1L,
gradient = TRUE,
hessian = FALSE,
epsilon_u = 1e-10
)
Arguments
- y
A
numeric
vector of responses.- trials
A
numeric
vector representing the number of trials. Only used for binomial models, but should be set to some arbitrary value otherwise.- X
A dense
numeric
matrix.- Zt
A sparse matrix of class
dgCMatrix
.- Lambdat
A sparse matrix of class
dgCMatrix
.- beta
A
numeric
vector of fixed effects.- theta
A
numeric
vector of variance components, parametrized identically tolme4
.- theta_mapping
An
integer
vector corresponding toLind
used bylme4
, but with base zero indexing.- u_init
Initial values from random effects. Defaults to a vector of zeros.
- lambda
A
numeric
vector of factor loadings.- lambda_mapping_X
An
integer
vector of mappings betweenX
andlambda
, columnwise. Should be set tointeger()
if not used. An entry-1
indicates that the corresponding value ofX
does not depend onlambda
, as in the case where the first element oflambda
is fixed to 1.- lambda_mapping_X_covs
Optional list of covariates.
- lambda_mapping_Zt
An
integer
vector of mappings betweenZt
andlambda
, along the nonzero elements ofZt
as can be found byZt@x
. Should be set tointeger()
if not used. An entry-1
indicates that the corresponding value ofX
does not depend onlambda
, as in the case where the first element oflambda
is fixed to 1.- lambda_mapping_Zt_covs
Optional list of covariates.
- weights
Vector of weights.
- weights_mapping
Mapping
- family
A length one
character
denoting the family.- family_mapping
Mapping
- maxit_conditional_modes
Maximum number of iterations for conditional models. Can be 1 when
family = "gaussian"
.- gradient
Boolean specifying whether to including the gradient at the given parameters. Defaults to
TRUE
.- hessian
Boolean specifying whether to include the Hessian matrix at the given parameters. Defaults to
FALSE
.- epsilon_u
Tolerance in the inner iteration. Defaults to
1e-10
.