Description Usage Arguments Details Value References Examples
Log-likelihood functions and related quantities for a logistic regression model with crossed random effects based on the Salamander
data. In particular, the function nlogH_salam
gives the joint likelihood for the fixed and random parameters, given the data, grad_salam
gives the gradient of nlogH_salam
with respect to the random effects and hess_salam
gives its Hessian matrix.
1 2 3 4 5 | nlogH_salam(randPar, fixPar, data)
grad_salam(randPar, fixPar, data)
hess_salam(randPar, fixPar, data)
|
randPar |
The vector of random effects. The first 20 elements are the random effects for femals and the second block of 20 elements are the random effects for males |
fixPar |
is the vector of fixed parameters made by the 4 regression coefficients and the 2 variance components |
data |
The data. It must be a named list with appropriate components. See Examples for more details. |
For each experiment, the model can be written as
Y_ij \sim Bernoulli(p_ij),
logit(p_i) = x_ij^Tβ + u_i^f + u_j^m
u_i \sim N(0,σ_m^2),
i,j=1,...,20. There are 20 random effects for female salamnders and 20 random effects for males. Both males' and females' random effects are independent Gaussian random variables but with different variances. There are 4 regression parameters β, all corresponding to a type of cross. Hence, overall there are 6 fixed parameters of which 4 are regression parameter and 2 are variance parameters, reparametrised in logarithmic scale. If the experiments are analysed separately the marginal likelihood for the fixed parameters entails the integration over a 40-dimensional vector of random effects. But if the experiments are analysed jointly, there are 3*40=120 random effects to be integrated out.
double
a 40-dimensional vector
a 40 by 40 positive definite matrix
Ruli E., Sartori N. and Ventura L. (2015) Improved Laplace approximation for marignal likelihoods. http://arxiv.org/abs/1502.06440
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## Not run:
data(Salamander)
library(iLaplace)
# data for experiment 1 (salam1), 2 (salam2) and 3 (salam3)
salam1 = list()
salam1$y = salam$y[,1]
salam1$x = matrix(0, 120, 4)
salam1$x[,1] = rep(1, 120)
salam1$x[,2] = c(salam$x[,3]+salam$x[,4])
salam1$x[,3] = c(salam$x[,2]+salam$x[,4])
salam1$x[,4] = salam1$x[,2]*salam1$x[,3]
salam1$z = salam$z
salam2 = salam1
salam3 = salam1
salam2$y = salam$y[,2]
salam3$y = salam$y[,3]
# maximise the marginal likelihood approximated by the improved
# Laplace approximation
init <- rep(0, 6)
opt1 <- nlminb(init,
obj=function(x) -iLap.nlik_salam(x, data=salam1),
control = list(trace=1)
)
opt1
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.