In: Statistics and Probability
> library(ISLR)
> d=Carseats
> head(d)
>model=lm(Sales~CompPrice+Income+Advertising+Population+Price+ShelveLoc+Age+Education+Urban+
US)
> model
Call:
lm(formula = Sales ~ CompPrice + Income + Advertising + Population
+
Price + ShelveLoc + Age + Education + Urban + US)
Coefficients: | ||||||||
(Intercept) | CompPrice | Income | Advertising | Population | Price | ShelveLocGood | ShelveLocMedium | Age |
5.6606231 | 0.0928153 | 0.0158028 | 0.1230951 | 0.0002079 | -0.0953579 | 4.8501827 | 1.9567148 | -0.04605 |
Education | UrbanYes | USYes | ||||||
-0.0211018 | 0.1228864 | -0.1840928 |
Model
Sales=5.6606231+0.0928153CompPrice + 0.0158028Income +
0.1230951Advertising +0.0002079 Population -0.0953579
Price + 4.8501827ShelveLocGood +1.9567148
ShelveLocMedium-0.04605Age -0.0211018 Education + 0.1228864UrbanYes
-0.1840928 USYes
# interaction plot of ShelveLoc and price.
interaction.plot(ShelveLoc,Price,Sales)