Learn R Programming

JMbayes (version 0.8-85)

logLik.JMbayes: Log-Likelihood for Joint Models

Description

Computes the log-likelihood for a fitted joint model.

Usage

# S3 method for JMbayes
logLik(object, thetas, b, priors = TRUE, marginal.b = TRUE, 
    marginal.thetas = FALSE, full.Laplace = FALSE, useModes = TRUE, …)

Arguments

object

an object inheriting from class JMBayes.

thetas

a list with values for the joint model's parameters. This should have the same structure as the coefficients component of a fitted joint model. If missing object$postMeans is used.

b

a numeric matrix with random effects value. This should have the same structure as the ranef component of a fitted joint model. If missing ranef(object) is used.

priors

logical, if TRUE the priors are also included in the computation.

marginal.b

logical, if TRUE the marginal log-likelihood over the random effects is returned. This marginalization is done using a Laplace approximation.

marginal.thetas

logical, if TRUE the marginal log-likelihood over the parameters is returned. This marginalization is done using a Laplace approximation.

full.Laplace

logical, if FALSE the posterior means and posterior variances are used in the Laplace approximation instead of the posterior modes and posterior hessian matrix of the random effects. Sacrificing a bit of accuracy, this will be much faster than calculating the posterior modes. Relevant only when marginal.b = TRUE.

useModes

logical, if TRUE the modes are used in the Laplace approximation otherwise the means.

extra arguments; currently none is used.

Value

a numeric scalar of class logLik with the value of the log-likelihood. It also has the attributes df the number of parameter (excluding the random effects), and nobs the number of subjects.

Details

Let \(y_i\) denote the vectors of longitudinal responses, \(T_i\) the observed event time, and \(\delta_i\) the event indicator for subject \(i\) (\(i = 1, \ldots, n\)). Let also \(p(y_i | b_i; \theta)\) denote the probability density function (pdf) for the linear mixed model, \(p(T_i, \delta_i | b_i; \theta)\) the pdf for the survival submodel, and \(p(b_i; \theta)\) the multivariate normal pdf for the random effects, where \(\theta\) denotes the full parameter vector. Then, if priors = TRUE, and marginal.b = TRUE, function logLik() computes $$\log \int p(y_i | b_i; \theta) p(T_i, \delta_i | b_i; \theta) p(b_i; \theta) db_i + \log p(\theta),$$ where \(p(\theta)\) denotes the prior distribution for the parameters. If priors = FALSE the prior is excluded from the computation, i.e., $$\log \int p(y_i | b_i; \theta) p(T_i, \delta_i | b_i; \theta) p(b_i; \theta) db_i,$$ and when marginal.b = FALSE, then the conditional on the random effects log-likelihood is computed, i.e., $$\log p(y_i | b_i; \theta) + \log p(T_i, \delta_i | b_i; \theta) + \log p(b_i; \theta) + \log p(\theta),$$ when priors = TRUE and $$\log p(y_i | b_i; \theta) + \log p(T_i, \delta_i | b_i; \theta) + \log p(b_i; \theta),$$ when priors = FALSE.

References

Rizopoulos, D., Hatfield, L., Carlin, B. and Takkenberg, J. (2014). Combining dynamic predictions from joint models for longitudinal and time-to-event data using Bayesian model averaging. Journal of the American Statistical Association. to appear.

See Also

jointModelBayes

Examples

Run this code
# NOT RUN {
lmeFit <- lme(log(serBilir) ~ ns(year, 2), data = pbc2, 
    random = ~ ns(year, 2) | id)
survFit <- coxph(Surv(years, status2) ~ 1, data = pbc2.id, x = TRUE)

jointFit <- jointModelBayes(lmeFit, survFit, timeVar = "year")

logLik(jointFit)
logLik(jointFit, priors = FALSE)
logLik(jointFit, marginal.b = FALSE)
# }

Run the code above in your browser using DataLab