The questions involve the data set for asking prices of Richmond townhouses obta
ID: 3044852 • Letter: T
Question
The questions involve the data set for asking prices of Richmond townhouses obtained on 2014.11.03.
For your subset, the response variable is:
asking price divided by 10000:
askpr=c(44.8, 68.8, 46.8, 54.98, 49.9, 74.8, 48.8, 50.5, 55.2, 57.8, 50.8, 68.5, 57.5, 62.9, 57.8, 33.7, 68.8, 79.8, 40.9, 40.8, 65.99, 54.8, 59.8, 62.8888, 68.5, 56.8, 58.8, 25.9, 51.68, 56.88, 60.8, 79.99, 73.8, 47.9, 52.4, 51.99, 26.99, 50.8, 47.8, 40.8)
The explanatory variables are:
(i) finished floor area divided by 100
ffarea=c(9.4, 16.9, 16.2, 13.06, 15.6, 17.48, 14.8, 12.26, 15.3, 13.84, 16.6, 15.76, 13.46, 14, 12.01, 12, 15.95, 15.25, 16.06, 14, 22.78, 11.26, 17.63, 15.77, 13.59, 15.5, 17.37, 6.1, 15.1, 15.78, 13.2, 22, 17.54, 12.1, 16.22, 12.09, 10.5, 12.27, 13.34, 12.26)
(ii) age
age=c(14, 8, 30, 1, 20, 5, 50, 3, 9, 10, 23, 4, 10, 5, 0, 28, 18, 3, 25, 38, 35, 0, 26, 6, 2, 23, 26, 11, 20, 17, 3, 20, 9, 7, 25, 7, 37, 17, 32, 29)
You are to fit a multiple regression model with the response variable askpr and two explanatory variables ffarea, age
richmondtownh=data.frame(askpr,ffarea,age)
After fitting the regression model, get the vector of fitted or predicted values y iy^i.
Please use 3 significant digits for the answers below which are not integer-valued
Part a)
Explanation / Answer
> askpr=c(44.8, 68.8, 46.8, 54.98, 49.9, 74.8, 48.8, 50.5, 55.2, 57.8, 50.8, 68.5, 57.5, 62.9, 57.8, 33.7, 68.8, 79.8, 40.9, 40.8, 65.99, 54.8, 59.8, 62.8888, 68.5, 56.8, 58.8, 25.9, 51.68, 56.88, 60.8, 79.99, 73.8, 47.9, 52.4, 51.99, 26.99, 50.8, 47.8, 40.8)
> ffarea=c(9.4, 16.9, 16.2, 13.06, 15.6, 17.48, 14.8, 12.26, 15.3, 13.84, 16.6, 15.76, 13.46, 14, 12.01, 12, 15.95, 15.25, 16.06, 14, 22.78, 11.26, 17.63, 15.77, 13.59, 15.5, 17.37, 6.1, 15.1, 15.78, 13.2, 22, 17.54, 12.1, 16.22, 12.09, 10.5, 12.27, 13.34, 12.26)
> age=c(14, 8, 30, 1, 20, 5, 50, 3, 9, 10, 23, 4, 10, 5, 0, 28, 18, 3, 25, 38, 35, 0, 26, 6, 2, 23, 26, 11, 20, 17, 3, 20, 9, 7, 25, 7, 37, 17, 32, 29)
> richmondtownh=data.frame(askpr,ffarea,age)
a)> model=lm(askpr~ffarea+age,data=richmondtownh) #fitting multiple linear regression
> summary(model)
Call:
lm(formula = askpr ~ ffarea + age, data = richmondtownh)
Residuals:
Min 1Q Median 3Q Max
-13.9049 -4.7301 0.4835 2.4310 13.8689
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.31375 4.52642 3.825 0.000486 ***
ffarea 3.31150 0.31226 10.605 9.03e-13 ***
age -0.62766 0.07609 -8.249 6.60e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 5.772 on 37 degrees of freedom
Multiple R-squared: 0.8006, Adjusted R-squared: 0.7898
F-statistic: 74.26 on 2 and 37 DF, p-value: 1.113e-13
ANS : R2 = 0.8006
b)> yicap=predict(model)
> yicap
1 2 3 4 5 6 7 8
39.65458 68.25676 52.13019 59.93424 56.41989 72.06041 34.94089 56.02972
9 10 11 12 13 14 15 16
62.33071 56.86826 57.84841 66.99230 55.60989 60.53640 57.08483 39.47722
17 18 19 20 21 22 23 24
58.83424 65.93110 54.80488 39.82361 70.78154 54.60120 59.37627 65.77009
25 26 27 28 29 30 31 32
61.06167 54.20576 58.51528 30.60962 54.76415 58.89895 59.14253 77.61348
33 34 35 36 37 38 39 40
69.74846 52.98924 55.33472 52.95612 28.86104 47.27559 41.40399 39.71055
> yi=askpr
> yi
[1] 44.8000 68.8000 46.8000 54.9800 49.9000 74.8000 48.8000 50.5000 55.2000
[10] 57.8000 50.8000 68.5000 57.5000 62.9000 57.8000 33.7000 68.8000 79.8000
[19] 40.9000 40.8000 65.9900 54.8000 59.8000 62.8888 68.5000 56.8000 58.8000
[28] 25.9000 51.6800 56.8800 60.8000 79.9900 73.8000 47.9000 52.4000 51.9900
[37] 26.9900 50.8000 47.8000 40.8000
> mean(yi)
[1] 55.22972
> sd(yi)
[1] 12.58929
> mean(yicap)
[1] 55.22972
> sd(yicap)
[1] 11.26418
c) >cov(yi,yicap)
[1] 126.8817
> cor(yi,yicap)
[1] 0.8947429
d)> cor(yi,yicap)^2
[1] 0.8005648
This is equal to R2 obtained in (a).
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.