> #Model Building:
> #Dependent Variable - 'Price'
> #Explanatory Variable - 'Living.Area','Number of Bedrooms',
and 'Number of Fireplaces'
>
> lin.fit = lm(Price ~ Living.Area+Bedrooms+Fireplaces,data =
mydata)
>
> #Summary
> summary(lin.fit)
Call:
lm(formula = Price ~ Living.Area + Bedrooms + Fireplaces, data =
mydata)
Residuals:
Min 1Q Median 3Q Max
-62948 -44151 -11924 25181 159655
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -76113.22 55113.57 -1.381 0.186
Living.Area 162.08 48.27 3.358 0.004 **
Bedrooms -11816.43 24453.88 -0.483 0.635
Fireplaces 21851.10 24552.28 0.890 0.387
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 59450 on 16 degrees of freedom
Multiple R-squared: 0.6347, Adjusted R-squared:
0.5662
F-statistic: 9.266 on 3 and 16 DF, p-value: 0.0008698
>
> #ANOVA
> anova(lin.fit)
Analysis of Variance Table
Response: Price
Df Sum Sq Mean Sq F value Pr(>F)
Living.Area 1 9.3321e+10 9.3321e+10 26.4019 9.913e-05 ***
Bedrooms 1 2.1378e+09 2.1378e+09 0.6048 0.4481
Fireplaces 1 2.7997e+09 2.7997e+09 0.7921 0.3867
Residuals 16 5.6554e+10 3.5346e+09
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> #Model 2
> #Dependent Variable - 'Price'
> #Explanatory Variable - 'Living.Area','Central Air', and
Interaction of the respective variables
>
> lin.fit2 = lm(Price ~
Living.Area+Central.Air+Central.Air*Living.Area,data =
mydata)
>
> #Summary
> summary(lin.fit2)
Call:
lm(formula = Price ~ Living.Area + Central.Air + Central.Air
*
Living.Area, data = mydata)
Residuals:
Min 1Q Median 3Q Max
-73167 -42646 -6390 22429 182885
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -55250.06 47665.26 -1.159 0.263412
Living.Area 133.83 26.86 4.983 0.000135 ***
Central.Air -917668.34 1128241.33 -0.813 0.427949
Living.Area:Central.Air 576.49 708.23 0.814 0.427597
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 60750 on 16 degrees of freedom
Multiple R-squared: 0.6186, Adjusted R-squared:
0.5471
F-statistic: 8.65 on 3 and 16 DF, p-value: 0.001215
>
> #ANOVA
> anova(lin.fit2)
Analysis of Variance Table
Response: Price
Df Sum Sq Mean Sq F value Pr(>F)
Living.Area 1 9.3321e+10 9.3321e+10 25.2876 0.0001235 ***
Central.Air 1 9.0242e+04 9.0242e+04 0.0000 0.9961156
Living.Area:Central.Air 1 2.4452e+09 2.4452e+09 0.6626
0.4275974
Residuals 16 5.9046e+10 3.6904e+09
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
>
> # Scatter Plot
> library(ggplot2)
> mydata$central.air <- as.factor(mydata$Central.Air)
> ggplot(mydata, aes(x=Living.Area, y=Price, shape=central.air,
color=central.air)) +
+ geom_point()
USE R SOFTWARE TO SOLVE THE PROBLEM and SHOW ALL YOUR WORK WITH CODE. Build the model one a multiple regression model including the living area (), number of bedrooms (), and number of fireplaces...