More-about-anova-and-summary-table-in-MLR

.pdf
More about ANOVA Table and Summary Table in R Models house <- read.csv ( "housing_data.csv" ) house <- house[ - which (house $ bedrooms > 20 ), - 1 ] bed <- house $ bedrooms bath <- house $ bathrooms size <- house $ sqft.living / 1000 price <- house $ price n <- length (price) n ## [1] 6979 model0 <- lm ( log (price) ~ 1 ) model1 <- lm ( log (price) ~ size) model2 <- lm ( log (price) ~ size + bath) model3 <- lm ( log (price) ~ size + bath + bed) Model 1 summary (model1) ## ## Call: ## lm(formula = log(price) ~ size) ## ## Residuals: ## Min 1Q Median 3Q Max ## -1.36259 -0.29950 0.01047 0.27043 1.22185 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 12.23893 0.01163 1052.46 <2e-16 *** ## size 0.39801 0.00522 76.24 <2e-16 *** ## --- ## Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 ## ## Residual standard error: 0.3894 on 6977 degrees of freedom ## Multiple R-squared: 0.4545, Adjusted R-squared: 0.4544 ## F-statistic: 5813 on 1 and 6977 DF, p-value: < 2.2e-16 anova (model1) ## Analysis of Variance Table ## 1
## Response: log(price) ## Df Sum Sq Mean Sq F value Pr(>F) ## size 1 881.32 881.32 5813.2 < 2.2e-16 *** ## Residuals 6977 1057.77 0.15 ## --- ## Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 anova (model0, model1) ## Analysis of Variance Table ## ## Model 1: log(price) ~ 1 ## Model 2: log(price) ~ size ## Res.Df RSS Df Sum of Sq F Pr(>F) ## 1 6978 1939.1 ## 2 6977 1057.8 1 881.32 5813.2 < 2.2e-16 *** ## --- ## Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Model 2 summary (model2) ## ## Call: ## lm(formula = log(price) ~ size + bath) ## ## Residuals: ## Min 1Q Median 3Q Max ## -1.38613 -0.30117 0.00884 0.26845 1.24111 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 12.209753 0.013592 898.281 < 2e-16 *** ## size 0.372939 0.007999 46.622 < 2e-16 *** ## bath 0.038534 0.009324 4.133 3.63e-05 *** ## --- ## Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 ## ## Residual standard error: 0.3889 on 6976 degrees of freedom ## Multiple R-squared: 0.4558, Adjusted R-squared: 0.4557 ## F-statistic: 2922 on 2 and 6976 DF, p-value: < 2.2e-16 anova (model0, model2) ## Analysis of Variance Table ## ## Model 1: log(price) ~ 1 ## Model 2: log(price) ~ size + bath ## Res.Df RSS Df Sum of Sq F Pr(>F) ## 1 6978 1939.1 ## 2 6976 1055.2 2 883.9 2921.8 < 2.2e-16 *** ## --- ## Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 2
anova (model2) ## Analysis of Variance Table ## ## Response: log(price) ## Df Sum Sq Mean Sq F value Pr(>F) ## size 1 881.32 881.32 5826.570 < 2.2e-16 *** ## bath 1 2.58 2.58 17.078 3.629e-05 *** ## Residuals 6976 1055.18 0.15 ## --- ## Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 anova (model0, model1, model2) ## Analysis of Variance Table ## ## Model 1: log(price) ~ 1 ## Model 2: log(price) ~ size ## Model 3: log(price) ~ size + bath ## Res.Df RSS Df Sum of Sq F Pr(>F) ## 1 6978 1939.1 ## 2 6977 1057.8 1 881.32 5826.570 < 2.2e-16 *** ## 3 6976 1055.2 1 2.58 17.078 3.629e-05 *** ## --- ## Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 Model 3 summary (model3) ## ## Call: ## lm(formula = log(price) ~ size + bath + bed) ## ## Residuals: ## Min 1Q Median 3Q Max ## -1.47533 -0.29819 0.00662 0.26740 1.23092 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 12.325407 0.018586 663.164 < 2e-16 *** ## size 0.400023 0.008496 47.085 < 2e-16 *** ## bath 0.050730 0.009368 5.415 6.32e-08 *** ## bed -0.058495 0.006454 -9.064 < 2e-16 *** ## --- ## Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1 ## ## Residual standard error: 0.3867 on 6975 degrees of freedom ## Multiple R-squared: 0.4622, Adjusted R-squared: 0.4619 ## F-statistic: 1998 on 3 and 6975 DF, p-value: < 2.2e-16 anova (model3) ## Analysis of Variance Table 3
Page1of 5
Uploaded by Indu2008 on coursehero.com