[R] glm.fit when family argument is not a "family" object

David Winsemius dwinsemius at comcast.net
Mon Feb 23 00:11:53 CET 2015


On Feb 22, 2015, at 1:55 PM, Mathew McLean wrote:

> The documentation for glm/glm.fit indicates that the family argument "can
> be a character string naming a family function, a family function or the
> result of a call to a family function".
> 
> glm.fit(1, 1, family = "gaussian")
> 
> ## Error: $ operator is invalid for atomic vectors
> 
> glm.fit(1, 1, family = gaussian)
> 
> ​## Error: object of type 'closure' is not subsettable
> 
> glm.fit(1, 1, family = gaussian())  # works​, results omitted

It's fairly easy to find near the top of code in `glm` which lines are responsible for doing the lookup for a family object and to see by comparison that such lookup efforts are not in `glm.fit` Users are advised that `glm.fit` is not generally called directly. I think it was expected that people who were doing so, should be able to figure the situation out rather quickly by looking at the code. You might also have noticed that the Usage parameters for glm and glm.fit are different.

-- 
David.
> 
> sessionInfo()
> 
> ## R version 3.1.2 Patched (2015-02-20 r67856)
> ## Platform: x86_64-w64-mingw32/x64 (64-bit)
> ## Running under: Windows 7 x64 (build 7601) Service Pack 1
> 
> ## locale:
> ## [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252
> ## [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
> 
> ## [5] LC_TIME=English_United States.1252
> 
> ## attached base packages:
> ## [1] stats     graphics  grDevices utils     datasets  methods   base
> 
> ## loaded via a namespace (and not attached):
> ## [1] tools_3.1.2
> 
> 
> -- 
> Mathew W. McLean
> Research Assistant Professor
> 


David Winsemius
Alameda, CA, USA



More information about the R-help mailing list