Compute the marginal likelihood of a GLLAMM or GALAMM
Source:R/marginal_likelihood.R
marginal_likelihood.RdThis 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
numericvector of responses.- trials
A
numericvector representing the number of trials. Only used for binomial models, but should be set to some arbitrary value otherwise.- X
A dense
numericmatrix.- Zt
A sparse matrix of class
dgCMatrix.- Lambdat
A sparse matrix of class
dgCMatrix.- beta
A
numericvector of fixed effects.- theta
A
numericvector of variance components, parametrized identically tolme4.- theta_mapping
An
integervector corresponding toLindused bylme4, but with base zero indexing.- u_init
Initial values from random effects. Defaults to a vector of zeros.
- lambda
A
numericvector of factor loadings.- lambda_mapping_X
An
integervector of mappings betweenXandlambda, columnwise. Should be set tointeger()if not used. An entry-1indicates that the corresponding value ofXdoes not depend onlambda, as in the case where the first element oflambdais fixed to 1.- lambda_mapping_X_covs
Optional list of covariates.
- lambda_mapping_Zt
An
integervector of mappings betweenZtandlambda, along the nonzero elements ofZtas can be found byZt@x. Should be set tointeger()if not used. An entry-1indicates that the corresponding value ofXdoes not depend onlambda, as in the case where the first element oflambdais fixed to 1.- lambda_mapping_Zt_covs
Optional list of covariates.
- weights
Vector of weights.
- weights_mapping
Mapping
- family
A length one
characterdenoting 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.