chandwich v1.1.2

0

Monthly downloads

0th

Percentile

Chandler-Bate Sandwich Loglikelihood Adjustment

Performs adjustments of a user-supplied independence loglikelihood function using a robust sandwich estimator of the parameter covariance matrix, based on the methodology in Chandler and Bate (2007) <doi:10.1093/biomet/asm015>. 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. Nested models can be compared using an adjusted likelihood ratio test.

Readme

chandwich

Travis-CI Build Status AppVeyor Build Status Coverage Status CRAN\_Status\_Badge

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. Nested models can be compared using an adjusted likelihood ratio test.

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.

Functions in chandwich

Name Description
coef.chandwich Extract model coefficients method for objects of class "chandwich"
anova.chandwich Comparison of nested models
confint.chandwich Confidence intervals for model parameters
log_gev The Generalised Extreme Value Log-Density Function
chandwich chandwich: Chandler-Bate Sandwich Loglikelihood Adjustment
logLik.chandwich Extract log-likelihood for objects of class "chandwich"
conf_region Two-dimensional confidence regions
compare_models Comparison of nested models
adjust_loglik Loglikelihood adjustment using the sandwich estimator
conf_intervals Confidence intervals
print.confint Print method for objects of class "confint"
plot.confreg Plot diagnostics for a confreg object
plot.confint Plot diagnostics for a confint object
print.summary.chandwich Print method for objects of class "summary.chandwich"
print.compmod Print method for objects of class "compmod"
print.chandwich Print method for objects of class "chandwich"
rats Rat tumor data
profile_loglik Profile loglikelihood
vcov.chandwich Calculate the variance-covariance model for an object of class "chandwich"
plot.chandwich Plot diagnostics for a chandwich object
owtemps Oxford and Worthing annual maximum temperatures
summary.chandwich Summarizing adjusted loglikelihoods
No Results!

Vignettes of chandwich

Name
chandwich-vignette.Rmd
chandwich.bib
No Results!

Last month downloads

Details

Date 2019-07-11
License GPL (>= 2)
LazyData TRUE
Encoding UTF-8
RoxygenNote 6.1.0
VignetteBuilder knitr
URL http://github.com/paulnorthrop/chandwich
BugReports http://github.com/paulnorthrop/chandwich/issues
NeedsCompilation no
Packaged 2019-07-11 16:36:21 UTC; paul
Repository CRAN
Date/Publication 2019-07-11 21:59:26 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/chandwich)](http://www.rdocumentation.org/packages/chandwich)