{"id":28427136,"url":"https://github.com/ikosmidis/brglm2","last_synced_at":"2025-06-24T21:31:20.803Z","repository":{"id":44415125,"uuid":"62118550","full_name":"ikosmidis/brglm2","owner":"ikosmidis","description":"Estimation and inference from generalized linear models using explicit and implicit methods for bias reduction","archived":false,"fork":false,"pushed_at":"2024-09-12T18:31:17.000Z","size":2643,"stargazers_count":31,"open_issues_count":6,"forks_count":11,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-06-02T20:24:55.729Z","etag":null,"topics":["adjusted-score-equations","algorithms","bias-reducing-adjustments","bias-reduction","estimation","glm","logistic-regression","nominal-responses","ordinal-responses","r","regression","regression-algorithms","rstats","statistics"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ikosmidis.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-06-28T07:11:33.000Z","updated_at":"2025-05-29T14:18:07.000Z","dependencies_parsed_at":"2023-02-18T19:31:24.002Z","dependency_job_id":"c702987e-725a-451f-b884-c51fabf4fbaa","html_url":"https://github.com/ikosmidis/brglm2","commit_stats":{"total_commits":555,"total_committers":5,"mean_commits":111.0,"dds":"0.13153153153153152","last_synced_commit":"f748bc9f097e2d205b0227bfd21543df2c94914a"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ikosmidis/brglm2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikosmidis%2Fbrglm2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikosmidis%2Fbrglm2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikosmidis%2Fbrglm2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikosmidis%2Fbrglm2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikosmidis","download_url":"https://codeload.github.com/ikosmidis/brglm2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikosmidis%2Fbrglm2/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261759092,"owners_count":23205494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adjusted-score-equations","algorithms","bias-reducing-adjustments","bias-reduction","estimation","glm","logistic-regression","nominal-responses","ordinal-responses","r","regression","regression-algorithms","rstats","statistics"],"created_at":"2025-06-05T12:00:48.954Z","updated_at":"2025-06-24T21:31:20.783Z","avatar_url":"https://github.com/ikosmidis.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\n# brglm2 \u003cimg src=\"man/figures/hex_brglm2.svg\" width=\"320\" align=\"right\"\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/brglm2)](https://cran.r-project.org/package=brglm2)\n[![R-CMD-check](https://github.com/ikosmidis/brglm2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ikosmidis/brglm2/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/ikosmidis/brglm2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/ikosmidis/brglm2?branch=master)\n[![Licence](https://img.shields.io/badge/licence-GPL--3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html)\n\u003c!-- badges: end --\u003e\n\n\n\n[**brglm2**](https://github.com/ikosmidis/brglm2) provides tools for\nthe estimation and inference from generalized linear models using\nvarious methods for bias reduction. **brglm2** supports all\ngeneralized linear models supported in R, and provides methods for\nmultinomial logistic regression (nominal responses), adjacent category\nmodels (ordinal responses), and negative binomial regression (for\npotentially overdispered count responses).\n\nReduction of estimation bias is achieved by solving either the\nmean-bias reducing adjusted score equations in [Firth\n(1993)](https://doi.org/10.1093/biomet/80.1.27) and [Kosmidis \u0026 Firth\n(2009)](https://doi.org/10.1093/biomet/asp055) or the median-bias\nreducing adjusted score equations in [Kenne et al\n(2017)](https://doi.org/10.1093/biomet/asx046), or through the direct\nsubtraction of an estimate of the bias of the maximum likelihood\nestimator from the maximum likelihood estimates as prescribed in\n[Cordeiro and McCullagh\n(1991)](https://www.jstor.org/stable/2345592). [Kosmidis et al\n(2020)](https://doi.org/10.1007/s11222-019-09860-6) provides a\nunifying framework and algorithms for mean and median bias reduction\nfor the estimation of generalized linear models.\n\nIn the special case of generalized linear models for binomial and\nmultinomial responses (both ordinal and nominal), the adjusted score\nequations return estimates with improved frequentist properties, that\nare also always finite, even in cases where the maximum likelihood\nestimates are infinite (e.g. complete and quasi-complete\nseparation). See, [Kosmidis \u0026 Firth\n(2021)](https://doi.org/10.1093/biomet/asaa052) for the proof of the\nlatter result in the case of mean bias reduction for logistic\nregression (and, for more general binomial-response models where the\nlikelihood is penalized by a power of the Jeffreys' invariant prior).\n\nThe core model fitters are implemented by the functions `brglm_fit()`\n(univariate generalized linear models), `brmultinom()` (baseline\ncategory logit models for nominal multinomial responses), `bracl()`\n(adjacent category logit models for ordinal multinomial responses),\nand `brnb()` for negative binomial regression.\n\n\n## Installation\n\nInstall the current version from CRAN:\n\n```r\ninstall.packages(\"brglm2\")\n```\n\nor the development version from github:\n\n```r\n# install.packages(\"remotes\")\nremotes::install_github(\"ikosmidis/brglm2\", ref = \"develop\")\n```\n\n## Example\n\n### Estimation of binomial-response GLMs with separated data\n\nBelow we follow the example of [Heinze and Schemper\n(2002)](https://doi.org/10.1002/sim.1047) and fit a logistic\nregression model using maximum likelihood (ML) to analyze data from a\nstudy on endometrial cancer (see `?brglm2::endometrial` for details\nand references).\n\n```{r, echo = TRUE, eval = TRUE}\nlibrary(\"brglm2\")\ndata(\"endometrial\", package = \"brglm2\")\nmodML \u003c- glm(HG ~ NV + PI + EH, family = binomial(\"logit\"), data = endometrial)\nsummary(modML)\n```\n\nThe ML estimate of the parameter for `NV` is\nactually infinite, as can be quickly verified using the\n[**detectseparation**](https://cran.r-project.org/package=detectseparation) R package\n```{r, echo = TRUE, eval = TRUE}\n# install.packages(\"detectseparation\")\nlibrary(\"detectseparation\")\nupdate(modML, method = \"detect_separation\")\n```\n\nThe reported, apparently finite estimate `r\nround(coef(summary(modML))[\"NV\", \"Estimate\"], 3)` for `NV` is merely\ndue to false convergence of the iterative estimation procedure for\nML. The same is true for the estimated standard error, and, hence the\nvalue `r round(coef(summary(modML))[\"NV\", \"z value\"], 3)` for the\n$z$-statistic cannot be trusted for inference on the size of the\neffect for `NV`.\n\nAs mentioned earlier, many of the estimation methods implemented in\n**brglm2** not only return estimates with improved frequentist\nproperties (e.g. asymptotically smaller mean and median bias than what\nML typically delivers), but also estimates and estimated standard\nerrors that are always finite in binomial (e.g. logistic, probit, and\ncomplementary log-log regression) and multinomial regression models\n(e.g. baseline category logit models for nominal responses, and\nadjacent category logit models for ordinal responses). For example,\nthe code chunk below refits the model on the endometrial cancer study\ndata using mean bias reduction.\n\n```{r, echo = TRUE, eval = TRUE}\nsummary(update(modML, method = \"brglm_fit\"))\n```\n\nA quick comparison of the output from mean bias reduction to that from\nML reveals a dramatic change in the $z$-statistic for `NV`, now that\nestimates and estimated standard errors are finite. In particular, the\nevidence against the null of `NV` not contributing to the model in the\npresence of the other covariates being now stronger.\n\nSee `?brglm_fit` and `?brglm_control` for more examples and the other\nestimation methods for generalized linear models, including median\nbias reduction and maximum penalized likelihood with Jeffreys' prior\npenalty. Also do not forget to take a look at the vignettes\n(`vignette(package = \"brglm2\")`) for details and more case studies.\n\n### Improved estimation of the exponential of regression parameters\n\nSee, also `?expo` for a method to estimate the exponential of\nregression parameters, such as odds ratios from logistic regression\nmodels, while controlling for other covariate information. Estimation\ncan be performed using maximum likelihood or various estimators with\nsmaller asymptotic mean and median bias, that are also guaranteed to\nbe finite, even if the corresponding maximum likelihood estimates are\ninfinite. For example, `modML` is a logistic regression fit, so the\nexponential of each coefficient is an odds ratio while controlling for\nother covariates. To estimate those odds ratios using the\n`correction*` method for mean bias reduction (see `?expo` for details)\nwe do\n\n```{r, echo = TRUE, eval = TRUE}\nexpoRB \u003c- expo(modML, type = \"correction*\")\nexpoRB\n```\n\nThe odds ratio between presence of neovasculation and high histology\ngrade (`HG`) is estimated to be `r round(coef(expoRB)[\"NV\"], 3)`, while\ncontrolling for PI and EH. So, for each value of `PI` and `EH`, the\nestimated odds of high histology grade are about `r round(coef(expoRB)[\"NV\"], 1)` times higher when neovasculation is present. An approximate 95\\% interval for the latter odds ratio is \n`r paste0(\"(\", paste(round(expoRB$ci[\"NV\",], 1), collapse = \", \"), \")\")`\nproviding evidence of association between `NV` and `HG` while\ncontrolling for `PI` and `EH`. Note here that, the maximum likelihood estimate of the odds ratio is not as useful as the `correction*` estimate, because it is $+\\infty$ with an infinite standard error (see previous section). \n\n## Solving adjusted score equations using quasi-Fisher scoring\n\nThe workhorse function in **brglm2** is\n[`brglm_fit`](https://github.com/ikosmidis/brglm2/blob/master/R/brglmFit.R)\n(or equivalently `brglmFit` if you like camel case), which, as we did\nin the example above, can be passed directly to the `method` argument\nof the `glm` function. `brglm_fit` implements a quasi [Fisher\nscoring](https://en.wikipedia.org/wiki/Scoring_algorithm) procedure,\nwhose special cases result in a range of explicit and implicit bias\nreduction methods for generalized linear models for more\ndetails). Bias reduction for multinomial logistic regression (nominal\nresponses) can be performed using the function `brmultinom`, and for\nadjacent category models (ordinal responses) using the function\n`bracl`. Both `brmultinom` and `bracl` rely on `brglm_fit`.\n\nThe [iteration\nvignette](https://cran.r-project.org/package=brglm2/vignettes/iteration.html)\nand [Kosmidis et al\n(2020)](https://doi.org/10.1007/s11222-019-09860-6) present the\niteration and give mathematical details for the bias-reducing\nadjustments to the score functions for generalized linear models.\n\nThe classification of bias reduction methods into explicit and\nimplicit is as given in [Kosmidis\n(2014)](https://doi.org/10.1002/wics.1296).\n\n## References and resources\n\n**brglm2** was presented by [Ioannis\nKosmidis](https://www.ikosmidis.com) at the useR! 2016 international\nconference at University of Stanford on 16 June 2016. The presentation\nwas titled \"Reduced-bias inference in generalized linear models\".\n\nMotivation, details and discussion on the methods that **brglm2** implements are provided in\n\nKosmidis, I, Kenne Pagui, E C, Sartori N. (2020). Mean and median bias reduction in generalized linear models. [*Statistics and Computing*](https://doi.org/10.1007/s11222-019-09860-6) *30*, 43–59.\n\n## Code of Conduct\n\nPlease note that the **brglm2** project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikosmidis%2Fbrglm2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikosmidis%2Fbrglm2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikosmidis%2Fbrglm2/lists"}