Re: [R] First Variable in lm

2004-03-24 Thread Christian Hoffmann
> I want to take the first variable (column) of a data frame and regress > it against all other variables. > > bla <- function (dat) { >reg <- lm(whateverthefirstofthevariablenamesis ~., data=dat) >return(reg) > } > > Thanks to all who answered my question: Prof. Brian Ripley:

RE: [R] First Variable in lm

2004-03-24 Thread Prof Brian Ripley
It isn't lm but terms.formula. Compare terms(dat$y ~ .,data = dat) terms(dat[, 1] ~ ., data = dat) Now as to why, exactly, see the C code in src/main/model.c. The short answer is that dat$y matches y, and dat[, 1] does not. (I am not at all sure the first is intentional.) On Wed, 24 Mar 2004, B

RE: [R] First Variable in lm

2004-03-24 Thread Baskin, Robert
la = dat$y ~ ., data = dat) Curious Minds Want to Know Bob -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 24, 2004 12:51 PM To: [EMAIL PROTECTED] Subject: Re: [R] First Variable in lm Christian Hoffmann wsl.ch> writes: > > Hi all

Re: [R] First Variable in lm

2004-03-24 Thread Gabor Grothendieck
Christian Hoffmann wsl.ch> writes: > > Hi all, > > I just cannot think of how to do it: > I want to take the first variable (column) of a data frame and regress > it against all other variables. > > bla <- function (dat) { >reg <- lm(whateverthefirstofthevariablenamesis ~., data=dat) >

Re: [R] First Variable in lm

2004-03-24 Thread Prof Brian Ripley
On Wed, 24 Mar 2004, Christian Hoffmann wrote: > Hi all, > > I just cannot think of how to do it: > I want to take the first variable (column) of a data frame and regress > it against all other variables. > > bla <- function (dat) { >reg <- lm(whateverthefirstofthevariablenamesis ~., data=d

RE: [R] First Variable in lm

2004-03-24 Thread Liaw, Andy
You might be trying too hard: > dat <- data.frame(y=rnorm(10), x1=rnorm(10), x2=rnorm(10)) > fit <- lm(dat) > summary(fit) Call: lm(formula = dat) Residuals: Min 1Q Median 3Q Max -1.11643 -0.42746 -0.01442 0.55902 1.04890 Coefficients: Estimate Std. Error

[R] First Variable in lm

2004-03-24 Thread Christian Hoffmann
Hi all, I just cannot think of how to do it: I want to take the first variable (column) of a data frame and regress it against all other variables. bla <- function (dat) { reg <- lm(whateverthefirstofthevariablenamesis ~., data=dat) return(reg) } What kind of function do I have to take inste