WeMix (version 2.2.1)

calc_lin_lnl_quad_fast: This function calcuates the liklihood of the model using integration by adaptive quadrature

Description

calculates the log-likelihood of an l level mixed model using adaptive quadrature. the genral model is y = Xb + ZU + e but that values of beta and U are not included in the call. Instead this information is contained in yhat which incorporates Xb at the top level and all relevant Zu information at lower levels.

Usage

calc_lin_lnl_quad_fast(y, yhat, level, Z, Qi, omega, W, C, qp, omegaFull,
  QiFull, ZFull, top = TRUE, atPoint = FALSE,
  integralMultiplierExponent = 0L, integralZColumn = 1L,
  verbose = TRUE, acc = 120L)

Arguments

y

a numeric vector, the response.

yhat

the current predicted values of the response

level

an integer that respresents the number of levels in the likelihood that is desired. In a two level model this function will be called with l=2 and it will recurse and call itself with l=1

Z

a list of the Z matricies where the index of Z indicates the level. of the Z matri. Z[[1]] is NULL because there is no individual lavel Zs.

Qi

the scaling factor for the adaptive quadratures (per group)

omega

a list of the b estimates for ech group

W

list of weight matricies. must have `w` and `index` columns

C

a list of Cholesky decompositions of the Sigma matricies. C[[1]] is simply the residual variance (a scalar) while C[[l]] for l > 1 is a matrix with the name number of rows and columns as the Z matrix for that level.

qp

Gaussian quadrature result from statmod::gauss.quad.

omegaFull

numeric, the b estimates for each group duplicated so each element has one row per observation (like Zfull)

QiFull

the scaling factors for adaptive quarature points duplicated so each element has one row per observation (like Zfull)

ZFull

Z expended such that each Z[[i]] matrix contains one row for each observation (ie each element has same number of rows as original data)

top

boolean set to TRUE to return a single scalar, otherwise returns a vector

atPoint

boolean, indicates likelihood should be calculated at single point at the top level and then integrated below that. This is useful for finding the maximum posterior (or likelihood) extimate for the random effects

integralMultiplierExponent

a single integer, the function evaluates the integral times the randome effect to this power when set to 0, it is just the log-likelhood when set to 1, this can be used to estimate the expected value.

integralZColumn

is the column index of Z to use integralMultiplierExponent on only one random effect at a time can be integrated over, and the integration happens at the top level.

verbose

boolean set to TRUE to get verbose output

acc

numeric, accuracy of the mpfr