[R] Beginning lm

From: <rkevinburton_at_charter.net>
Date: Sat, 26 Jul 2008 08:37:54 -0700


I have ussed lm to generate a basic line correlation:

fit = lm(hours.of.sleep ~ ToSleep)

Note: From "Bayesian Computation with R", Jim Albert, p. 7

I understand the simple y = mx + b line that this fits the data to. Now apparently I don't understand formulas. The documentation indicates that there is an implied "intercept" in the formula so now I want to try and fit the line to a second degree polynomial so I tried:

ft = lm(hours.of.sleep ~ ToSleep ^ 2 + ToSleep)

and I still seem to get results that indicate a slope intercept, y = mx + b, type of fit. Can anyone give me a short tutorial on the formula syntax? I would like to fit the data to 2nd and higher order polynomials, 1 / x, log(x), etc. I am sorry but I could not glean this information from the help page on lm.

Thank you.

Kevin



R-help_at_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. Received on Sat 26 Jul 2008 - 15:44:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 26 Jul 2008 - 18:32:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive