[R] [Fwd: Re: evaluation question]
Gabor Grothendieck
ggrothendieck at gmail.com
Tue Jan 27 19:56:36 CET 2009
On Tue, Jan 27, 2009 at 1:38 PM, Wacek Kusnierczyk
<Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
> Gabor Grothendieck wrote:
>> It looks in data and if not found there in environment(formula)
>> so try this:
>>
>> mylm <- function(model, wghts) {
>> lm(model, data.frame(wghts), weights = wghts)
>> }
>>
>
> won't help, i'm afraid:
>
> wghts = 1:10
> y = rnorm(10)
>
> lm(y~wghts, weights=rep(1,10))
> mylm(y~wghts, rep(1,10))
The question was about the weights=
argument, not about the formula and
answering the original and not the changed
question, we see they are the same:
> mylm(y ~ seq(10), wghts)
Call:
lm(formula = model, data = data.frame(wghts), weights = wghts)
Coefficients:
(Intercept) seq(10)
-0.7439 0.1522
> lm(y ~ seq(10), weights = wghts)
Call:
lm(formula = y ~ seq(10), weights = wghts)
Coefficients:
(Intercept) seq(10)
-0.7439 0.1522
More information about the R-help
mailing list