next up previous
Link to Statistics and Actuarial Science main page
Next: Scatterplots and Correlation Up: Some Rweb Notes Previous: Scatterplots

Correlation and Least-Squares Regression

The command cor computes correlations. The correlation of our height and weight variables is computed by
The command lm (whort for Linear Model) fits a least squares regression. Use the following command to fit a regression with weight as the response variable and height as the explanatory variable:
The slope of this line is $ b = r * s_y / s_x$; you can check this with the command
The intercept is $ a = \overline{y} - a \overline{x}$:
Using the least squares line, the weights we would predict for the observed heights are computed by
The residuals can then be computes as Computing the residuals:
Try some examples of your own in the work area below.

Work Area
Enter your own commands here; then click the Submit button.

next up previous
Link to Statistics and Actuarial Science main page
Next: Scatterplots and Correlation Up: Some Rweb Notes Previous: Scatterplots
Luke Tierney 2006-08-23