|
R demos
Back to all R demos
Least squares and linear regression
You can try out the functions I used in lectures 8 and 9 to visualise linear (and quadratic) regression fitted by least squares to small data sets entered using the mouse.
- Download this file: regression.R to your computer, and save it (as regression.R)
- Start up R
- In R, using the Source R code command (on the File menu), navigate to the appropriate folder, and select the file regression.R
- Run the demonstration by typing regression()
- You can exit the function by clicking with the mouse below the horizontal axis of the plot.
- Use the mouse to choose the position of the menu
- Subsequent clicks add a data point at the pointer location, and display the least squares linear regression line (as soon as there are enough points for this to be defined)
- To delete a data point, click 'delete' on the menu, then click near the point to be deleted.
- To switch to quadratic regression, click on 'quadratic'
- To switch back to linear regression, click on 'linear'
- To stop, click on 'stop'
|