Price Bedrooms Size Pool Distance Township Garage Baths 2631
Price
Bedrooms
Size
Pool
Distance
Township
Garage
Baths
263.1
4
2300
1
17
5
1
2
182.4
4
2100
0
19
4
0
2
242.1
3
2300
0
12
3
0
2
213.6
2
2200
0
16
2
0
2.5
139.9
2
2100
0
28
1
0
1.5
245.4
2
2100
1
12
1
1
2
327.2
6
2500
0
15
3
1
2
271.8
2
2100
0
9
2
1
2.5
221.1
3
2300
1
18
1
0
1.5
266.6
4
2400
0
13
4
1
2
292.4
4
2100
0
14
3
1
2
209
2
1700
0
8
4
1
1.5
270.8
6
2500
0
7
4
1
2
246.1
4
2100
0
18
3
1
2
194.4
2
2300
0
11
3
0
2
281.3
3
2100
0
16
2
1
2
172.7
4
2200
1
16
3
0
2
207.5
5
2300
1
21
4
0
2.5
198.9
3
2200
1
10
4
1
2
209.3
6
1900
1
15
4
1
2
252.3
4
2600
0
8
4
1
2
192.9
4
1900
1
14
2
1
2.5
209.3
5
2100
0
20
5
0
1.5
345.3
8
2600
0
9
4
1
2
326.3
6
2100
0
11
5
1
3
173.1
2
2200
1
21
5
1
1.5
187
2
1900
0
26
4
0
2
257.2
2
2100
0
9
4
1
2
233
3
2200
0
14
3
1
1.5
180.4
2
2000
0
11
5
0
2
234
2
1700
0
19
3
1
2
207.1
2
2000
0
11
5
1
2
247.7
5
2400
0
16
2
1
2
166.2
3
2000
1
16
2
1
2
177.1
2
1900
0
10
5
1
2
182.7
4
2000
1
14
4
0
2.5
216
4
2300
0
19
2
0
2
312.1
6
2600
0
7
5
1
2.5
199.8
3
2100
0
19
3
1
2
273.2
5
2200
0
16
2
1
3
206
3
2100
1
9
3
0
1.5
232.2
3
1900
1
16
1
1
1.5
198.3
4
2100
1
19
1
1
1.5
205.1
3
2000
1
20
4
0
2
175.6
4
2300
1
24
4
1
2
307.8
3
2400
1
21
2
1
3
269.2
5
2200
0
8
5
1
3
224.8
3
2200
0
17
1
1
2.5
171.6
3
2000
1
16
4
0
2
216.8
3
2200
0
15
1
1
2
192.6
6
2200
1
14
1
0
2
236.4
5
2200
0
20
3
1
2
172.4
3
2200
0
23
3
0
2
251.4
3
1900
0
12
2
1
2
246
6
2300
0
7
3
1
3
147.4
6
1700
1
12
1
0
2
176
4
2200
0
15
1
1
2
228.4
3
2300
0
17
5
1
1.5
166.5
3
1600
1
19
3
0
2.5
189.4
4
2200
0
24
1
1
2
312.1
7
2400
0
13
3
1
3
289.8
6
2000
0
21
3
1
3
269.9
5
2200
1
11
4
1
2.5
154.3
2
2000
0
13
2
0
2
222.1
2
2100
0
9
5
1
2
209.7
5
2200
1
13
2
1
2
190.9
3
2200
1
18
3
1
2
254.3
4
2500
1
15
3
1
2
207.5
3
2100
1
10
2
0
2
209.7
4
2200
1
19
2
1
2
294
2
2100
0
13
2
1
2.5
176.3
2
2000
1
17
3
0
2
294.3
7
2400
0
8
4
1
2
224
3
1900
1
6
1
1
2
125
2
1900
0
18
4
0
1.5
236.8
4
2600
1
17
5
1
2
164.1
4
2300
0
19
4
0
2
217.8
3
2500
0
12
3
0
2
192.2
2
2400
0
16
2
0
2.5
125.9
2
2400
0
28
1
0
1.5
220.9
2
2300
1
12
1
1
2
294.5
6
2700
0
15
3
1
2
244.6
2
2300
0
9
2
1
2.5
199
3
2500
1
18
1
0
1.5
240
4
2600
0
13
4
1
2
263.2
4
2300
0
14
3
1
2
188.1
2
1900
0
8
4
1
1.5
243.7
6
2700
0
7
4
1
2
221.5
4
2300
0
18
3
1
2
175
2
2500
0
11
3
0
2
253.2
3
2300
0
16
2
1
2
155.4
4
2400
1
16
3
0
2
186.7
5
2500
1
21
4
0
2.5
179
3
2400
1
10
4
1
2
188.3
6
2100
1
15
4
1
2
227.1
4
2900
0
8
4
1
2
173.6
4
2100
1
14
2
1
2.5
188.3
5
2300
0
20
5
0
1.5
310.8
8
2900
0
9
4
1
2
293.7
6
2400
0
11
5
1
3
179
3
2400
0
8
4
1
2
188.3
6
2100
1
14
2
1
2.5
227.1
4
2900
0
20
5
0
1.5
173.6
4
2100
0
9
4
1
2
188.3
5
2300
0
11
5
1
3
Refer to the Real Estate data, which report information on homes in the Goodyear, Arizona area during last year. Use the selling price of the home as the dependent variable and determine the regression equation with number of bedrooms, size of the house, center of the city, and number of bathrooms as independent variables.
a. Use a statistical software package to determine the multiple regression equation. Discuss each of the variables. For example, are you surprised that the regression coefficient for distance from the center of the city is negative? How much does a garage or a swimming pool add to the selling price of a home?
b. Determine the value of the intercept.
c. Develop a correlation matrix. Which independent variables have strong or weak correlations with the dependent variable? Do you see any problems with multicollinearity?
d. Conduct the global test on the set of independent variables. Interpret.
e. Conduct a test of hypothesis on each of the independent variables. Would you consider deleting any of the variables? If so, which ones?
| Price | Bedrooms | Size | Pool | Distance | Township | Garage | Baths |
| 263.1 | 4 | 2300 | 1 | 17 | 5 | 1 | 2 |
| 182.4 | 4 | 2100 | 0 | 19 | 4 | 0 | 2 |
| 242.1 | 3 | 2300 | 0 | 12 | 3 | 0 | 2 |
| 213.6 | 2 | 2200 | 0 | 16 | 2 | 0 | 2.5 |
| 139.9 | 2 | 2100 | 0 | 28 | 1 | 0 | 1.5 |
| 245.4 | 2 | 2100 | 1 | 12 | 1 | 1 | 2 |
| 327.2 | 6 | 2500 | 0 | 15 | 3 | 1 | 2 |
| 271.8 | 2 | 2100 | 0 | 9 | 2 | 1 | 2.5 |
| 221.1 | 3 | 2300 | 1 | 18 | 1 | 0 | 1.5 |
| 266.6 | 4 | 2400 | 0 | 13 | 4 | 1 | 2 |
| 292.4 | 4 | 2100 | 0 | 14 | 3 | 1 | 2 |
| 209 | 2 | 1700 | 0 | 8 | 4 | 1 | 1.5 |
| 270.8 | 6 | 2500 | 0 | 7 | 4 | 1 | 2 |
| 246.1 | 4 | 2100 | 0 | 18 | 3 | 1 | 2 |
| 194.4 | 2 | 2300 | 0 | 11 | 3 | 0 | 2 |
| 281.3 | 3 | 2100 | 0 | 16 | 2 | 1 | 2 |
| 172.7 | 4 | 2200 | 1 | 16 | 3 | 0 | 2 |
| 207.5 | 5 | 2300 | 1 | 21 | 4 | 0 | 2.5 |
| 198.9 | 3 | 2200 | 1 | 10 | 4 | 1 | 2 |
| 209.3 | 6 | 1900 | 1 | 15 | 4 | 1 | 2 |
| 252.3 | 4 | 2600 | 0 | 8 | 4 | 1 | 2 |
| 192.9 | 4 | 1900 | 1 | 14 | 2 | 1 | 2.5 |
| 209.3 | 5 | 2100 | 0 | 20 | 5 | 0 | 1.5 |
| 345.3 | 8 | 2600 | 0 | 9 | 4 | 1 | 2 |
| 326.3 | 6 | 2100 | 0 | 11 | 5 | 1 | 3 |
| 173.1 | 2 | 2200 | 1 | 21 | 5 | 1 | 1.5 |
| 187 | 2 | 1900 | 0 | 26 | 4 | 0 | 2 |
| 257.2 | 2 | 2100 | 0 | 9 | 4 | 1 | 2 |
| 233 | 3 | 2200 | 0 | 14 | 3 | 1 | 1.5 |
| 180.4 | 2 | 2000 | 0 | 11 | 5 | 0 | 2 |
| 234 | 2 | 1700 | 0 | 19 | 3 | 1 | 2 |
| 207.1 | 2 | 2000 | 0 | 11 | 5 | 1 | 2 |
| 247.7 | 5 | 2400 | 0 | 16 | 2 | 1 | 2 |
| 166.2 | 3 | 2000 | 1 | 16 | 2 | 1 | 2 |
| 177.1 | 2 | 1900 | 0 | 10 | 5 | 1 | 2 |
| 182.7 | 4 | 2000 | 1 | 14 | 4 | 0 | 2.5 |
| 216 | 4 | 2300 | 0 | 19 | 2 | 0 | 2 |
| 312.1 | 6 | 2600 | 0 | 7 | 5 | 1 | 2.5 |
| 199.8 | 3 | 2100 | 0 | 19 | 3 | 1 | 2 |
| 273.2 | 5 | 2200 | 0 | 16 | 2 | 1 | 3 |
| 206 | 3 | 2100 | 1 | 9 | 3 | 0 | 1.5 |
| 232.2 | 3 | 1900 | 1 | 16 | 1 | 1 | 1.5 |
| 198.3 | 4 | 2100 | 1 | 19 | 1 | 1 | 1.5 |
| 205.1 | 3 | 2000 | 1 | 20 | 4 | 0 | 2 |
| 175.6 | 4 | 2300 | 1 | 24 | 4 | 1 | 2 |
| 307.8 | 3 | 2400 | 1 | 21 | 2 | 1 | 3 |
| 269.2 | 5 | 2200 | 0 | 8 | 5 | 1 | 3 |
| 224.8 | 3 | 2200 | 0 | 17 | 1 | 1 | 2.5 |
| 171.6 | 3 | 2000 | 1 | 16 | 4 | 0 | 2 |
| 216.8 | 3 | 2200 | 0 | 15 | 1 | 1 | 2 |
| 192.6 | 6 | 2200 | 1 | 14 | 1 | 0 | 2 |
| 236.4 | 5 | 2200 | 0 | 20 | 3 | 1 | 2 |
| 172.4 | 3 | 2200 | 0 | 23 | 3 | 0 | 2 |
| 251.4 | 3 | 1900 | 0 | 12 | 2 | 1 | 2 |
| 246 | 6 | 2300 | 0 | 7 | 3 | 1 | 3 |
| 147.4 | 6 | 1700 | 1 | 12 | 1 | 0 | 2 |
| 176 | 4 | 2200 | 0 | 15 | 1 | 1 | 2 |
| 228.4 | 3 | 2300 | 0 | 17 | 5 | 1 | 1.5 |
| 166.5 | 3 | 1600 | 1 | 19 | 3 | 0 | 2.5 |
| 189.4 | 4 | 2200 | 0 | 24 | 1 | 1 | 2 |
| 312.1 | 7 | 2400 | 0 | 13 | 3 | 1 | 3 |
| 289.8 | 6 | 2000 | 0 | 21 | 3 | 1 | 3 |
| 269.9 | 5 | 2200 | 1 | 11 | 4 | 1 | 2.5 |
| 154.3 | 2 | 2000 | 0 | 13 | 2 | 0 | 2 |
| 222.1 | 2 | 2100 | 0 | 9 | 5 | 1 | 2 |
| 209.7 | 5 | 2200 | 1 | 13 | 2 | 1 | 2 |
| 190.9 | 3 | 2200 | 1 | 18 | 3 | 1 | 2 |
| 254.3 | 4 | 2500 | 1 | 15 | 3 | 1 | 2 |
| 207.5 | 3 | 2100 | 1 | 10 | 2 | 0 | 2 |
| 209.7 | 4 | 2200 | 1 | 19 | 2 | 1 | 2 |
| 294 | 2 | 2100 | 0 | 13 | 2 | 1 | 2.5 |
| 176.3 | 2 | 2000 | 1 | 17 | 3 | 0 | 2 |
| 294.3 | 7 | 2400 | 0 | 8 | 4 | 1 | 2 |
| 224 | 3 | 1900 | 1 | 6 | 1 | 1 | 2 |
| 125 | 2 | 1900 | 0 | 18 | 4 | 0 | 1.5 |
| 236.8 | 4 | 2600 | 1 | 17 | 5 | 1 | 2 |
| 164.1 | 4 | 2300 | 0 | 19 | 4 | 0 | 2 |
| 217.8 | 3 | 2500 | 0 | 12 | 3 | 0 | 2 |
| 192.2 | 2 | 2400 | 0 | 16 | 2 | 0 | 2.5 |
| 125.9 | 2 | 2400 | 0 | 28 | 1 | 0 | 1.5 |
| 220.9 | 2 | 2300 | 1 | 12 | 1 | 1 | 2 |
| 294.5 | 6 | 2700 | 0 | 15 | 3 | 1 | 2 |
| 244.6 | 2 | 2300 | 0 | 9 | 2 | 1 | 2.5 |
| 199 | 3 | 2500 | 1 | 18 | 1 | 0 | 1.5 |
| 240 | 4 | 2600 | 0 | 13 | 4 | 1 | 2 |
| 263.2 | 4 | 2300 | 0 | 14 | 3 | 1 | 2 |
| 188.1 | 2 | 1900 | 0 | 8 | 4 | 1 | 1.5 |
| 243.7 | 6 | 2700 | 0 | 7 | 4 | 1 | 2 |
| 221.5 | 4 | 2300 | 0 | 18 | 3 | 1 | 2 |
| 175 | 2 | 2500 | 0 | 11 | 3 | 0 | 2 |
| 253.2 | 3 | 2300 | 0 | 16 | 2 | 1 | 2 |
| 155.4 | 4 | 2400 | 1 | 16 | 3 | 0 | 2 |
| 186.7 | 5 | 2500 | 1 | 21 | 4 | 0 | 2.5 |
| 179 | 3 | 2400 | 1 | 10 | 4 | 1 | 2 |
| 188.3 | 6 | 2100 | 1 | 15 | 4 | 1 | 2 |
| 227.1 | 4 | 2900 | 0 | 8 | 4 | 1 | 2 |
| 173.6 | 4 | 2100 | 1 | 14 | 2 | 1 | 2.5 |
| 188.3 | 5 | 2300 | 0 | 20 | 5 | 0 | 1.5 |
| 310.8 | 8 | 2900 | 0 | 9 | 4 | 1 | 2 |
| 293.7 | 6 | 2400 | 0 | 11 | 5 | 1 | 3 |
| 179 | 3 | 2400 | 0 | 8 | 4 | 1 | 2 |
| 188.3 | 6 | 2100 | 1 | 14 | 2 | 1 | 2.5 |
| 227.1 | 4 | 2900 | 0 | 20 | 5 | 0 | 1.5 |
| 173.6 | 4 | 2100 | 0 | 9 | 4 | 1 | 2 |
| 188.3 | 5 | 2300 | 0 | 11 | 5 | 1 | 3 |
Solution
Solution: For the given data, I have used R for performing regression over it. Corresponding R code is given below:
----------------------------------------------------
setwd(\"...\") #set your working directory. add your path within quotes
getwd() #get working directory
#read data. I have stored data in real_estate_data.csv. header should be true telling first line is header.
data<-read.csv(\"./real_estate_data.csv\",header=TRUE,sep = \",\",na.strings=\"NA\") #data is a data frame.
dim(data) #dimensions of data
names(data) #column names of data
head(data) #first 6 rows of data
#create model by using lm() function. lm() performs linear regression.
model<-lm(Price~Bedrooms+Size+Pool+Distance+Township+Garage+Baths,data=data)
model
summary(model) #summary details of model
coefficients(model) #coefficients of model
fitted(model) #predicted values
residuals(model) #residuals
confint(model) #95% confidence interval for model parameters
----------------------------------
Output:
------------------------------------------------
---------------------------------------------------
As per coefficients, the corresponding regression equation will be:
-------------------------------------------------
Price=62.24869165+7.37549761*Bedrooms+ 0.03862695*Size-19.11144180*Pool-1.01266885*Distance -1.73900779*Township+35.49801891*Garage+23.09254587*Baths
----------------------------------------------------
Value of Intercept: 62.24869165
Interpretation: Look at the summary details of the model and note down the significance level of various parameters. It can be easily seen that Garage is most significant of all parameters, while Township and Distance from city center are least significant. It is also clear that Bedrooms, Baths, Size and Pool also play a role in determining the Price.
It is not surprising that coefficient for Distance is in negative. It indicates that nearness to city center can be a positive for Price of house. Garage definitely adds to the value of house. While coefficient for Pool is negative. Intercept is just playing the role of an adjusting factor.
Look at the predicted values and residuals. From this it is clear that we can drop non-significant parameters from consideration and need to create a new model. For further calculation, Township can be dropped. New model can be calculated as:
model<-lm(Price~Bedrooms+Size+Pool+Distance+Garage+Baths,data=data)
Its summary is given below:
This seems to be a bit better than the previous model. Now we drop Pool also from consideration and calculate:
This is more better.
Now we omit Distance also:
Correlation matrix: Can be calculated by using cor() function in R.
--------------------------
cor(data)
-------------------------------
Output:
-------------------------------------
From the correlation matrix, it is clear that Bedrooms, Size, Garage and Bath have strong correlations with Price (+), while Pool and Distance have week correlations with Price (-). Altough, Township also has positive correlation with Price, but its strength is low.





























