Re: [R] Question about regression without an intercept

2008-12-27 Thread John Fox
ay Shah > Sent: December-26-08 11:09 AM > To: r-help > Subject: [R] Question about regression without an intercept > > Consider this code fragment: > > --- > set.seed(42) > > x <- runif(20)

[R] Question about regression without an intercept

2008-12-27 Thread Ajay Shah
Consider this code fragment: --- set.seed(42) x <- runif(20) y <- 2 + 3*x + rnorm(20) m1 <- lm(y ~ x) m2 <- lm(y ~ -1 + x) summary(m1) summary(m2) cor(y, fitted.values(m1))^2 cor(y, fitted.values(m2))^2