Description Usage Arguments Value
View source: R/02-likelihood.R
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.
1 2 3 4 5 | hessian_log_likelihood_structure(W, model_data)
hessian_log_likelihood_x(W, model_data)
hessian_log_likelihood(W, model_data, structure = NULL)
|
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. |
A sparse matrix inheriting from class CsparseMatrix containing the negated Hessian of the log-likelihood.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.