diff --git a/DESCRIPTION b/DESCRIPTION index 5ebb0bd..ce619ef 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: brglm2 Title: Bias Reduction in Generalized Linear Models -Version: 0.6.1 +Version: 0.6.2 Authors@R: c(person(given = "Ioannis", family = "Kosmidis", role = c("aut", "cre"), email = "ioannis.kosmidis@warwick.ac.uk", comment = c(ORCID = "0000-0003-1556-0302")), person(given = "Kjell", family = "Konis", role = "ctb", email = "kjell.konis@me.com"), person(given = c("Euloge", "Clovis"), family = c("Kenne Pagui"), role = "ctb", email = "kenne@stat.unipd.it"), diff --git a/NEWS.md b/NEWS.md index 6dd980f..dc4ab47 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,113 +1,158 @@ -# brglm 0.6.1 +# brglm2 0.6.2 + +## Other improvements, updates and additions +* `vcov.brglmFit` objects now uses `vcov.summary.glm` and supports the + `complete` argument for controlling whether the variance covariance + matrix should include rows and columns for aliased parameters. +* Deprecated `detect_sepration` and `check_infinite_estimates`, which + will be removed from **brglm2** at version 0.8. New versions of + `detect_sepration` and `check_infinite_estimates` are now maintained + in the + [**detectseparation**](https://cran.r-project.org/package=detectseparation) + R package. +* Fixed typos in NEWS. + +# brglm2 0.6.1 ## Bug fixes * Fixed bug in AIC reported by `print.summary` for `brmultinom` and `bracl` -* `detect_separation` now handles one-column model matrices correctly +* `detect_separation` now handles one-column model matrices correctly. ## Other improvements, updates and additions * Documentation improvements and typo fixes -# brglm 0.6 +# brglm2 0.6 ## New functionality -* `brglmFit` can now do maximum penalized likelihood with powers of the Jeffreys prior as penalty (`type = "MPL_Jeffreys`) for all supported generalized linear models. See `brglmControl` and `brglmFit` for details. +* `brglmFit` can now do maximum penalized likelihood with powers of + the Jeffreys prior as penalty (`type = "MPL_Jeffreys`) for all + supported generalized linear models. See `brglmControl` and + `brglmFit` for details. ## Other improvements, updates and additions -* Documentation updates and improvements -* Updated vignettes to include maximum penalized likelihood with powers of the Jeffreys prior as penalty -* New examples in `?brglmFit` +* Documentation updates and improvements. +* Updated vignettes to include maximum penalized likelihood with + powers of the Jeffreys prior as penalty. +* New examples in `?brglmFit`. -# brglm 0.5.2 +# brglm2 0.5.2 ## Bug fixes -* `print.brmultinom` is now exported, so `bracl` and `brmultinom` fits print correctly +* `print.brmultinom` is now exported, so `bracl` and `brmultinom` fits + print correctly. ## New functionality -* Added `response_adjustment` argument in `brglmControl` to allow for more fine-tuning of the starting values when `brglmFit` is called with `start = NULL` +* Added `response_adjustment` argument in `brglmControl` to allow for + more fine-tuning of the starting values when `brglmFit` is called + with `start = NULL`. ## Other improvements, updates and additions -* Documentation updates and improvements -* Added Kosmidis et al (2019) in the description file -* Added tests for `brglmControl` +* Documentation updates and improvements. +* Added Kosmidis et al (2019) in the description file. +* Added tests for `brglmControl`. -# brglm 0.5.1 +# brglm2 0.5.1 ## Other improvements, updates and additions -* Fixed typos in vignettes and documentation -* Added ORCHID for Ioannis Kosmidis in DESCRIPTION +* Fixed typos in vignettes and documentation. +* Added ORCHID for Ioannis Kosmidis in DESCRIPTION. -# brglm 0.5.0 +# brglm2 0.5.0 ## Bug fixes -* `brglmFit` now works as expected with custom link functions (mean and median bias reduction) -* `brglmFit` respects the specification of the transformation argument in `brglmControl` -* Fixed bug in the computation of the QR decomposition under aliasing in `brglmFit` -* Other minor bug fixes and performance improvements -* Protection against use of `quasi`, `quasibinomial` and `quasibinomial` families and documentation update. +* `brglmFit` now works as expected with custom link functions (mean + and median bias reduction). +* `brglmFit` respects the specification of the transformation argument + in `brglmControl`. +* Fixed bug in the computation of the QR decomposition under aliasing + in `brglmFit`. +* Other minor bug fixes and performance improvements. +* Protection against use of `quasi`, `quasibinomial` and + `quasibinomial` families and documentation update. ## New functionality -* Added `bracl` for fitting adjacent category logit models for ordinal responses using maximum likelihood, mean bias reduction, and median bias reduction and associated methods (`logLik`, `summary` and so on) -* Added `predict` methods for `brmultinom` and `bracl` -@ Added `residuals` methods for `brmultinom` and `bracl` (residuals of the equivalent Poisson log-linear model) -* Added the `mis` link functions for accounting for misclassification in binomial response models (Neuhaus, 1999, Biometrika) +* Added `bracl` for fitting adjacent category logit models for ordinal + responses using maximum likelihood, mean bias reduction, and median + bias reduction and associated methods (`logLik`, `summary` and so + on). +* Added `predict` methods for `brmultinom` and `bracl`. @ Added +`residuals` methods for `brmultinom` and `bracl` (residuals of the +equivalent Poisson log-linear model) +* Added the `mis` link functions for accounting for misclassification + in binomial response models (Neuhaus, 1999, Biometrika). ## Other improvements, updates and additions -* Improved `summary` method for `brmultinom` objects -* Better starting values for null fits -* Added references to [arxiv:1804.04085](https://arxiv.org/abs/1804.04085) in documentation -* Updated reference to [Kenne Pagui et al (2017)](https://doi.org/10.1093/biomet/asx046) +* Improved `summary` method for `brmultinom` objects. +* Better starting values for null fits. +* Added references to [arxiv:1804.04085](https://arxiv.org/abs/1804.04085) in + documentation. +* Updated reference to [Kenne Pagui et al (2017)](https://doi.org/10.1093/biomet/asx046). -# brglm 0.1.8 +# brglm2 0.1.8 ## Other improvements, updates and additions -* Improved documentation examples -* Removed warning about observations with non-positive weights from brmultinom -* Updated email address for Ioannis Kosmidis in brglmFit +* Improved documentation examples. +* Removed warning about observations with non-positive weights from brmultinom. +* Updated email address for Ioannis Kosmidis in brglmFit. ## Bug fixes -* brmultinom returns a fitted values matrix that respects the dimension of data -* Fixed bug on condition for NA dispersion for models with 0 df resid +* brmultinom returns a fitted values matrix that respects the + dimension of data. +* Fixed bug on condition for NA dispersion for models with 0 df resid. -# brglm 0.1.7 +# brglm2 0.1.7 ## Other improvements, updates and additions -* Eliminated errors from markdown chunks in multinomial vignette +* Eliminated errors from markdown chunks in multinomial vignette. # brglm2 0.1.6 ## Bug fixes -* Compatibility with new version of enrichwith +* Compatibility with new version of enrichwith. ## Other improvements, updates and additions -* New email for Ioannis Kosmidis +* New email for Ioannis Kosmidis. # brglm2 0.1.5 ## Bug fixes ## New functionality -* Added `type = AS_mixed` as an option to use **mean-bias reducing score functions** for the regression parameters and **median-bias reducing score functions** for the dispersion in models with unknown dispersion -* `check_infinite_estimates` now accepts `brmultinom` objects -* Added `singular.ok` argument to `brglmFit` and `detect_separation` methods in line with the update of `glm.fit` +* Added `type = AS_mixed` as an option to use **mean-bias reducing + score functions** for the regression parameters and **median-bias + reducing score functions** for the dispersion in models with unknown + dispersion. +* `check_infinite_estimates` now accepts `brmultinom` objects. +* Added `singular.ok` argument to `brglmFit` and `detect_separation` + methods in line with the update of `glm.fit`. ## Other improvements, updates and additions -* less strict tolerance in `brglm_control` -* Updates to help files -* Fixed typos in iteration vignette -* Added URL and bugreports in Description -* Added new tests +* less strict tolerance in `brglm_control`. +* Updates to help files. +* Fixed typos in iteration vignette. +* Added URL and bugreports in Description. +* Added new tests. # brglm2 0.1.4 ## Bug fixes -* `brglmControl` is now exported -* `slowit` did nothing; now included in iteration +* `brglmControl` is now exported. +* `slowit` did nothing; now included in iteration. ## New functionality -* The `detect_separation` `method` for the `glm` function can be used to check for separation in binomial response settings without fitting the model. This relies on a port of Kjell Konis' `safeBinaryRegression:::separator` function (see ?detect_separation) -* brglm2 provides estimation via **median-bias reducing score functions** with `type = "AS_median"` -* brglm2 provides camel and underscored aliases for basic methods (`brglmFit`, `brglm_fit`, `detectSeparation`, `detect_separation`, `brglm_control`, `brglmControl`, `detectSeparationControl`, `detect_separation_control`, `checkInfiniteEstimates`, `check_infinite_estimates`) +* The `detect_separation` `method` for the `glm` function can be used + to check for separation in binomial response settings without + fitting the model. This relies on a port of Kjell Konis' + `safeBinaryRegression:::separator` function (see ?detect_separation). +* **brglm2** provides estimation via **median-bias reducing score + functions** with `type = "AS_median"`. +* **brglm2** provides camel and underscored aliases for basic methods + (`brglmFit`, `brglm_fit`, `detectSeparation`, `detect_separation`, + `brglm_control`, `brglmControl`, `detectSeparationControl`, + `detect_separation_control`, `checkInfiniteEstimates`, + `check_infinite_estimates`). ## Other improvements, updates and additions -* Minor enhancements in the codebase -* The inverse expected information matrix is computed internally using cho2inv -* Internal changes to have more meaningful variable names -* Renamed detect_infinite* to check_infinite +* Minor enhancements in the codebase. +* The inverse expected information matrix is computed internally using + `cho2inv`. +* Internal changes to have more meaningful variable names. +* Renamed detect_infinite* to check_infinite. # brglm2 0.1.3 @@ -117,11 +162,11 @@ ## Other improvements, updates and additions * Fixed typo in f_{Y_i}(y) in iteration vignette (thanks to Eugene - Clovis Kenne Pagui for spotting) + Clovis Kenne Pagui for spotting), # brglm2 0.1.2 -* First release +* First release. diff --git a/R/brglm2-package.R b/R/brglm2-package.R index 47b731d..575172c 100644 --- a/R/brglm2-package.R +++ b/R/brglm2-package.R @@ -94,7 +94,24 @@ if (getRversion() >= "2.15.1") globalVariables(c("n", "lambda")) #' @param object a fitted model object (e.g. the result of a #' \code{\link{glm}} call). #' @param ... other options to be passed to the method. +#' +#' +#' @note +#' +#' +#' \code{check_infinite_estimates} will be removed from \pkg{brglm2} +#' at version 0.8. An new version of +#' \code{check_infinite_estimates} is now maintained in the +#' \pkg{detectseparation} R package at +#' \url{https://cran.r-project.org/package=detectseparation}. +#' +#' @seealso check_infinite_estimates.glm +#' #' @export check_infinite_estimates <- function(object, ...) { + function_moves_to_new_package(gsub("\\(|\\)", "", deparse(match.call()[1])), + "0.8", + "brglm2", + "detectseparation") UseMethod("check_infinite_estimates") } diff --git a/R/brglmControl.R b/R/brglmControl.R index 2b560cb..176c0a7 100644 --- a/R/brglmControl.R +++ b/R/brglmControl.R @@ -20,7 +20,6 @@ #' Typically only used internally by \code{\link{brglmFit}}, but may #' be used to construct a \code{control} argument. #' -#' @inheritParams stats::glm.control #' @aliases brglm_control #' @param epsilon positive convergence tolerance epsilon. Default is #' \code{1e-06}. diff --git a/R/brglmFit.R b/R/brglmFit.R index 659f117..cb744fd 100644 --- a/R/brglmFit.R +++ b/R/brglmFit.R @@ -1254,16 +1254,24 @@ confint.brglmFit <- function(object, parm, level = 0.95, ...) { #' Return the variance-covariance matrix for the regression parameters #' in a \code{\link{brglmFit}} object #' -#' @inheritParams stats::vcov +#' @inheritParams stats::vcov.glm #' @param model character specifying for which component of the model coefficients should be extracted. #' +#' @details +#' +#' The options for \code{model} are \code{"mean"} for mean regression +#' parameters only (default), \code{"dispersion"} for the dispersion +#' parameter (or the transformed dispersion; see +#' \code{\link{brglm_control}}), and \code{"mean"} for both the mean +#' regression and the (transformed) dispersion parameters. +#' #' @method vcov brglmFit #' @export -vcov.brglmFit <- function(object, model = c("mean", "full", "dispersion"), ...) { +vcov.brglmFit <- function(object, model = c("mean", "full", "dispersion"), complete = TRUE, ...) { model <- match.arg(model) switch(model, mean = { - summary.brglmFit(object, ...)$cov.scaled + vcov(summary.brglmFit(object, ...), complete = complete) }, dispersion = { vtd <- 1/object$info_transformed_dispersion @@ -1272,7 +1280,7 @@ vcov.brglmFit <- function(object, model = c("mean", "full", "dispersion"), ...) vtd }, full = { - vbetas <- summary.brglmFit(object, ...)$cov.scaled + vbetas <- vcov(summary.brglmFit(object, ...), complete = complete) vtd <- 1/object$info_transformed_dispersion nBetasAll <- c(rownames(vbetas), paste0(object$transformation, "(dispersion)")) vBetasAll <- cbind(rbind(vbetas, 0), diff --git a/R/brmultinom.R b/R/brmultinom.R index 34eacf7..97e2cba 100644 --- a/R/brmultinom.R +++ b/R/brmultinom.R @@ -46,7 +46,7 @@ #' baseline-category logit models have infinite components with #' positive probability, which can result in problems in their #' estimation and the use of inferential procedures (e.g. Wad -#' tests). Albert and Andreson (1984) have categorised the possible +#' tests). Albert and Andreson (1984) have categorized the possible #' data patterns for such models into the exclusive and exhaustive #' categories of complete separation, quasi-complete separation and #' overlap, and showed that infinite maximum likelihood estimates @@ -264,7 +264,7 @@ fitted.brmultinom <- function(object, ...) { #' @details #' #' The residuals computed are the residuals from the equivalent -#' Poisson log-linear model fit, organised in a form that matches the +#' Poisson log-linear model fit, organized in a form that matches the #' output of \code{fitted(object, type = "probs")}. As a result, the #' output is residuals defined in terms of the object and expected #' multinomial counts. @@ -418,7 +418,7 @@ print.summary.brmultinom <- function(x, digits = x$digits, ...) #' \code{"class"}, which produces predictions of the response #' category at the covariate values supplied in \code{"newdata"}, #' selecting the category with the largest probability; the -#' alternative \code{"probs"} returns all cateogry probabilities +#' alternative \code{"probs"} returns all category probabilities #' at the covariate values supplied in \code{"newdata"}. #' @param ... further arguments passed to or from other methods. #' diff --git a/R/check_infinite_estimates.R b/R/check_infinite_estimates.R index 0680185..4bbe527 100644 --- a/R/check_infinite_estimates.R +++ b/R/check_infinite_estimates.R @@ -28,7 +28,7 @@ #' #' @details #' -#' \code{check_infinite_estimates} attempts to identify the occurence +#' \code{check_infinite_estimates} attempts to identify the occurrence #' of infinite estimates in GLMs with binomial responses by #' successively refitting the model. At each iteration the maximum #' number of allowed IWLS iterations is fixed starting from 1 to @@ -43,6 +43,16 @@ #' estimate for the corresponding parameter has value minus or plus #' infinity. #' +#' @note +#' +#' \code{check_infinite_estimates} will be removed from \pkg{brglm2} +#' at version 0.8. An new version of \code{check_infinite_estimates} +#' is now maintained in the \pkg{detectseparation} R package at +#' \url{https://cran.r-project.org/package=detectseparation}. In order +#' to use the version in \code{detect_separation} load first +#' \pkg{brglm2} and then \pkg{detectseparation}, i.e. +#' \code{library(brglm2); library(detectseparation)}. +#' #' @seealso \code{\link[nnet]{multinom}}, \code{\link{brmultinom}} #' #' @references @@ -73,7 +83,7 @@ #' } #' @export check_infinite_estimates.glm <- function(object, nsteps = 20, ...) -{ +{ is_brmultinom <- inherits(object, "brmultinom") if ((class(object)[1] != "glm") & (!is_brmultinom)) { diff --git a/R/data.R b/R/data.R index 99be558..9deef33 100644 --- a/R/data.R +++ b/R/data.R @@ -40,7 +40,7 @@ #' #' \item{PI}{pulsality index of arteria uterina} #' -#' \item{EH}{endometrium heigh} +#' \item{EH}{endometrium height} #' #' \item{HG}{histology grade with coding 0 for low grade and 1 for high grade} #' @@ -50,7 +50,7 @@ #' from \url{http://www.stat.ufl.edu/~aa/glm/data}. The latter #' link provides the data sets used in Agresti (2015). #' -#' The endometrial data set was first analysed in Heinze and +#' The endometrial data set was first analyzed in Heinze and #' Schemper (2002), and was originally provided by Dr #' E. Asseryanis from the Medical University of Vienna. #' @@ -113,7 +113,7 @@ #' #' @source #' -#' The alligators data set is analysed in Agresti (2002, Subsection~7.1.2). +#' The alligators data set is analyzed in Agresti (2002, Subsection~7.1.2). #' #' @seealso #' @@ -156,7 +156,7 @@ #' #' @source #' -#' The \code{stemcell} data set is analysed in Agresti (2010, Subsection~4.1.5). +#' The \code{stemcell} data set is analyzed in Agresti (2010, Subsection~4.1.5). #' #' @references #' diff --git a/R/detect_separation.R b/R/detect_separation.R index 0a29dc1..9dd6010 100644 --- a/R/detect_separation.R +++ b/R/detect_separation.R @@ -57,18 +57,28 @@ #' #' \code{detectSeparation} is an alias for \code{detect_separation}. #' +#' @note +#' +#' \code{detect_separation} will be removed from \pkg{brglm2} at +#' version 0.8. A new version of \code{detect_separation} is now +#' maintained in the \pkg{detectseparation} R package at +#' \url{https://cran.r-project.org/package=detectseparation}. In order +#' to use the version in \code{detect_separation} load first +#' \pkg{brglm2} and then \pkg{detectseparation}, i.e. +#' \code{library(brglm2); library(detectseparation)}. +#' #' @author Ioannis Kosmidis [aut, cre] \email{ioannis.kosmidis@warwick.ac.uk}, Kjell Konis [ctb] \email{kjell.konis@me.com} #' #' @seealso \code{\link{brglm_fit}}, \code{\link{glm.fit}} and \code{\link{glm}} #' #' @references #' -#' Kjell K. (2007). *Linear Programming Algorithms for Detecting +#' Konis K. (2007). *Linear Programming Algorithms for Detecting #' Separated Data in Binary Logistic Regression #' Models*. DPhil. University of Oxford. #' \url{https://ora.ox.ac.uk/objects/uuid:8f9ee0d0-d78e-4101-9ab4-f9cbceed2a2a} #' -#' Kjell K. (2013). safeBinaryRegression: Safe Binary Regression. R +#' Konis K. (2013). safeBinaryRegression: Safe Binary Regression. R #' package version 0.1-3. #' \url{https://CRAN.R-project.org/package=safeBinaryRegression} #' @@ -102,10 +112,16 @@ #' update(murder_glm, method = "brglm_fit") #' } #' @export -detect_separation <- function (x, y, weights = rep(1, nobs), - start = NULL, etastart = NULL, mustart = NULL, - offset = rep(0, nobs), family = gaussian(), - control = list(), intercept = TRUE, singular.ok = TRUE) { +detect_separation <- function(x, y, weights = rep(1, nobs), + start = NULL, etastart = NULL, mustart = NULL, + offset = rep(0, nobs), family = gaussian(), + control = list(), intercept = TRUE, singular.ok = TRUE) { + + function_moves_to_new_package(gsub("\\(|\\)", "", deparse(match.call()[1])), + "0.8", + "brglm2", + "detectseparation") + if (family$family != "binomial") { warning("detect_separation has been developed for use with binomial-response models") } diff --git a/R/warnings.R b/R/warnings.R new file mode 100644 index 0000000..356bdba --- /dev/null +++ b/R/warnings.R @@ -0,0 +1,21 @@ +function_moves_to_new_package <- function(function_name, + removal_version, + current_pkg, + new_pkg, + extra_message = NULL) { + function_name <- paste0("'", function_name, "'") + current_pkg <- paste0("'", current_pkg, "'") + new_pkg <- paste0("'", new_pkg, "'") + msg <- paste(function_name, + "will be removed from", + current_pkg, + "at version", + paste0(removal_version, "."), + "A new version of", + function_name, + "is now maintained in the", + new_pkg, + "package.", + extra_message) + .Deprecated(msg = msg, package = new_pkg) +} diff --git a/README.md b/README.md index 91edfac..7bb24df 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ brglm2 Reduction of estimation bias is achieved by solving either the mean-bias reducing adjusted score equations in [Firth (1993)](https://doi.org/10.1093/biomet/80.1.27) and [Kosmidis & Firth (2009)](https://doi.org/10.1093/biomet/asp055) or the median-bias reducing adjusted score equations in [Kenne et al (2016)](https://arxiv.org/abs/1604.04768), or through the direct subtraction of an estimate of the bias of the maximum likelihood estimator from the maximum likelihood estimates as prescribed in [Cordeiro and McCullagh (1991)](http://www.jstor.org/stable/2345592). [Kosmidis et al (2019)](https://doi.org/10.1007/s11222-019-09860-6) provides a unifying framework and algorithms for mean and median bias reduction for the estimation of generalized linear models. -In the special case of generalized linear models for binomial and multinomial responses (both ordinal and nomial), the adjusted score equations return estimates with improved frequentist properties, that are also always finite, even in cases where the maximum likelihood estimates are infinite (e.g. complete and quasi-complete separation). See, [Kosmidis & Firth (2019)](http://arxiv.org/abs/1812.01938) for the proof of the latter result in the case of mean bias reduction for logistic regression (and, for more general binomial-response models where the likelihood is penalized by a power of the Jeffreys invariant prior). +In the special case of generalized linear models for binomial and multinomial responses (both ordinal and nominal), the adjusted score equations return estimates with improved frequentist properties, that are also always finite, even in cases where the maximum likelihood estimates are infinite (e.g. complete and quasi-complete separation). See, [Kosmidis & Firth (2019)](http://arxiv.org/abs/1812.01938) for the proof of the latter result in the case of mean bias reduction for logistic regression (and, for more general binomial-response models where the likelihood is penalized by a power of the Jeffreys invariant prior). **brglm2** also provides *pre-fit* and *post-fit* methods for the detection of separation and of infinite maximum likelihood estimates in binomial response generalized linear models (see `?detect_separation` and `?check_infinite_estimates`). @@ -49,6 +49,5 @@ The classification of bias reduction methods into explicit and implicit is as gi Motivation, details and discussion on the methods that **brglm2** implements are provided in -Kosmidis, I, Kenne Pagui, E C, Sartori N. (2017). Mean and median bias reduction in generalized linear models. To appear in [*Statistics and Computing*](https://doi.org/10.1007/s11222-019-09860-6). *arXiv*, [arXiv:1710.11217](http://arxiv.org/abs/1804.04085). - +Kosmidis, I, Kenne Pagui, E C, Sartori N. (2017). Mean and median bias reduction in generalized linear models. [*Statistics and Computing*](https://doi.org/10.1007/s11222-019-09860-6) *30*, 43–59. *arXiv*, [arXiv:1710.11217](http://arxiv.org/abs/1804.04085). diff --git a/inst/WORDLIST b/inst/WORDLIST new file mode 100644 index 0000000..37792dd --- /dev/null +++ b/inst/WORDLIST @@ -0,0 +1,74 @@ +Agresti +al +Andreson +arteria +arxiv +arXiv +Asseryanis +behaviour +biomet +Biometrika +bracl +brglm +brglmFit +brmultinom +bugreports +codebase +Cordeiro +detectseparation +df +diag +doi +DPhil +enrichwith +equivariance +et +finiteness +foodchoice +frac +github +glm +grahami +Heinze +http +https +ICPSR +inverseSqrt +iw +Jeffreys +Jefreys +jj +jstor +Kenne +Laver +ldots +leftarrow +Lesaffre +Licence +McCullagh +misclassified +nd +Nelder +neovasculization +Neuhaus +Nonsynchronous +nsteps +opalinus +Pagui +Palmgren +pre +priori +pulsality +Raphson +resid +safeBinaryRegression +Salvan +Schemper +Schoener +th +TWD +useR +uterina +vdots +www +Zeilig diff --git a/man/alligators.Rd b/man/alligators.Rd index 009aa46..7e8ebf6 100644 --- a/man/alligators.Rd +++ b/man/alligators.Rd @@ -20,7 +20,7 @@ }} \source{ -The alligators data set is analysed in Agresti (2002, Subsection~7.1.2). +The alligators data set is analyzed in Agresti (2002, Subsection~7.1.2). } \usage{ alligators diff --git a/man/brmultinom.Rd b/man/brmultinom.Rd index 2dc619b..868d76c 100644 --- a/man/brmultinom.Rd +++ b/man/brmultinom.Rd @@ -91,7 +91,7 @@ The maximum likelihood estimates for the parameters of baseline-category logit models have infinite components with positive probability, which can result in problems in their estimation and the use of inferential procedures (e.g. Wad -tests). Albert and Andreson (1984) have categorised the possible +tests). Albert and Andreson (1984) have categorized the possible data patterns for such models into the exclusive and exhaustive categories of complete separation, quasi-complete separation and overlap, and showed that infinite maximum likelihood estimates diff --git a/man/check_infinite_estimates.Rd b/man/check_infinite_estimates.Rd index 5ac90fb..a5e5754 100644 --- a/man/check_infinite_estimates.Rd +++ b/man/check_infinite_estimates.Rd @@ -15,3 +15,13 @@ check_infinite_estimates(object, ...) \description{ Generic method for checking for infinite estimates } +\note{ +\code{check_infinite_estimates} will be removed from \pkg{brglm2} +at version 0.8. An new version of +\code{check_infinite_estimates} is now maintained in the +\pkg{detectseparation} R package at +\url{https://cran.r-project.org/package=detectseparation}. +} +\seealso{ +check_infinite_estimates.glm +} diff --git a/man/check_infinite_estimates.glm.Rd b/man/check_infinite_estimates.glm.Rd index cd00a5a..b2fb2e5 100644 --- a/man/check_infinite_estimates.glm.Rd +++ b/man/check_infinite_estimates.glm.Rd @@ -22,7 +22,7 @@ A simple diagnostic of whether the maximum likelihood estimates are infinite } \details{ -\code{check_infinite_estimates} attempts to identify the occurence +\code{check_infinite_estimates} attempts to identify the occurrence of infinite estimates in GLMs with binomial responses by successively refitting the model. At each iteration the maximum number of allowed IWLS iterations is fixed starting from 1 to @@ -37,6 +37,15 @@ quasi-complete separation occurs and the maximum likelihood estimate for the corresponding parameter has value minus or plus infinity. } +\note{ +\code{check_infinite_estimates} will be removed from \pkg{brglm2} +at version 0.8. An new version of \code{check_infinite_estimates} +is now maintained in the \pkg{detectseparation} R package at +\url{https://cran.r-project.org/package=detectseparation}. In order +to use the version in \code{detect_separation} load first +\pkg{brglm2} and then \pkg{detectseparation}, i.e. +\code{library(brglm2); library(detectseparation)}. +} \examples{ ## endometrial data from Heinze \& Schemper (2002) (see ?endometrial) diff --git a/man/detect_separation.Rd b/man/detect_separation.Rd index a0cf736..cdb6712 100644 --- a/man/detect_separation.Rd +++ b/man/detect_separation.Rd @@ -98,6 +98,15 @@ permission of Kjell Konis. \code{detectSeparation} is an alias for \code{detect_separation}. } +\note{ +\code{detect_separation} will be removed from \pkg{brglm2} at +version 0.8. A new version of \code{detect_separation} is now +maintained in the \pkg{detectseparation} R package at +\url{https://cran.r-project.org/package=detectseparation}. In order +to use the version in \code{detect_separation} load first +\pkg{brglm2} and then \pkg{detectseparation}, i.e. +\code{library(brglm2); library(detectseparation)}. +} \examples{ ## endometrial data from Heinze \& Schemper (2002) (see ?endometrial) @@ -129,12 +138,12 @@ update(murder_glm, method = "brglm_fit") } } \references{ -Kjell K. (2007). *Linear Programming Algorithms for Detecting +Konis K. (2007). *Linear Programming Algorithms for Detecting Separated Data in Binary Logistic Regression Models*. DPhil. University of Oxford. \url{https://ora.ox.ac.uk/objects/uuid:8f9ee0d0-d78e-4101-9ab4-f9cbceed2a2a} -Kjell K. (2013). safeBinaryRegression: Safe Binary Regression. R +Konis K. (2013). safeBinaryRegression: Safe Binary Regression. R package version 0.1-3. \url{https://CRAN.R-project.org/package=safeBinaryRegression} } diff --git a/man/endometrial.Rd b/man/endometrial.Rd index 89dade9..6d21023 100644 --- a/man/endometrial.Rd +++ b/man/endometrial.Rd @@ -11,7 +11,7 @@ \item{PI}{pulsality index of arteria uterina} -\item{EH}{endometrium heigh} +\item{EH}{endometrium height} \item{HG}{histology grade with coding 0 for low grade and 1 for high grade} @@ -21,7 +21,7 @@ The packaged data set was downloaded in \code{.dat} format from \url{http://www.stat.ufl.edu/~aa/glm/data}. The latter link provides the data sets used in Agresti (2015). - The endometrial data set was first analysed in Heinze and + The endometrial data set was first analyzed in Heinze and Schemper (2002), and was originally provided by Dr E. Asseryanis from the Medical University of Vienna. } diff --git a/man/predict.brmultinom.Rd b/man/predict.brmultinom.Rd index 583177d..73499b5 100644 --- a/man/predict.brmultinom.Rd +++ b/man/predict.brmultinom.Rd @@ -18,7 +18,7 @@ predictors are used.} \code{"class"}, which produces predictions of the response category at the covariate values supplied in \code{"newdata"}, selecting the category with the largest probability; the -alternative \code{"probs"} returns all cateogry probabilities +alternative \code{"probs"} returns all category probabilities at the covariate values supplied in \code{"newdata"}.} \item{...}{further arguments passed to or from other methods.} diff --git a/man/residuals.brmultinom.Rd b/man/residuals.brmultinom.Rd index 8a96b63..8b810cf 100644 --- a/man/residuals.brmultinom.Rd +++ b/man/residuals.brmultinom.Rd @@ -24,7 +24,7 @@ Residuals for multinomial logistic regression and adjacent category logit models } \details{ The residuals computed are the residuals from the equivalent -Poisson log-linear model fit, organised in a form that matches the +Poisson log-linear model fit, organized in a form that matches the output of \code{fitted(object, type = "probs")}. As a result, the output is residuals defined in terms of the object and expected multinomial counts. diff --git a/man/stemcell.Rd b/man/stemcell.Rd index 2bcc22e..c606d91 100644 --- a/man/stemcell.Rd +++ b/man/stemcell.Rd @@ -19,7 +19,7 @@ beliefs with levels \code{fundamentalist}, \code{moderate}, }} \source{ -The \code{stemcell} data set is analysed in Agresti (2010, Subsection~4.1.5). +The \code{stemcell} data set is analyzed in Agresti (2010, Subsection~4.1.5). } \usage{ stemcell diff --git a/man/vcov.brglmFit.Rd b/man/vcov.brglmFit.Rd index 4a55de5..a325517 100644 --- a/man/vcov.brglmFit.Rd +++ b/man/vcov.brglmFit.Rd @@ -5,7 +5,7 @@ \title{Return the variance-covariance matrix for the regression parameters in a \code{\link{brglmFit}} object} \usage{ -\method{vcov}{brglmFit}(object, model = c("mean", "full", "dispersion"), ...) +\method{vcov}{brglmFit}(object, model = c("mean", "full", "dispersion"), complete = TRUE, ...) } \arguments{ \item{object}{ @@ -15,6 +15,14 @@ in a \code{\link{brglmFit}} object} \item{model}{character specifying for which component of the model coefficients should be extracted.} +\item{complete}{for the \code{aov}, \code{lm}, \code{glm}, \code{mlm}, and where + applicable \code{summary.lm} etc methods: logical indicating if the + full variance-covariance matrix should be returned also in case of + an over-determined system where some coefficients are undefined and + \code{\link[stats]{coef}(.)} contains \code{NA}s correspondingly. When + \code{complete = TRUE}, \code{vcov()} is compatible with + \code{coef()} also in this singular case.} + \item{...}{ additional arguments for method functions. For the \code{\link[stats]{glm}} method this can be used to pass a @@ -24,3 +32,10 @@ in a \code{\link{brglmFit}} object} Return the variance-covariance matrix for the regression parameters in a \code{\link{brglmFit}} object } +\details{ +The options for \code{model} are \code{"mean"} for mean regression +parameters only (default), \code{"dispersion"} for the dispersion +parameter (or the transformed dispersion; see +\code{\link{brglm_control}}), and \code{"mean"} for both the mean +regression and the (transformed) dispersion parameters. +} diff --git a/tests/testthat/test-separation.R b/tests/testthat/test-separation.R index 6ad056e..28b85df 100644 --- a/tests/testthat/test-separation.R +++ b/tests/testthat/test-separation.R @@ -2,15 +2,15 @@ context("test that detect_separation works as expected") ## endometrial data from Heinze \& Schemper (2002) (see ?endometrial) data("endometrial", package = "brglm2") -endometrial_separation <- glm(HG ~ I(-NV) + PI + EH, data = endometrial, - family = binomial("cloglog"), - method = "detect_separation") +expect_warning(endometrial_separation <- glm(HG ~ I(-NV) + PI + EH, data = endometrial, + family = binomial("cloglog"), + method = "detect_separation")) ## The lizards example from ?brglm::brglm data("lizards", package = "brglm2") -lizards_separation <- glm(cbind(grahami, opalinus) ~ height + diameter + - light + time, family = binomial(logit), data = lizards, - method = "detect_separation") +expect_warning(lizards_separation <- glm(cbind(grahami, opalinus) ~ height + diameter + + light + time, family = binomial(logit), data = lizards, + method = "detect_separation")) test_that("infinte estimates have been found as expected", { diff --git a/tests/testthat/tests-checkinfinite.R b/tests/testthat/tests-checkinfinite.R index b4ca80c..928516f 100644 --- a/tests/testthat/tests-checkinfinite.R +++ b/tests/testthat/tests-checkinfinite.R @@ -7,6 +7,8 @@ expect_warning({ family = binomial("cloglog")) }) +expect_warning(cie <- check_infinite_estimates(endometrial_ml)) + test_that("infinte estimates have been found as expected", { - expect_true(any(check_infinite_estimates(endometrial_ml)[, "I(-NV)"] > 1e+06)) + expect_true(any(cie[, "I(-NV)"] > 1e+06)) }) diff --git a/vignettes/adjacent.Rmd b/vignettes/adjacent.Rmd index da10825..1474e83 100644 --- a/vignettes/adjacent.Rmd +++ b/vignettes/adjacent.Rmd @@ -22,7 +22,7 @@ knitr::opts_chunk$set( ``` # **bracl** -The [**brglm2**](https://github.com/ikosmidis/brglm2) R package provides `bracl` which is a wrapper of `brglmFit` for fitting adjacent category models for ordinal responses using either maximum likelihood or maximum penalized likelihood or any of the various bias reduction methods described in `brglmFit`. There is a formal equivalence between adjacent category logit models for ordinal responses and multinomial logistic regression models (see, e.g. the [Multinomial logistic regression using brglm2](https://cran.r-project.org/package=brglm2/vignettes/multinomial.html) vignette and the `brmultinom` function). `bracl` utilised that equivalence and fits the corresponding Poisson log-linear model, by appropriately re-scaling the Poisson means to match the multinomial totals (a.k.a. the "Poisson trick"). The mathematical details and algorithm on using the Poisson trick for mean-bias reduction are given in @kosmidis:11. +The [**brglm2**](https://github.com/ikosmidis/brglm2) R package provides `bracl` which is a wrapper of `brglmFit` for fitting adjacent category models for ordinal responses using either maximum likelihood or maximum penalized likelihood or any of the various bias reduction methods described in `brglmFit`. There is a formal equivalence between adjacent category logit models for ordinal responses and multinomial logistic regression models (see, e.g. the [Multinomial logistic regression using brglm2](https://cran.r-project.org/package=brglm2/vignettes/multinomial.html) vignette and the `brmultinom` function). `bracl` utilized that equivalence and fits the corresponding Poisson log-linear model, by appropriately re-scaling the Poisson means to match the multinomial totals (a.k.a. the "Poisson trick"). The mathematical details and algorithm on using the Poisson trick for mean-bias reduction are given in @kosmidis:11. diff --git a/vignettes/separation.Rmd b/vignettes/separation.Rmd index 8e63098..925224a 100644 --- a/vignettes/separation.Rmd +++ b/vignettes/separation.Rmd @@ -28,7 +28,7 @@ The key methods are `detect_separation` and `check_infinite_estimates` and this # Checking for infinite estimates -@heinze:02 used a logistic regression model to analyse data from a +@heinze:02 used a logistic regression model to analyze data from a study on endometrial cancer. @agresti:15[, Section 5.7] provide details on the data set. Below, we fit a probit regression model with the same linear predictor as the logistic regression model in @heinze:02.