LoslegenKostenlos loslegen

Estimating simple linear regression

Back to our sales dataset, salesData, which is already loaded in the workspace. We saw that the sales in the last three months are strongly positively correlated with the sales in this month. Hence we will start off including that as an explanatory variable in a linear regression.

Diese Übung ist Teil des Kurses

Machine Learning for Marketing Analytics in R

Kurs anzeigen

Anleitung zur Übung

  • Use the lm() function in order to specify a linear regression model using salesLast3Mon as explanatory variable. Assign it to an object salesSimpleModel.

  • Then use the summary() function in order to look at the results.

  • Look at the regression coefficient. Is there a positive or negative relationship between the two variables?

  • About how much of the variation in the sales in this month can be explained by the sales of the previous three months?

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Model specification using lm
salesSimpleModel <- lm(salesThisMon ~ ___, 
                       data = ___)

# Looking at model summary
summary(___)
Code bearbeiten und ausführen