Develope a regression model to predict selling price based o
Develope a regression model to predict selling price based on square footage, number of bedrooms and age. Use this to predict the selling price of a 10-years old, 2,000 square foot with three bedrooms.
| SELLING PRICE ($) | SQUARE FOOTAGE | BEDROOMS | AGE (YEARS) |
| 84000 | 1670 | 2 | 30 |
| 79000 | 1339 | 2 | 25 |
| 91500 | 1712 | 3 | 30 |
| 120000 | 1840 | 3 | 40 |
| 127500 | 2300 | 3 | 18 |
| 132500 | 2234 | 3 | 30 |
| 145000 | 2311 | 3 | 19 |
| 164000 | 2377 | 3 | 7 |
| 155000 | 2736 | 4 | 10 |
| 168000 | 2500 | 3 | 1 |
| 172500 | 2500 | 4 | 3 |
| 174000 | 2479 | 3 | 3 |
| 175000 | 2400 | 3 | 1 |
| 177500 | 3124 | 4 | 0 |
| 184000 | 2500 | 3 | 2 |
| 195500 | 4062 | 4 | 10 |
| 195000 | 2854 | 3 | 3 |
Solution
> ttt <- read.csv(\"clipboard\",sep=\"\\t\") # data copied merely from the table given in the problem
> head(ttt)
SELLING.PRICE.... SQUARE.FOOTAGE BEDROOMS AGE..YEARS.
1 84000 1670 2 30
2 79000 1339 2 25
3 91500 1712 3 30
4 120000 1840 3 40
5 127500 2300 3 18
6 132500 2234 3 30
> names(ttt) <- c(\"Selling_Price\",\"Sq_Foot\",\"Bedrooms\",\"Age\")
> splm <- lm(Selling_Price~.,data=ttt)
> summary(splm)
Call:
lm(formula = Selling_Price ~ ., data = ttt)
Residuals:
Min 1Q Median 3Q Max
-19041 -11884 2456 7049 27455
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 91446.49 26076.89 3.507 0.00386 **
Sq_Foot 29.86 10.86 2.749 0.01657 *
Bedrooms 2116.86 10003.01 0.212 0.83568
Age -1504.77 370.82 -4.058 0.00136 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 15230 on 13 degrees of freedom
Multiple R-squared: 0.8678, Adjusted R-squared: 0.8373
F-statistic: 28.44 on 3 and 13 DF, p-value: 5.557e-06
> predict(splm,newdata=data.frame(\"Sq_Foot\"=2000,\"Bedrooms\"=3,\"Age\"=10))
1
142465.2

