On Tue, Jan 27, 2009 at 1:38 PM, Wacek Kusnierczyk
<waclaw.marcin.kusnierc...@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

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to