Releases: paulnorthrop/chandwich
chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
chandwich 1.1.6
Bug fixes and minor improvements
-
Create the help file for the package correctly, with alias chandwich-package.
-
In
plot.confint()confidence limits are now added to the horizontal axis in cases where only one interval is plotted. -
Activated 3rd edition of the
testthatpackage
chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
chandwich 1.1.5
Bug fixes and minor improvements
- In the vignette references section DOIs are rendered with URLs hyperlinked.
chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
chandwich 1.1.4
Bug fixes and minor improvements
-
The function
conf_intervals()now stops evaluating the profile loglikelihood when the required confidence limits have been estimated. -
In
conf_interals()the initial estimates used in the profile loglikelihood were not reset in between the searches for the lower confidence limits and the upper limits. In some cases this may cause problems for the optimisations. This has been corrected: initial estimates are now reset. -
In
confint.chandwich()the argumentprofilecan be used to choose whether to return confidence intervals based on an (adjusted) profile loglikelihood or based on approximate large sample normal theory. -
The
anova.chandwich()function has been modified to enable the comparison of nested (adjusted) model objects, where the nesting has not been explicitly created using the argumentfixed_parstoadjust_loglikelihood(). -
The documentation of
conf_intervals()has been updated: the general nature of the argumentnumis explained and in Details advice is given on what to do if one or more of the confidence limits are not found using the default arguments. -
In the description of the argument
parmin the documentation ofconfint.chandwich(),which_parshas been corrected toparmtwice.
chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
chandwich 1.1.3
Bug fixes and minor improvements
-
The object returned from
adjust_loglik()has an extra attributeloglikVecMLE, which is a vector containing the contributions of individual observations to the independence log-likelihood evaluated at the MLE. -
isTRUE()is used in the GEV example to avoid potential problems owing to the possibility of NAs.
chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
chandwich 1.1.2
Bug fixes and minor improvements
-
A typo meant that the text in the Value section of the description of
confint.chandwich()was cut short. This has been corrected. -
In
adjust_loglik()ifp = 1and the user supplies a scalarHinstead of a matrix then an error is thrown bydimnames()just before the results are returned. The calculations are correct, so the code has been modified trivially to avoid the error. -
In the function returned from
adjust_loglikthe code to perform the horizontal adjustment of the loglikelihood has been changed tox_star <- mle + as.vector(C %*% (x - mle)): usingas.vector()avoids a potential warning by ensuring vector + vector, not vector + matrix. -
There were bugs in
plot.chandwich(),plot.confreg()andplot.confint()that produced an error if the user tried to set their own legend using thelegendargument. These bugs have been corrected.
chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
chandwich 1.1.1
Bug fixes and minor improvements
-
The attribute
nobshas been added to the object returned fromadjust_loglik()and as an attribute to the object returned fromlogLik.chandwich(). -
In
compare_models()the parameter names (if any) are passed to the (adjusted) loglikelihod function, in case they are required inside the loglikelihood function. -
There was a bug in the plot method for objects of class "confreg" returned from conf_region(): if the parameters had not been named by the user then ? appeared twice in the console, requiring the user to press return twice before the plot as produced. This has been corrected.
chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
chandwich 1.1.0
New features
-
adjust_loglikhas an additional argumentsmle,HandVthat allow the user the option to supply the MLE, the Hessian of the independence loglikelihood (H) and the variance of the vector of cluster-specific contributions to the score vector (V), each evaluated at the MLE, rather than estimating these withinadjust_loglik. -
An anova S3 method for class "chandwich" has been added. This compares two or more nested models using adjusted likelihood ratio tests of successive pairs of models, using
compare_models(). -
A confint S3 method for class "chandwich" has been added. This is based on a fairly trivial call to
conf_intervals(). -
S3 methods
coef,vcovandlogLikfor class "chandwich" have been added.
Bug fixes and minor improvements
-
A bug in
compare_models()has been fixed. The bug resulted an error in cases where the argumentlargercorresponded to a simplication of the full model in which element i of the parameter was fixed but some element i+n, for n > 0, was not fixed. -
Estimated unadjusted (VC) and adjusted (adjVC) variance-covariance matrices of the free model parameters are now available in the object returned by
adjust_loglik(). -
The documentation of the argument
approxtocompare_models()has been edited to make it clearer that ifsmalleris not supplied thenapprox = FALSEwill be used regardless of any value supplied forapproxin the call tocompare_models(). -
If parameter names are supplied to
adjust_loglik()(viapar_names) butfixed_parsis numeric then the names of the parameters infixed_parsare now also inferred in the case where a larger model is not supplied vialarger. This means that the output fromcompare_models()will now use the parameter name, rather than the parameter number. -
If a numeric
fixed_parsis supplied tocompare_models()then the names of the parameters infixed_parsare inferred, if they are available in the supplied objectlarger. -
The summary method for class "evpost" is now set up according to Section 8.1 of the R FAQ at (https://cran.r-project.org/doc/FAQ/R-FAQ.html).
-
In the Introducing chandwich vignette a typo in the definition of HA has been corrected. The expression given is for the inverse of HA, not for HA.
chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
Chandler-Bate Sandwich Loglikelihood Adjustment
What does chandwich do?
The chandwich package performs adjustments of an independence loglikelihood using a robust sandwich estimator of the parameter covariance matrix, based on the methodology in Chandler and Bate (2007). This can be used for cluster correlated data when interest lies in the parameters of the marginal distributions or for performing inferences that are robust to certain types of model misspecification. Functions for profiling the adjusted loglikelihoods are also provided, as are functions for calculating and plotting confidence intervals, for single
model parameters, and confidence regions, for pairs of model parameters.
A simple example
The main function in the chandwich package is adjust_loglik. It finds the maximum likelihood estimate (MLE) of model parameters based on an independence loglikelihood in which cluster dependence in the data is ignored. The independence loglikelihood is adjusted in a way that ensures that the Hessian of the adjusted loglikelihood conicides with a robust sandwich estimate of the parameter covariance at the MLE. Three adjustments are available: one in which the independence loglikelihood itself is scaled (vertical scaling) and two others where the scaling is in the parameter vector (horizontal scaling).
The rats data contain information about an experiment in which, for each of 71 groups of rats, the total number of rats in the group and the numbers of rats who develop a tumor is recorded. We model these data using a binomial distribution, treating each group of rats as a separate cluster. The argument binom_loglik to adjust_loglik is a function that returns a vector of the loglikelihood contributions from each group of rats. In one-dimensional examples like this the two adjustments using horizontal scaling are identical, but this will not generally hold in more than one dimension.
binom_loglik <- function(prob, data) {
if (prob < 0 || prob > 1) {
return(-Inf)
}
return(dbinom(data[, "y"], data[, "n"], prob, log = TRUE))
}
rat_res <- adjust_loglik(loglik = binom_loglik, data = rats)
plot(rat_res, type = 1:4, legend_pos = "bottom", lwd = 2, col = 1:4)
Installation
To get the current released version from CRAN:
install.packages("chandwich")
Vignette
See vignette("chandwich-vignette", package = "chandwich") for an overview of the package.