Thanks! it worked. this forum is so powerful!

On Tue, Nov 16, 2010 at 12:20 PM, Douglas Bates <ba...@stat.wisc.edu> wrote:

> On Tue, Nov 16, 2010 at 10:30 AM, poko2000 <quan.poko2...@gmail.com>
> wrote:
>
> > Hi I am a newbie in R.
> > I have data with dim of 20.
> > How to use lm if i want to do regression with the whole design matrix? My
> y
> > is the first column.
> > the left are xs.
> > Thanks a lot.
>
> Do you have the data stored in a matrix or in a data frame?  If it is
> in a data frame and the first column is named "y" then you can use a
> call like
>
> lm(y ~ ., mydata)
>
> The '.' on the right hand side of the formula is expanded to a formula
> incorporating of the columns in the data frame except for the
> response.  For example
>
> > summary(lm(Fertility ~ ., swiss))
>
> Call:
> lm(formula = Fertility ~ ., data = swiss)
>
> Residuals:
>     Min       1Q   Median       3Q      Max
> -15.2743  -5.2617   0.5032   4.1198  15.3213
>
> Coefficients:
>                 Estimate Std. Error t value Pr(>|t|)
> (Intercept)      66.91518   10.70604   6.250 1.91e-07
> Agriculture      -0.17211    0.07030  -2.448  0.01873
> Examination      -0.25801    0.25388  -1.016  0.31546
> Education        -0.87094    0.18303  -4.758 2.43e-05
> Catholic          0.10412    0.03526   2.953  0.00519
> Infant.Mortality  1.07705    0.38172   2.822  0.00734
>
> Residual standard error: 7.165 on 41 degrees of freedom
> Multiple R-squared: 0.7067,     Adjusted R-squared: 0.671
> F-statistic: 19.76 on 5 and 41 DF,  p-value: 5.594e-10
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to