Re: [R] weighted regression inside FOREACH loop

2016-10-07 Thread William Dunlap via R-help
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...@tibco

Re: [R] weighted regression inside FOREACH loop

2016-10-07 Thread Bos, Roger
of 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

Re: [R] weighted regression inside FOREACH loop

2016-10-07 Thread William Dunlap via R-help
1:100+rnorm(100)) >> attr(datdf, "weights") <- rep(c(1,2), 50) >> mod <- lm(fmla, data=datdf, weights=attr(data, "weights")) >> return(mod$coef) >> } >> Models >> >> >> >> >> >> -Original Message-

Re: [R] weighted regression inside FOREACH loop

2016-10-07 Thread William Dunlap via R-help
;weights") <- rep(c(1,2), 50) > mod <- lm(fmla, data=datdf, weights=attr(data, "weights")) > return(mod$coef) > } > Models > > > > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bos, Roger &g

Re: [R] weighted regression inside FOREACH loop

2016-10-07 Thread Bos, Roger
ssage- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bos, Roger Sent: Friday, October 07, 2016 9:25 AM To: R-help Subject: [R] weighted regression inside FOREACH loop I have a foreach loop that runs regressions in parallel and works fine, but when I try to add the weights par

Re: [R] weighted regression inside FOREACH loop

2016-10-07 Thread Thierry Onkelinx
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

[R] weighted regression inside FOREACH loop

2016-10-07 Thread Bos, Roger
I have a foreach loop that runs regressions in parallel and works fine, but when I try to add the weights parameter to the regression the coefficients don’t get stored in the “models” variable like they are supposed to. Below is my reproducible example: library(doParallel) cl <-