Displaying 2 results from an estimated 2 matches for "wghts".
2009 Jan 25
1
[Fwd: Re: evaluation question]
...ys ago showing that prac1 ( see
> below ) doesn't work. Then someone else sent two different
> ways of fixing it.
> I'm still slightly confused.
<snip>
>
>
> x<-1:10;
> y<-rnorm(10) + x;
>
> # THIS DOES NOT WORK
>
> prac1 <- function( model,wghts){
> lm( model, weights = wghts)
> }
>
> prac1(model = y~x, wghts = rep(1, 10))
tfm:
" the variables are taken from 'environment(formula)', typically
the environment from which 'lm' is called. "
when lm is applied to a model, the variable names used to p...
2009 Jan 14
1
referring to calls in functions
The first program generates an error message and does not execute the
regression of y on x.
x<-1:10;
y<-rnorm(10) + x;
prac <- function( model, wghts ){ lm(model, weights = wghts) }
prac(model = y~x, wghts = rep(1, 10))
But the next program works:
x<-1:10;
y<-rnorm(10) + x;
prac <- function( y, x, wghts ){ lm(y~x, weights = wghts) }
prac(y=y, x=x, wghts = rep(1, 10))
I would be grateful f...