hessian_log_likelihood_structure: Compute the negated Hessian of the log-likelihood

Description Usage Arguments Value

View source: R/02-likelihood.R

Description

Function to implement the (sparse) NEGATED hessian of the case-crossover log-likelihood This is MINUS the second derivative. Because that's what's used in the paper. So remember when optimizing: provide the NEGATIVE of log_likelihood and gradient_..., but provide the POSITIVE of this function.

Two functions are written. hessian_log_likelihood_x() provides the ELEMENTS of the hessian only This is very fast (134 milliseconds on average for the air pollution example) hessian_log_likelihood_structure() brute-force computes the hessian using bdiag, which is an order of magnitude slower (around a second on average). But the structure never changes, so we only need to compute this once. hessian_log_likelihood() computes the hessian, but you can supply it the structure and it will basically just wrap hessian_log_likelihood_x(). Much faster.

Usage

1
2
3
4
5

Arguments

W

Parameter vector. First n elements are eta, then Gamma and beta.

model_data

A list of class "cc_modeldata" as returned by model_setup().

structure

Optional. A list returned by hessian_log_likelihood_structure() which contains the sparse structure of the hessian. Computing this is the slow part, but only needs to be done once.

Value

A sparse matrix inheriting from class CsparseMatrix containing the negated Hessian of the log-likelihood.


awstringer1/casecrossover documentation built on March 11, 2021, 4:41 a.m.