QuasiGLM

Adjust Poisson and Binomial Generalised Linear Models to their quasi equivalents for dispersed data

https://github.com/hendersontrent/quasiglm.jl

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.4%) to scientific vocabulary

Keywords

generalized-linear-models statistical-inference statistical-models statistics
Last synced: 6 months ago · JSON representation

Repository

Adjust Poisson and Binomial Generalised Linear Models to their quasi equivalents for dispersed data

Basic Info
  • Host: GitHub
  • Owner: hendersontrent
  • License: mit
  • Language: Julia
  • Default Branch: main
  • Homepage:
  • Size: 26.4 KB
Statistics
  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Topics
generalized-linear-models statistical-inference statistical-models statistics
Created about 4 years ago · Last pushed almost 4 years ago
Metadata Files
Readme License Citation

README.md

QuasiGLM

DOI

Adjust Poisson and Binomial Generalised Linear Models to their quasi equivalents for dispersed data

Installation

You can install QuasiGLM.jl from the Julia Registry via:

using Pkg Pkg.add("QuasiGLM")

Motivation

R has an excellent interface for specifying generalised linear models (GLM) and its base functionality includes a wide variety of probability distributions and link functions. GLM.jl in Julia is also excellent, and boasts a similar interface to its R counterpart. However, in GLM.jl, two key model types are not readily available:

  1. quasipoisson
  2. quasibinomial

While neither defines an explicit probability distribution, these models are useful in a variety of contexts as they enable the modelling of overdispersion in data. If the data is indeed overdispersed, the estimated dispersion parameter will be >1. Failure to estimate and adjust for this dispersion may lead to inappropriate statistical inference.

QuasiGLM.jl is a simple package that provides intuitive one-line-of-code adjustments to existing Poisson and Binomial GLM.jl models to convert them to their quasi equivalents. It achieves this through estimating the dispersion parameter and using this to make adjustments to standard errors. These adjustments then flow through to updated test statistics, p-values, and confidence intervals.

Usage

Here's a Poisson to quasipoisson conversion using the Dobson (1990) Page 93: Randomized Controlled Trial dataset (as presented in the GLM.jl documentation).

``` using DataFrames, CategoricalArrays, GLM, QuasiGLM

dobson = DataFrame(Counts = [18,17,15,20,10,20,25,13,12], Outcome = categorical([1,2,3,1,2,3,1,2,3]), Treatment = categorical([1,1,1,2,2,2,3,3,3]))

gm = fit(GeneralizedLinearModel, @formula(Counts ~ Outcome + Treatment), dobson, Poisson()) testOutputs = AdjustQuasiGLM(gm, dobson; level=0.95) ```

And here's a binomial to quasibinomial example using the leaf blotch dataset (McCullagh and Nelder (1989, Ch. 9.2.4)) as seen in multiple textbooks and the SAS documentation:

``` using DataFrames, CategoricalArrays, GLM, QuasiGLM

blotchData = DataFrame(blotch = [0.05,0.00,1.25,2.50,5.50,1.00,5.00,5.00,17.50,0.00,0.05,1.25,0.50,1.00,5.00,0.10,10.00,25.00,0.00,0.05,2.50,0.01,6.00,5.00,5.00,5.00,42.50,0.10,0.30,16.60,3.00,1.10,5.00,5.00,5.00,50.00,0.25,0.75,2.50,2.50,2.50,5.00,50.00,25.00,37.50,0.05,0.30,2.50,0.01,8.00,5.00,10.00,75.00,95.00,0.50,3.00,0.00,25.00,16.50,10.00,50.00,50.00,62.50,1.30,7.50,20.00,55.00,29.50,5.00,25.00,75.00,95.00,1.50,1.00,37.50,5.00,20.00,50.00,50.00,75.00,95.00,1.50,12.70,26.25,40.00,43.50,75.00,75.00,75.00,95.00], variety = categorical(repeat([1,2,3,4,5,6,7,8,9], inner=1, outer=10)), site = categorical(repeat([1,2,3,4,5,6,7,8,9,10], inner=9, outer=1)))

blotchData.blotch = blotchData.blotch ./ 100 gm2 = fit(GeneralizedLinearModel, @formula(blotch ~ variety + site), blotchData, Binomial()) testOutputs2 = AdjustQuasiGLM(gm2, blotchData; level=0.95) ```

Comparison to R results

Note that results do not exactly equal the R equivalent of GLMs fit with quasibinomial or quasipoisson families. While explorations are continuing, the discrepancy is believed to be the result of differences in optimisation methods in the GLM machinery and floating point calculations.

For example, in the quasipoisson example presented above, the dispersion parameter returned by QuasiGLM.jl and R's glm function with quasipoisson family are equivalent, and the numerical values for the Intercept and Outcome in the summary coefficient table are also equivalent. However, the Treatment variable exhibits different coefficient estimates despite exhibiting the same standard error and p-values.

Here is the R code to test it:

``` dobson <- data.frame(Counts = c(18,17,15,20,10,20,25,13,12), Outcome = as.factor(c(1,2,3,1,2,3,1,2,3)), Treatment = as.factor(c(1,1,1,2,2,2,3,3,3)))

mod <- glm(Counts ~ Outcome + Treatment, dobson, family = quasipoisson) summary(mod) ```

Citation instructions

If you use QuasiGLM.jl in your work, please cite it using the following (included as BibTeX file in the package folder):

@Manual{QuasiGLM.jl, title={{QuasiGLM.jl}}, author={Henderson, Trent}, year={2022}, month={2}, url={https://zenodo.org/badge/latestdoi/459915317}, doi={10.5281/zenodo.6164674} }

Owner

  • Name: Trent Henderson
  • Login: hendersontrent
  • Kind: user
  • Location: Canberra, Australia
  • Company: Nous Group

Senior data scientist and statistics PhD student. Mostly coding in R, Julia, and Stan. Interested in genetic programming, time series, and data vis

GitHub Events

Total
Last Year

Committers

Last synced: 6 months ago

All Time
  • Total Commits: 16
  • Total Committers: 1
  • Avg Commits per committer: 16.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Trent Henderson t****1@o****m 16

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 4
  • Total pull requests: 6
  • Average time to close issues: 2 days
  • Average time to close pull requests: 2 minutes
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.75
  • Average comments per pull request: 0.0
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • hendersontrent (4)
Pull Request Authors
  • hendersontrent (6)
Top Labels
Issue Labels
documentation (2) question (1)
Pull Request Labels
documentation (1) enhancement (1)

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
juliahub.com: QuasiGLM

Adjust Poisson and Binomial Generalised Linear Models to their quasi equivalents for dispersed data

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 9.9%
Average: 37.7%
Dependent packages count: 38.9%
Stargazers count: 48.5%
Forks count: 53.5%
Last synced: 6 months ago