Simple Linear Regression Tutorial

From SOCR
Jump to: navigation, search

SOCR_EduMaterials_AnalysesActivities - Simple Linear Regression Tutorial

Simple Linear Regression Tutorial Using LA Neighborhoods Data

Data: We will be using the LA Neighborhoods Data for this tutorial.

Goal: Our goal is to predict the median income using one explanatory variable by using SOCR. In this example, we will use the age variable.

Step 1: First, we will import the data into the SOCR Simple Regression Analysis Activity. Head to LA Neighborhoods Dataand find the table with the data. Select all of the data, and press Ctrl+C (Command+C on Macs) to copy it.

Step 2: Next, head to http://socr.ucla.edu/htmls/SOCR_Analyses.html, and find the Simple Regression Analysis Activity in the drop-down menu.

Error creating thumbnail: File missing

Step 3: Now Click the “PASTE” button under the drop down menu. You should now see the data in the window.

Error creating thumbnail: File missing

Step 4: Click on the “MAPPING” tab. This is where we define our dependent and independent variables. The dependent variable is the one we want to make a prediction on, and the independent variable is the one which we will use to make the prediction. In this example, we add Income to the dependent variable list and Age to the independent variable list.

Error creating thumbnail: File missing

Step 5: Click “CALCULATE”. You will now be taken to the “RESULTS” tab.

Error creating thumbnail: File missing

Here you can see the regression equation, \(R^2\), individual residuals, and also mean and standard deviation for both variables.


Step 6: Click “GRAPH”. Here is the scatterplot of Income vs Age. We see the upward trend: As median age increases, so does median household income.

Error creating thumbnail: File missing

There are also residual plots

Error creating thumbnail: File missing

and the Normal-QQ Plot.

Error creating thumbnail: File missing

Step 7: We want to check that the assumptions of linear regression, and make sure that they are met.

Assumption 1: There is a linear relationship between the independent (age) and dependent variable (income)

  • How to check: Make a scatter plot of income and age
  • How to fix: Transformations (for example Log(y) vs x), or the relationship is not linear.

Assumption Met

Assumption 2: The variance is constant

  • How to check: Look at plot of residuals vs. predicted values. Make sure there is not a pattern, such as the residuals getting larger as the predicted values increase.
  • How to fix: Logging of variables, fixing underlying independence or linearity causes.

Slight increase of residuals at the high end of age

Assumption 3: Errors are normally distributed

  • How to check: Normal QQ Plot (Should lie close to straight line)
  • How to fix: Take out outliers, if applicable. Non-linear transformation may be needed

Assumption Met

Conclusions

No major violation of linear regression assumptions, we proceed with our analysis:

We can see from the results tab that the regression equation is:

Error creating thumbnail: File missing

Income = -74549.596 + 4096.055 age

Income is the predicted value, -74549.596 is the intercept, 4096.055 is the slope, and age is the independent variable.

The linear model states that for every 1 year increase in median age, the median household income will increase by $4,096.06.




Translate this page:

(default)
Uk flag.gif

Deutsch
De flag.gif

Español
Es flag.gif

Français
Fr flag.gif

Italiano
It flag.gif

Português
Pt flag.gif

日本語
Jp flag.gif

България
Bg flag.gif

الامارات العربية المتحدة
Ae flag.gif

Suomi
Fi flag.gif

इस भाषा में
In flag.gif

Norge
No flag.png

한국어
Kr flag.gif

中文
Cn flag.gif

繁体中文
Cn flag.gif

Русский
Ru flag.gif

Nederlands
Nl flag.gif

Ελληνικά
Gr flag.gif

Hrvatska
Hr flag.gif

Česká republika
Cz flag.gif

Danmark
Dk flag.gif

Polska
Pl flag.png

România
Ro flag.png

Sverige
Se flag.gif