Skip to content

Commit

Permalink
The method for objects can now also handle specifications from with f…
Browse files Browse the repository at this point in the history
…ixed (reported by Christian Kleiber).
  • Loading branch information
zeileis committed May 15, 2024
1 parent 3a359bd commit f867f2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
for vectors of distributions (#101).
- Fixed errors in notation of cumulative distribution function in the documentation of
`HurdlePoisson()` and `HurdleNegativeBinomial()` (by @dkwhu in #94 and #96).
- The `prodist()` method for `glm` objects can now also handle `family` specifications from
`MASS::negative.binomial(theta)` with fixed `theta` (reported by Christian Kleiber).
- Further small improvements in methods and manual pages.


Expand Down
7 changes: 7 additions & 0 deletions R/prodist.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,19 @@ prodist.glm <- function(object, ..., dispersion = NULL) {
size <- if("newdata" %in% names(list(...))) 1L else object$prior.weights
}

## special case: MASS::negative.binomial()
if(startsWith(object$family$family, "Negative Binomial")) {
object$family$family <- "negative.binomial"
phi <- environment(object$family$variance)$.Theta
}

## set up distributions object (if possible)
switch(object$family$family,
"gaussian" = Normal(mu = mu, sigma = sqrt(phi)),
"poisson" = Poisson(lambda = mu),
"binomial" = Binomial(size = size, p = mu),
"Gamma" = distributions3::Gamma(shape = 1/phi, rate = 1/(phi * mu)),
"negative.binomial" = NegativeBinomial(mu = mu, size = phi),
"inverse.gaussian" = stop("inverse Gaussian distributions3 object not implemented yet"), ## FIXME: could use SuppDists for this
"quasi" = stop("quasi family is not associated with a full probability distribution"),
"quasibinomial" = stop("quasi-Poisson family is not associated with a full probability distribution"),
Expand Down

0 comments on commit f867f2c

Please sign in to comment.