Linear Regression Basics

The first linear regression model I will be making is going to predict the amount of loves (Y) a product receives using the size of the discount (X) (value price – actual price).

I had a few trial and error codes to see what variables would work best with each other and I realized that I wanted to see if the size of the discount had any effect on the customer liking the product more. I had to create the X variable using the code below:

After creating this variable I could now use it in my linear regression model. Below is the code I am using to build my model and create the output summary in R:

This code will build the model Loves = a + b*Difference in Prices, where a is the intercept and b is the slope.

The Output from R is shown below:

From this output we can see that both the intercept and the slope is statistically significant because of the 3 stars placed after the p value. The three stars represent a p value < .05, this means that the chance that I am accepting these values mistakenly is small (<.05). Therefore, these three stars means that I can accept the values for slope and intercept which R has estimated for me.

The model equation is:

Loves = 16570.79 – 165.99*Difference in Price

Thank you for following along and in my next post I will be discussing the meaning of my given intercept and slope.

Leave a comment

Design a site like this with WordPress.com
Get started