Re: [R] formula and lm

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Fri 16 Jul 2004 - 16:49:37 EST


Hallo

On 15 Jul 2004 at 13:46, solares@unsl.edu.ar wrote:

> Hi, don' t understand why the function fomula have this error, i
> enclose the parameter "a" with the function I() Thank Ruben
> x<-1:5
> y<-c( 2 ,4 , 6 , 8 ,11)
> formu<-y~I(a*x)
> form<-formula(formu)
> dummy<-data.frame(x=x,y=y)
> fm<-lm(form,data=dummy)
> Error in unique(c("AsIs", oldClass(x))) : Object "a" not found

You did not created object "a" before you have done your calculations, as the error message clearly states.

try

a<-5
x<-1:5
y<-c(  2  ,4 , 6 , 8 ,11)

formu<-y~I(a*x)
form<-formula(formu)
dummy<-data.frame(x=x,y=y)
fm<-lm(form,data=dummy)

But if you want to estimate "a" follow previous replies and try to read help page for lm().

formu<-y~x

is probably what you want :-).

Cheers
Petr

>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal@precheza.cz



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 16 17:00:16 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:02 EST