[R] get names of glm and related families from an object
Michael Friendly
friendly at yorku.ca
Sat Oct 4 18:45:13 CEST 2014
In a function I'm writing, I want to handle a variety of families of
glm() and related models
including MASS::glm.nb() and hopefully countreg::hurdle(), zeroinfl().
A central part of the function
is a switch() call
family <- object$family$family
switch(family,
"binomial" = {
},
"quasibinomial" = {
},
"poisson" = {
},
"quasipoisson" = {
},
"gaussian" = {
}
)
But I discovered that the object$family$family slot doesn't work the
same way with glm.nb --
I get, e.g.,
> nmes.nbin2$family$family
[1] "Negative Binomial(1.2354)"
and the countreg functions don't return a family component.
I think I have to also use class(object), and a more complicated
computation of family,
but maybe there's a simpler way?
-Michael
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA
More information about the R-help
mailing list