Mathew McLean
2015-Feb-22 21:55 UTC
[R] glm.fit when family argument is not a "family" object
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 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 462 Blocker Building Texas A&M University www.stat.tamu.edu/~mmclean [[alternative HTML version deleted]]
Bert Gunter
2015-Feb-22 22:46 UTC
[R] glm.fit when family argument is not a "family" object
... But glm(1~1, family = gaussian) ## works. As does family = "gaussian" (R 3.1.2 ) Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Sun, Feb 22, 2015 at 1:55 PM, Mathew McLean <mmclean at stat.tamu.edu> 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 > > 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 > 462 Blocker Building > Texas A&M University > www.stat.tamu.edu/~mmclean > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
David Winsemius
2015-Feb-22 23:11 UTC
[R] glm.fit when family argument is not a "family" object
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 omittedIt'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
Bert Gunter
2015-Feb-22 23:57 UTC
[R] glm.fit when family argument is not a "family" object
Exactly. Just a matter of fixing the glm.fit Help page. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Sun, Feb 22, 2015 at 3:11 PM, David Winsemius <dwinsemius at comcast.net> wrote:> > 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 > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.