Real estate investors, home buyers, and home owners often use the appraised value of a property as a basis for predicting sale price. Data on sale prices and total appraised values (in thousand of dollars) of 92 residential properties sold in 1999 in an upscale Tampa, Florida, neighborhood named Tampa Palms are saved in the file – tampalms.dat.
To read the data into R, first save the data file onto a folly
disk or to any local file. Then the following R codes basically read
the data into a data.frame called tampalms.
tampalms <- read.table("tampalms.dat", header=F,
col.names=c("appraised", "sale"))
First take the logarithm transformation on both X and Y and use
them as the response and predictor.
x <- log(tampalms$appraised) y <-
log(tampalms$sale)
Data is as follows:
170.432 |
180 |
212.827 | 245.1 |
68.13 | 85.4 |
65.505 | 87.9 |
68.655 | 84.2 |
64.98 | 85 |
67.605 | 81 |
100.861 | 125 |
108.981 | 124 |
102.523 | 126 |
104.203 | 128.5 |
102.681 | 127.5 |
105.175 | 128.2 |
80.954 | 107 |
101.515 | 125 |
89.119 | 116 |
102.066 | 122.5 |
89.588 | 118.9 |
106.118 | 120 |
147.865 | 188 |
158.26 | 183 |
161.309 | 195.5 |
162.395 | 193 |
151.475 | 192 |
203.826 | 256.9 |
222.012 | 270 |
214.728 | 230 |
259.848 | 332.5 |
217.125 | 310 |
220.041 | 230.5 |
228.806 | 257 |
253.876 | 300 |
205.529 | 275 |
318.508 | 365 |
202.127 | 258 |
263.847 | 279 |
286.744 | 340 |
324.578 | 335 |
266.542 | 297 |
140.743 | 166 |
151.305 | 187 |
148.115 | 163.4 |
182.272 | 59 |
170.863 | 221 |
270.04 | 290 |
235.087 | 260 |
348.574 | 445 |
302.133 | 406 |
136.315 | 185 |
116.446 | 176 |
133.912 | 171.1 |
153.25 | 182 |
127.93 | 166.5 |
306.172 | 295 |
298.68 | 369 |
289.489 | 350 |
315.663 | 365 |
320.017 | 390 |
348.574 | 365 |
352.985 | 440.3 |
112.242 | 100.3 |
225.613 | 220 |
150.348 | 187 |
169.282 | 214 |
171.832 | 185 |
156.224 | 182.5 |
144.384 | 165 |
139.94 | 167 |
127.706 | 160 |
111.856 | 130.9 |
125.731 | 160 |
128.329 | 142.8 |
615.586 | 560 |
572.523 | 715 |
140.04 | 176 |
164.849 | 178 |
125.187 | 156.5 |
149.202 | 153 |
422.913 | 528 |
372.377 | 475 |
330.554 | 427 |
929.396 | 957.5 |
192.105 | 260 |
201.886 | 262 |
159.705 | 154 |
223.001 | 260 |
179.056 | 215 |
195.862 | 244 |
176.85 | 219 |
95.718 | 132 |
137.108 | 156.9 |
183.704 | 263 |
5. Obtain the fitted values ^yi and residuals ri from the ftted model. Plot ri versus ^yi and comment.
Here, using R code, we are to obtain and
.
The R code for obtaining these are given below:
model=lm(y~x)
y_fit=model$fitted
res=model$resid
plot(y_fit,res,pch=16,main="Residual plot")
The residual plot is given below:
From the residual plot, we can see that the residuals are not
symmetrically placed on either side of the "0" line. Also, we can
see that there are outlier residuals present in the plot. This
tells us that heteroscedasticity is present in the data set,
meaning that the residuals get larger as the prediction moves from
small to large (or from large to small).
Get Answers For Free
Most questions answered within 1 hours.