multiple_regression_examples
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
multiple_regression_examples [2019/11/01 12:32] – hkimscil | multiple_regression_examples [2020/07/06 13:01] – [E.g. 1] hkimscil | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Multiple Regression with Two Predictor Variables ====== | + | ====== Multiple Regression |
+ | ====== E.g. 1 ====== | ||
+ | {{: | ||
+ | < | ||
+ | d.yyk <- read.csv(" | ||
+ | d.yyk | ||
+ | d.yyk <- subset(d.yyk, | ||
+ | d.yyk | ||
+ | </ | ||
+ | < | ||
+ | > d.yyk <- subset(d.yyk, | ||
+ | > d.yyk | ||
+ | bmi stress happiness | ||
+ | 1 15.1 2 4 | ||
+ | 2 15.3 2 4 | ||
+ | 3 16.4 1 5 | ||
+ | 4 16.3 2 4 | ||
+ | 5 17.5 2 3 | ||
+ | 6 18.8 2 4 | ||
+ | 7 19.2 2 3 | ||
+ | 8 20.3 1 4 | ||
+ | 9 21.3 1 4 | ||
+ | 10 21.3 2 4 | ||
+ | 11 22.4 2 5 | ||
+ | 12 23.5 2 5 | ||
+ | 13 23.7 2 4 | ||
+ | 14 24.2 3 3 | ||
+ | 15 24.3 3 3 | ||
+ | 16 25.6 2 3 | ||
+ | 17 26.4 3 3 | ||
+ | 18 26.4 3 2 | ||
+ | 19 26.4 3 2 | ||
+ | 20 27.5 3 3 | ||
+ | 21 28.6 3 2 | ||
+ | 22 28.2 4 2 | ||
+ | 23 31.3 3 2 | ||
+ | 24 32.1 4 1 | ||
+ | 25 33.1 4 1 | ||
+ | 26 33.2 5 1 | ||
+ | 27 34.4 5 1 | ||
+ | 28 35.8 5 1 | ||
+ | 29 36.1 5 1 | ||
+ | 30 38.1 5 1 | ||
+ | </ | ||
+ | 우선 여기에서 종속변인인 (dv) happiness에 bmi와 stress를 리그레션 해본다. | ||
+ | < | ||
+ | attach(d.yyk) | ||
+ | lm.happiness.bmistress <- lm(happiness ~ bmi + stress, data=d.yyk) | ||
+ | summary(lm.happiness.bmistress) | ||
+ | anova(lm.happiness.bmistress) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > attach(d.yyk) | ||
+ | > lm.happiness.bmistress <- lm(happiness ~ bmi + stress, data=d.yyk) | ||
+ | > summary(lm.happiness.bmistress) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = happiness ~ bmi + stress, data = d.yyk) | ||
+ | |||
+ | Residuals: | ||
+ | | ||
+ | -0.89293 -0.40909 | ||
+ | |||
+ | Coefficients: | ||
+ | Estimate Std. Error t value Pr(> | ||
+ | (Intercept) | ||
+ | bmi | ||
+ | stress | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 0.5869 on 27 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | > | ||
+ | > | ||
+ | > anova(lm.happiness.bmistress) | ||
+ | Analysis of Variance Table | ||
+ | |||
+ | Response: happiness | ||
+ | Df Sum Sq Mean Sq F value Pr(> | ||
+ | bmi 1 38.603 | ||
+ | stress | ||
+ | Residuals 27 9.300 | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | |||
+ | </ | ||
+ | |||
+ | 위의 분석을 보면 | ||
+ | R< | ||
+ | |||
+ | 그러나, coefficient 값을 보면 bmi는 significant 하지 않고, stress는 significant하다. 이는 R제곱에 영향을 주는 것으로 stress가 주이고 bmi의 영향력은 미미하다고 하다는 결론을 내리도록 해준다. 그러나, [[:multiple regression]]에서 언급한 것처럼 독립변인이 두 개 이상일 때에는 무엇이 얼마나 종속변인에 영향을 주는지 그림을 그릴 수 있어야 하므로, 아래와 같이 bmi만을 가지고 regression을 다시 해본다. | ||
+ | |||
+ | < | ||
+ | lm.happiness.bmi <- lm(happiness ~ bmi, data=d.yyk) | ||
+ | summary(lm.happiness.bmi) | ||
+ | anova(lm.happiness.bmi) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > lm.happiness.bmi <- lm(happiness ~ bmi, data=d.yyk) | ||
+ | > | ||
+ | > summary(lm.happiness.bmi) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = happiness ~ bmi, data = d.yyk) | ||
+ | |||
+ | Residuals: | ||
+ | | ||
+ | -1.20754 -0.49871 -0.03181 | ||
+ | |||
+ | Coefficients: | ||
+ | Estimate Std. Error t value Pr(> | ||
+ | (Intercept) | ||
+ | bmi | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 0.696 on 28 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | |||
+ | > anova(lm.happiness.bmi) | ||
+ | Analysis of Variance Table | ||
+ | |||
+ | Response: happiness | ||
+ | Df Sum Sq Mean Sq F value Pr(> | ||
+ | bmi 1 38.603 | ||
+ | Residuals 28 13.564 | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | </ | ||
+ | 놀랍게도 bmi 하나만을 가지고 regression을 했더니, R제곱 값이 .74이었다 (F(1,28) = 79.69, p = 1.109e-09). 이런 결과가 나올 수 있는 이유는 독립변인인 bmi와 stress 간의 상관관계가 높아서 처음 분석에서 그 영향력을 (설명력, R제곱에 기여하는 부분을) 하나의 독립변인이 모두 가졌갔기 때문이라고 생각할 수 있다. 이 경우에는 그 독립변인이 stress이다. | ||
+ | |||
+ | happiness에 stress 만을 regression 해본 결과는 아래와 같다. | ||
+ | |||
+ | < | ||
+ | lm.happiness.stress <- lm(happiness ~ stress, data = d.yyk) | ||
+ | summary(lm.happiness.stress) | ||
+ | anova(lm.happiness.stress) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > lm.happiness.stress <- lm(happiness ~ stress, data = d.yyk) | ||
+ | > summary(lm.happiness.stress) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = happiness ~ stress, data = d.yyk) | ||
+ | |||
+ | Residuals: | ||
+ | Min 1Q Median | ||
+ | -0.7449 -0.6657 | ||
+ | |||
+ | Coefficients: | ||
+ | Estimate Std. Error t value Pr(> | ||
+ | (Intercept) | ||
+ | stress | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 0.6044 on 28 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | |||
+ | > anova(lm.happiness.stress) | ||
+ | Analysis of Variance Table | ||
+ | |||
+ | Response: happiness | ||
+ | Df Sum Sq Mean Sq F value Pr(> | ||
+ | stress | ||
+ | Residuals 28 10.229 | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | > | ||
+ | </ | ||
+ | ====== | ||
data file: {{: | data file: {{: | ||
Line 611: | Line 791: | ||
====== e.g., ====== | ====== e.g., ====== | ||
+ | < | ||
+ | library(ISLR) | ||
+ | head(Carseats) | ||
+ | str(Carseats) | ||
+ | |||
+ | lm.full <- lm(Sales ~ . , data = Carseats) | ||
+ | lm.null <- lm(Sales ~ 1 , data = Carseats) | ||
+ | |||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
< | < | ||
> stepAIC(lm.full) | > stepAIC(lm.full) | ||
Line 700: | Line 892: | ||
> | > | ||
</ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP half column> | ||
+ | < | ||
+ | > step(lm.full, | ||
+ | Start: | ||
+ | Sales ~ CompPrice + Income + Advertising + Population + Price + | ||
+ | ShelveLoc + Age + Education + Urban + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Population | ||
+ | - Education | ||
+ | - Urban 1 1.23 404.06 | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.44 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=25.15 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + Education + Urban + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Urban 1 1.15 404.31 | ||
+ | - Education | ||
+ | - US | ||
+ | < | ||
+ | + Population | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 218.52 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=24.29 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + Education + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Education | ||
+ | - US | ||
+ | < | ||
+ | + Urban 1 1.15 403.16 | ||
+ | + Population | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.59 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=23.72 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - US | ||
+ | < | ||
+ | + Education | ||
+ | + Urban 1 1.24 404.52 | ||
+ | + Population | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.97 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=23.32 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age | ||
+ | |||
+ | Df Sum of Sq | ||
+ | < | ||
+ | + US | ||
+ | + Education | ||
+ | + Urban 1 1.19 406.20 | ||
+ | + Population | ||
+ | - Income | ||
+ | - Age 1 219.12 | ||
+ | - Advertising | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Call: | ||
+ | lm(formula = Sales ~ CompPrice + Income + Advertising + Price + | ||
+ | ShelveLoc + Age, data = Carseats) | ||
+ | |||
+ | Coefficients: | ||
+ | (Intercept) | ||
+ | 5.47523 | ||
+ | Price ShelveLocGood | ||
+ | | ||
+ | |||
+ | > | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | < | ||
+ | Start: | ||
+ | Sales ~ CompPrice + Income + Advertising + Population + Price + | ||
+ | ShelveLoc + Age + Education + Urban + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Population | ||
+ | - Education | ||
+ | - Urban 1 1.23 404.06 | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.44 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=25.15 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + Education + Urban + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Urban 1 1.15 404.31 | ||
+ | - Education | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 218.52 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=24.29 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + Education + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Education | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.59 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=23.72 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.97 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=23.32 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age | ||
+ | |||
+ | Df Sum of Sq | ||
+ | < | ||
+ | - Income | ||
+ | - Age 1 219.12 | ||
+ | - Advertising | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Call: | ||
+ | lm(formula = Sales ~ CompPrice + Income + Advertising + Price + | ||
+ | ShelveLoc + Age, data = Carseats) | ||
+ | |||
+ | Coefficients: | ||
+ | (Intercept) | ||
+ | 5.47523 | ||
+ | ShelveLocGood | ||
+ | 4.83567 | ||
+ | |||
+ | > </ | ||
+ | </ | ||
+ | |||
+ | <WRAP half column> | ||
+ | < | ||
+ | Start: | ||
+ | Sales ~ CompPrice + Income + Advertising + Population + Price + | ||
+ | ShelveLoc + Age + Education + Urban + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Population | ||
+ | - Education | ||
+ | - Urban 1 1.23 404.06 | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.44 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=25.15 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + Education + Urban + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Urban 1 1.15 404.31 | ||
+ | - Education | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 218.52 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=24.29 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + Education + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - Education | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.59 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=23.72 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + US | ||
+ | |||
+ | Df Sum of Sq | ||
+ | - US | ||
+ | < | ||
+ | - Income | ||
+ | - Advertising | ||
+ | - Age 1 217.97 | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Step: AIC=23.32 | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age | ||
+ | |||
+ | Df Sum of Sq | ||
+ | < | ||
+ | - Income | ||
+ | - Age 1 219.12 | ||
+ | - Advertising | ||
+ | - CompPrice | ||
+ | - ShelveLoc | ||
+ | - Price 1 | ||
+ | |||
+ | Call: | ||
+ | lm(formula = Sales ~ CompPrice + Income + Advertising + Price + | ||
+ | ShelveLoc + Age, data = Carseats) | ||
+ | |||
+ | Coefficients: | ||
+ | (Intercept) | ||
+ | 5.47523 | ||
+ | ShelveLocGood | ||
+ | 4.83567 | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | ===== Pick the model from stepAIC ===== | ||
+ | < | ||
+ | lm.fit.01 <- lm(formula = Sales ~ | ||
+ | | ||
+ | | ||
+ | | ||
+ | data = Carseats) | ||
+ | summary(lm.fit.01) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > lm.fit.01 <- lm(formula = Sales ~ CompPrice + | ||
+ | | ||
+ | | ||
+ | > summary(lm.fit.01) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = Sales ~ CompPrice + Income + Advertising + Price + | ||
+ | ShelveLoc + Age, data = Carseats) | ||
+ | |||
+ | Residuals: | ||
+ | Min 1Q Median | ||
+ | -2.7728 -0.6954 | ||
+ | |||
+ | Coefficients: | ||
+ | | ||
+ | (Intercept) | ||
+ | CompPrice | ||
+ | Income | ||
+ | Advertising | ||
+ | Price | ||
+ | ShelveLocGood | ||
+ | ShelveLocMedium | ||
+ | Age | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 1.019 on 392 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | </ | ||
+ | |||
+ | Compare the fitted model to full model | ||
+ | |||
+ | < | ||
+ | anova(lm.full, | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Analysis of Variance Table | ||
+ | |||
+ | Model 1: Sales ~ CompPrice + Income + Advertising + Population + Price + | ||
+ | ShelveLoc + Age + Education + Urban + US | ||
+ | Model 2: Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age | ||
+ | Res.Df | ||
+ | 1 388 402.83 | ||
+ | 2 392 407.39 -4 | ||
+ | > </ | ||
+ | ===== Backward elimination ===== | ||
+ | < | ||
+ | drop1(lm.full, | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > drop1(lm.full, | ||
+ | Single term deletions | ||
+ | |||
+ | Model: | ||
+ | Sales ~ CompPrice + Income + Advertising + Population + Price + | ||
+ | ShelveLoc + Age + Education + Urban + US | ||
+ | Df Sum of Sq | ||
+ | < | ||
+ | CompPrice | ||
+ | Income | ||
+ | Advertising | ||
+ | Population | ||
+ | Price 1 | ||
+ | ShelveLoc | ||
+ | Age 1 217.44 | ||
+ | Education | ||
+ | Urban 1 1.23 404.06 | ||
+ | US | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | > </ | ||
+ | |||
+ | < | ||
+ | drop1(update(lm.full, | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > drop1(update(lm.full, | ||
+ | Single term deletions | ||
+ | |||
+ | Model: | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + Education + Urban + US | ||
+ | Df Sum of Sq | ||
+ | < | ||
+ | CompPrice | ||
+ | Income | ||
+ | Advertising | ||
+ | Price 1 | ||
+ | ShelveLoc | ||
+ | Age 1 218.52 | ||
+ | Education | ||
+ | Urban 1 1.15 404.31 | ||
+ | US | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | > </ | ||
+ | |||
+ | < | ||
+ | drop1(update(lm.full, | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > drop1(update(lm.full, | ||
+ | Single term deletions | ||
+ | |||
+ | Model: | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + Education + US | ||
+ | Df Sum of Sq | ||
+ | < | ||
+ | CompPrice | ||
+ | Income | ||
+ | Advertising | ||
+ | Price 1 | ||
+ | ShelveLoc | ||
+ | Age 1 217.59 | ||
+ | Education | ||
+ | US | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | > | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | drop1(update(lm.full, | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > drop1(update(lm.full, | ||
+ | Single term deletions | ||
+ | |||
+ | Model: | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age + US | ||
+ | Df Sum of Sq | ||
+ | < | ||
+ | CompPrice | ||
+ | Income | ||
+ | Advertising | ||
+ | Price 1 | ||
+ | ShelveLoc | ||
+ | Age 1 217.97 | ||
+ | US | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | drop1(update(lm.full, | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > drop1(update(lm.full, | ||
+ | Single term deletions | ||
+ | |||
+ | Model: | ||
+ | Sales ~ CompPrice + Income + Advertising + Price + ShelveLoc + | ||
+ | Age | ||
+ | Df Sum of Sq | ||
+ | < | ||
+ | CompPrice | ||
+ | Income | ||
+ | Advertising | ||
+ | Price 1 | ||
+ | ShelveLoc | ||
+ | Age 1 219.12 | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | > </ | ||
+ | |||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | < | ||
+ | CompPrice + Income + | ||
+ | Advertising + Price + | ||
+ | ShelveLoc + Age, data = Carseats) | ||
+ | | ||
+ | summary(lm.fit.be) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > lm.fit.be <- lm(Sales ~ CompPrice + | ||
+ | Income + Advertising + | ||
+ | Price + ShelveLoc + | ||
+ | Age, data = Carseats) | ||
+ | > summary(lm.fit.be) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = Sales ~ CompPrice + Income + Advertising + Price + | ||
+ | ShelveLoc + Age, data = Carseats) | ||
+ | |||
+ | Residuals: | ||
+ | Min 1Q Median | ||
+ | -2.7728 -0.6954 | ||
+ | |||
+ | Coefficients: | ||
+ | | ||
+ | (Intercept) | ||
+ | CompPrice | ||
+ | Income | ||
+ | Advertising | ||
+ | Price | ||
+ | ShelveLocGood | ||
+ | ShelveLocMedium | ||
+ | Age | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 1.019 on 392 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | |||
+ | > | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP half column> | ||
+ | < | ||
+ | lm.fit.01 <- lm(formula = Sales ~ | ||
+ | | ||
+ | | ||
+ | | ||
+ | data = Carseats) | ||
+ | summary(lm.fit.01) | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | > lm.fit.01 <- lm(formula = Sales ~ CompPrice + | ||
+ | | ||
+ | | ||
+ | > summary(lm.fit.01) | ||
+ | |||
+ | Call: | ||
+ | lm(formula = Sales ~ CompPrice + Income + Advertising + Price + | ||
+ | ShelveLoc + Age, data = Carseats) | ||
+ | |||
+ | Residuals: | ||
+ | Min 1Q Median | ||
+ | -2.7728 -0.6954 | ||
+ | |||
+ | Coefficients: | ||
+ | | ||
+ | (Intercept) | ||
+ | CompPrice | ||
+ | Income | ||
+ | Advertising | ||
+ | Price | ||
+ | ShelveLocGood | ||
+ | ShelveLocMedium | ||
+ | Age | ||
+ | --- | ||
+ | Signif. codes: | ||
+ | |||
+ | Residual standard error: 1.019 on 392 degrees of freedom | ||
+ | Multiple R-squared: | ||
+ | F-statistic: | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | </ | ||
multiple_regression_examples.txt · Last modified: 2023/10/21 13:26 by hkimscil