Re: [R] simple lm question

2011-12-03 Thread Worik R
> > Please note that your "df" and "M" are undoubtedly different > objects by now: > > Right. Not my most coherent day. thanks W > > M <- matrix(runif(5*20), nrow=20) > > colnames(M) <- c('a', 'b', 'c', 'd', 'e') > > l1 <- lm(e~., data=as.data.frame(M)) > > l1 > > Call: > lm(formula = e ~ .,

Re: [R] simple lm question

2011-12-02 Thread David Winsemius
On Dec 2, 2011, at 11:20 PM, Worik R wrote: Duh! Silly me! But my confusion persits: What is the regression being done? See below Please note that your "df" and "M" are undoubtedly different objects by now: > M <- matrix(runif(5*20), nrow=20) > colnames(M) <- c('a', 'b', 'c',

Re: [R] simple lm question

2011-12-02 Thread Worik R
Duh! Silly me! But my confusion persits: What is the regression being done? See below On Sat, Dec 3, 2011 at 5:10 PM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > In your code by supplying a vector M[,"e"] you are regressing "e" > against all the variables provided in the da

Re: [R] simple lm question

2011-12-02 Thread R. Michael Weylandt
In your code by supplying a vector M[,"e"] you are regressing "e" against all the variables provided in the data argument, including "e" itself -- this gives the very strange regression coefficients you observe. R has no way to know that that's somehow related to the "e" it sees in the data argumen

Re: [R] simple lm question

2011-12-02 Thread Worik R
> > Use `lm` the way it is designed to be used, with a data argument: > > > l2 <- lm(e~. , data=as.data.frame(M)) > > summary(l2) > > Call: > lm(formula = e ~ ., data = as.data.frame(M)) > > And what is the regression being done in this case? How are the independent variables used? It looks like

Re: [R] simple lm question

2011-12-01 Thread David Winsemius
On Dec 1, 2011, at 10:50 PM, Worik R wrote: I really would like to be able to read about this in a document but I cannot find my way around the documentation properly Given the code... M <- matrix(runif(5*20), nrow=20) colnames(M) <- c('a', 'b', 'c', 'd', 'e') ind <- c(1,2,3,4) dep <- 5 I ca

[R] simple lm question

2011-12-01 Thread Worik R
I really would like to be able to read about this in a document but I cannot find my way around the documentation properly Given the code... M <- matrix(runif(5*20), nrow=20) colnames(M) <- c('a', 'b', 'c', 'd', 'e') ind <- c(1,2,3,4) dep <- 5 I can then do... l2 <- lm(M[,dep]~M[,ind]) ## Clearl