Stats 155 Class Notes 2012-09-28

Least Squares

Visual fitting a line activity.

Load the software:

fetchData("mLineFit.R")
## Retrieving from http://www.mosaic-web.org/go/datasets/mLineFit.R
## [1] TRUE

Then run it:

mLineFit(width ~ length, data = KidsFeet)

Vary the slope and intercept using the sliders.

QUESTIONS:

Randomizing the Residuals

Fit the model, then construct new data which is the fitted model values plus the residuals shuffled. Fit the same structure of model to the new data. How much do the parameters vary?

There are other possible criteria

Examples:

Do these in the context of a x ~ 1 model. Try different parameters. Use some data with big outliers, e.g. the alder nitrogen fixing variable:

alder = fetchData("alder.csv")
## Retrieving from http://www.mosaic-web.org/go/datasets/alder.csv
densityplot(~SNF, data = alder)

plot of chunk unnamed-chunk-4

Least absolute value leads to the median, minimax leads to the midpoint.

Weekly Quiz