Linear Regression in R
Last Updated on August 15, 2020
In this post you will discover 4 recipes for linear regression for the R platform.
You can copy and paste the recipes in this post to make a jump-start on your own problem or to learn and practice with linear regression in R.
Kick-start your project with my new book Machine Learning Mastery With R, including step-by-step tutorials and the R source code files for all examples.
Let’s get started.
Each example in this post uses the longley dataset provided in the datasets package that comes with R. The longley dataset describes 7 economic variables observed from 1947 to 1962 used to predict the number of people employed yearly.
Ordinary Least Squares Regression
Ordinary Least Squares (OLS) regression is a linear model that seeks to find a set of coefficients for a line/hyper-plane that minimise the sum of the squared errors.