> copies from your system and destroy any hard copies. You must
>
> not, directly or indirectly, use, disclose, distribute,
>
> print or copy any part of this message or any attachments if you are not
>
> the intended recipient.
>
> *From:* William Dunlap [mailto:wdun...@tib
this message or any attachments if you are not
the intended recipient.
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Friday, October 07, 2016 11:57 AM
To: Bos, Roger
Cc: R-help
Subject: Re: [R] weighted regression inside FOREACH loop
Using the temporary child environment works because
Using the temporary child environment works because model.frame, hence lm,
looks for the variables used in the formula, subset, and weights arguments
first in the data argument and then, if the data argument is not an
environment, in the environment of the formula argument.
Bill Dunlap
TIBCO Softw
A more general way is to change the environment of your formula to
a child of its original environment and add variables like 'weights' or
'subset' to the child environment. Since you change the environment
inside a function call it won't affect the formula outside of the function
call.
E.g.
fmla
All,
I figured out how to get it to work, so I am posting the solution in case
anyone is interested. I had to use attr to set the weights as an attribute of
the data object for the linear model. Seems convoluted, but anytime I tried to
pass a named vector as the weights the foreach loop could
Dear Roger,
Maybe you want to return(mod) instead of return(mod$coef)
Best regards,
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgiu
6 matches
Mail list logo