Appendix
Appendix
INPUT
setwd("C:\\Users\\user\\Desktop")
model.dat<-read.table("haha.txt",header=TRUE)
model.dat
model.reg<lm(Y~X1+X2+X3+X4+X5+X6+X7+X8+X9+X10,data=model.dat)
summary(model.reg)
OUTPUT
Y X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
1 650000 1.0 3150 2 5 4 2.50 0.64 1.40 0.22 0.5
2 1100000 1.0 2380 2 8 3 1.08 0.66 1.32 0.12 0.5
3 850000 2.0 2380 2 4 3 2.04 0.55 0.89 0.29 0.0
4 898000 2.0 1400 1 4 3 1.02 2.00 2.40 0.86 0.5
5 618000 1.0 1400 1 3 2 1.08 0.66 1.32 0.12 0.5
6 1260000 2.0 2380 2 6 4 1.05 0.33 2.15 0.72 1.0
7 560000 2.0 880 2 5 3 2.00 0.12 0.41 0.50 0.5
8 380000 2.0 1540 2 5 5 4.31 0.73 1.44 1.04 0.5
9 750000 2.0 1760 2 4 3 1.08 0.66 1.32 0.12 0.5
10 1250000 2.5 1650 2 6 4 1.08 0.66 1.32 0.12 0.5
11 800000 1.0 2700 2 4 4 0.59 0.94 0.70 0.30 0.5
12 650000 1.0 3150 2 5 4 1.62 0.58 0.85 0.30 0.5
13 830000 1.5 1870 2 4 3 1.62 0.05 0.43 0.35 0.5
14 560000 1.0 1200 1 3 1 3.51 0.26 0.40 0.31 0.5
15 1500000 2.5 3300 1 6 5 1.08 0.66 1.32 0.12 0.5
16 660000 1.0 1540 1 3 2 1.08 0.66 1.32 0.12 0.0
Call:
lm(formula = Y ~ X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8 + X9 +
1Q Median
-532028 -101390
3Q
Max
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 79525.93 156095.35 0.509 0.61250
X1
X2
X3
X4
X5
X6
X7
X8
X9
X10
Residual VS Bedrooms
model.reg<-lm(Y~X4,data=model.dat)
plot(x=model.dat$X4, y=model.reg$residuals, xlab = "Bedrooms", ylab =
"Residuals", main="Residuals vs. Bedrooms", col = "red", pch =
19,cex=1.5,panel.first=grid(col="gray",lty="dotted"))
abline(h=0,col="blue")
Residual VS Bedrooms
model.reg<-lm(Y~X4,data=model.dat)
plot(x=model.reg$fitted.values, y=model.reg$residuals, xlab = "Bedrooms",
ylab = "Residuals", main="Residuals vs. Predicted Values", col = "red", pch =
19,cex=1.5,panel.first=grid(col="gray",lty="dotted"))
abline(h=0,col="blue")
Price vs Bedrooms
model.reg<-lm(Y~X4,data=model.dat)
qqplot<-qqnorm(model.reg$residuals,main="Normal Probability
Plot",xlab="Bedrooms",ylab="Price",plot.it=TRUE ,col="blue", pch=19,
cex=1.5,panelfirst=grid(col="gray",lty="dotted"))
abline(lm(qqplot$y~qqplot$x))
Coefficient of Determination
INPUT
setwd("C:\\Users\\user\\Desktop")
model.dat<-read.table("haha.txt",header=TRUE)
model.reg<lm(Y~X1+X2+X3+X4+X5+X6+X7+X8+X9+X10,data=model.dat)
sum.reg<-summary(model.reg)
model1.reg<-lm(Y~X1,data=model.dat)
sum1.reg<-summary(model1.reg)
model2.reg<-lm(Y~X1+X2,data=model.dat)
sum2.reg<-summary(model2.reg)
model3.reg<-lm(Y~X1+X2+X3,data=model.dat)
sum3.reg<-summary(model3.reg)
model4.reg<-lm(Y~X1+X2+X3+X4,data=model.dat)
sum4.reg<-summary(model4.reg)
model5.reg<-lm(Y~X1+X2+X3+X4+X5,data=model.dat)
sum5.reg<-summary(model5.reg)
model6.reg<-lm(Y~X1+X2+X3+X4+X5+X6,data=model.dat)
sum6.reg<-summary(model6.reg)
model7.reg<-lm(Y~X1+X2+X3+X4+X5+X6+X7,data=model.dat)
sum7.reg<-summary(model7.reg)
model8.reg<-lm(Y~X1+X2+X3+X4+X5+X6+X7+X8,data=model.dat)
sum8.reg<-summary(model8.reg)
model9.reg<-lm(Y~X1+X2+X3+X4+X5+X6+X7+X8+X9,data=model.dat)
sum9.reg<-summary(model9.reg)
OUTPUT
model
1
2
3
x1
x1, x2
x1, x2, x3
R.sq
adj.R.sq
0.1331626
0.1194033
0.5943963
0.5813123
0.6297972
0.6115905
0.7343859
0.7166783
0.7551079
0.7343543
x1,x2,x3,x4,x5,x6
0.7769258
0.7538492
x1,x2,x3,x4,x5,x6,x7
0.7831864
x1,x2,x3,x4,x5,x6,x7,x8
0.7832118 0.7522420
x1,x2,x3,x4,x5,x6,x7,x8,x9
0.7883409
10 x1,x2,x3,x4,x5,x6,x7,x8,x9,x10
0.7909363
0.7565602
0.7537057
0.7522208
Call:
lm(formula = Y ~ X1 + X2 + X3 + X4 + X5 + X6 + X7, data = model.dat)
Residuals:
Min
1Q Median
3Q
Max
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 139279.00 138479.11 1.006 0.318774
X1
X2
X3
X4
X5
X6
X7