This function is generic. It performs adjustment of the loglikelihood
associated with fitted model objects, following Chandler and Bate (2007).
Certain classes of extreme value model objects are supported automatically.
For details see the `alogLik`

help pages for the packages:
`evd`

,
`evir`

,
`extRemes`

,
`fExtremes`

,
`ismev`

,
`mev`

,
`POT`

,
`texmex`

.
User-supplied objects can also be supported: the requirements for these
objects are explained in **Details**.

alogLik(x, cluster = NULL, use_vcov = TRUE, ...)

x | A fitted model object with certain associated S3 methods.
See |
---|---|

cluster | A vector or factor indicating from which cluster the
respective loglikelihood contributions from |

use_vcov | A logical scalar. Should we use the |

... | Further arguments to be passed to the functions in the
sandwich package |

An object inheriting from class `"chandwich"`

. See
`adjust_loglik`

.

If `x`

is one of the supported models then the class of the returned
object is a vector of length 5. The first 3 components are
`c("lax", "chandwich", "name_of_package")`

, where
`"name_of_package"`

is the name of the package from which the input
object `x`

originated. The remaining 2 components depend on the
model that was fitted. See the documentation of the relevant package
for details:
`evd`

,
`evir`

,
`extRemes`

,
`fExtremes`

,
`ismev`

,
`mev`

,
`POT`

,
`texmex`

.

Otherwise, the class of the returned object is
`c("lax", "chandwich", class(x))`

.

Objects returned from `aloglik` have `anova`, `coef`, `confint`, `logLik`, `nobs`, `plot`, `print`, `summary` and `vcov` methods.

Object `x`

*must* have the following S3
methods:

`logLikVec:`

returns a vector of the contributions to the independence loglikelihood from individual observations;`coef:`

returns a vector of model coefficients, see`coef`

;`nobs:`

returns the number of (non-missing) observations used in a model fit, see`nobs`

;

and *may* have the following S3 methods

`vcov:`

returns the estimated variance-covariance matrix of the (main) parameters of a fitted model, see`vcov`

;`estfun:`

returns an \(n x k\) matrix, in which each column gives the derivative of the loglikelihood at each of \(n\) observation with respect to the \(k\) parameters of the model, see`estfun`

.

Loglikelihood adjustment is performed using the
`adjust_loglik`

function in the
`chandwich`

package.
The relevant arguments to `adjust_loglik`

, namely
`loglik, mle, H`

and `V`

, are created based on the class of
the object `x`

.

If a `vcov`

method is not available, or if `use_vcov = FALSE`

,
then the variance-covariance matrix of the MLE (from which `H`

is
calculated) is estimated inside `adjust_loglik`

using `optimHess`

.

The `sandwich`

package is used to estimate the variance matrix
`V`

of the score vector: `meat`

is used if
`cluster = NULL`

; `meatCL`

is used if
`cluster`

is not `NULL`

.
If `cluster`

is `NULL`

then any arguments of
`meatCL`

present in ... will be ignored.
Similarly, if `cluster`

is not `NULL`

then any arguments of
`meat`

present in ... will be ignored.
`meat`

and `meatCL`

require an `estfun`

method to be available, which,
in the current context, provides matrix of score contributions.
If a bespoke `estfun`

method is not provided then this is constructed
by estimating the score contributions using `jacobian`

.

See the (package-specific) examples in `evd`

,
`evir`

, `extRemes`

,`fExtremes`

,
`ismev`

, `mev`

, `POT`

and
`texmex`

.

Chandler, R. E. and Bate, S. (2007). Inference for clustered
data using the independence loglikelihood. *Biometrika*,
**94**(1), 167-183. doi: 10.1093/biomet/asm015

Zeileis (2006) Object-Oriented Computation and Sandwich
Estimators. *Journal of Statistical Software*, **16**, 1-16.
doi: 10.18637/jss.v016.i09

`summary.chandwich`

,
`plot.chandwich`

,
`confint.chandwich`

,
`anova.chandwich`

,
`coef.chandwich`

,
`vcov.chandwich`

and `logLik.chandwich`

for S3 methods for objects of class `"chandwich"`

.

`conf_region`

for confidence regions for
pairs of parameters.

`adjust_loglik`

in the
`chandwich`

package to adjust a user-supplied
loglikelihood.