gamlss.gH {mgcv} | R Documentation |

## Calculating derivatives of log-likelihood wrt regression coefficients

### Description

Mainly intended for internal use with location scale model families.
Given the derivatives of the log-likelihood wrt the linear predictor, this function obtains
the derivatives and Hessian wrt the regression coefficients and derivatives of
the Hessian w.r.t. the smoothing parameters. For input derivative array packing conventions see `trind.generator`

.

### Usage

```
gamlss.gH(X, jj, l1, l2, i2, l3 = 0, i3 = 0, l4 = 0, i4 = 0, d1b = 0,
d2b = 0, deriv = 0, fh = NULL, D = NULL,sandwich=FALSE)
```

### Arguments

`X` |
matrix containing the model matrices of all the linear predictors. |

`jj` |
list of index vectors such that |

`l1` |
array of 1st order derivatives of each element of the log-likelihood wrt each parameter. |

`l2` |
array of 2nd order derivatives of each element of the log-likelihood wrt each parameter. |

`i2` |
two-dimensional index array, such that |

`l3` |
array of 3rd order derivatives of each element of the log-likelihood wrt each parameter. |

`i3` |
third-dimensional index array, such that |

`l4` |
array of 4th order derivatives of each element of the log-likelihood wrt each parameter. |

`i4` |
third-dimensional index array, such that |

`d1b` |
first derivatives of the regression coefficients wrt the smoothing parameters. |

`d2b` |
second derivatives of the regression coefficients wrt the smoothing parameters. |

`deriv` |
if |

`fh` |
eigen-decomposition or Cholesky factor of the penalized Hessian. |

`D` |
diagonal matrix, used to provide some scaling. |

`sandwich` |
set to |

### Value

A list containing `lb`

- the grad vector w.r.t. coefs; `lbb`

- the Hessian matrix w.r.t. coefs;
`d1H`

- either a list of the derivatives of the Hessian w.r.t. the smoothing parameters, or a single matrix whose columns are the leading diagonals of these dervative matrices; `trHid2H`

- the trace of the inverse Hessian multiplied by the second derivative of the Hessian w.r.t. all combinations of smoothing parameters.

### Author(s)

Simon N. Wood <simon.wood@r-project.org>.

### See Also

*mgcv*version 1.9-1 Index]