Re: [R] Passing formula and weights error

2020-08-28 Thread John Smith
Thanks to Duncan and Bill for very helpful tips. On Fri, Aug 28, 2020 at 11:38 AM William Dunlap wrote: > Note that neither call to glm in your myglm function really works - > the first one is using the 'weights' object from the global > environment, not the weights argument. E.g., in the

Re: [R] Passing formula and weights error

2020-08-28 Thread William Dunlap via R-help
Note that neither call to glm in your myglm function really works - the first one is using the 'weights' object from the global environment, not the weights argument. E.g., in the fresh R session, where I avoid making unneeded assignments and use fixed x and y for repeatability, > n <- 16 >

Re: [R] Passing formula and weights error

2020-08-28 Thread Duncan Murdoch
This came up recently in a discussion of lm() on the R-devel list. I'd assume the same issue applies to glm. The problem is that the argument to weights is evaluated in the same way as arguments in the formula: first in data, then in the environment of the formula. The latter will

[R] Passing formula and weights error

2020-08-28 Thread John Smith
Dear R-help: I am writing a function based on glm and would like some variations of weights. In the code below, I couldn't understand why the second glm function fails and don't know how to fix it: Error in eval(extras, data, env) : object 'newweights' not found Calls: print ... eval -> ->