Skip to main content

Section 27.5 Investigation 5.14: Housing Prices

Exercises 27.5.1 The Study

A group of students wanted to investigate which factors influence the price of a house (Koester, Davis, and Ross, 2003). They used http://www.househunt.com, limiting their search to single family homes in California. They collected a stratified sample by stratifying on three different regions in CA (northern, southern, and central), and then randomly selecting a sample from within each strata. They decided to focus on homes that were less than 5000 square feet and sold for less than $1.5 million. The file housing.txt contains data for their final sample of 83 houses. Below is a scatterplot of the size vs. selling price for this sample.
described in detail following the image
Scatterplot of price (in hundreds of thousands of dollars) versus square footage (in thousands) for 83 California houses, showing a positive association with more spread in prices for larger houses.

1. Least Squares Line and \(R^2\).

Open the housing.txt file and determine the least-squares regression line for these data. Also report and interpret the value of \(R^2\) for these data.
Solution.
The regression equation is \(\hat{price} = 65930 + 202\,squarefoot\text{.}\) \(R^2 = 0.421\)

2. Model Plausibility.

Based on the scatterplot, do these data appear to fit the basic linear regression model?
Solution.

3. Residual Normality.

Produce a histogram and a normal probability plot of the residuals of this regression. Is it reasonable to consider the residuals as following the normal distribution? Explain.
Solution.
described in detail following the image
Histogram of the residuals, skewed to the right with a peak just below zero.
described in detail following the image
Normal probability plot of the residuals with 95 percent confidence bands; the points bend away from the line in both tails.
The residuals appear to be skewed to the right and not following a normal distribution.

4. Residual Pattern Checks.

Produce a scatterplot of the residuals vs. the square footage.
Does there appear to be curvature in this graph?
Does the variability in the residuals appear to be roughly constant across the graph?
Solution.
described in detail following the image
Scatterplot of residuals versus square footage; the residuals cluster closer to zero for smaller houses and spread out more for larger houses.
There does not appear to be strong curvature but the spread does appear to increase across the graph.

Discussion.

It takes a while to become comfortable interpreting these residual plots, but the housing data do appear to have some problems. The residuals appear to cluster closer to zero for the smaller houses and to have more variability for the larger houses. This violates the condition of a constant standard deviation for each value of \(x\text{.}\) There is also a very slight hint of some curvature in this graph. The distribution of the residuals is clearly non-normal. This residual analysis gives us several reasons to not apply the basic regression model to these data.
When the regression model conditions are violated, we can often transform the data in the hopes that the new variables do meet the conditions.

5. Log Transformation.

Take the log base 10 of both the house prices and sizes, storing the results as logprice and logsqft. Produce the scatterplot and determine the regression equation to model the relationship between these two variables, storing the residuals. Examine the residual plots (histogram of residuals and residuals versus explanatory variable). Do these transformed variables appear to be more suitable for the basic regression model? Explain.
Hint.
Keep in mind that R and JMP use β€œlog” for natural log. Use β€œlogten” in R and JMP for log base 10.
Solution.
described in detail following the image
Scatterplot of logprice versus logsqft showing a positive linear association with fairly even scatter.
described in detail following the image
Scatterplot of the residuals from the log-log regression versus logsqft, showing similar spread across the values of logsqft.
described in detail following the image
Histogram of the residuals from the log-log regression, roughly symmetric and centered at zero.
described in detail following the image
Normal probability plot of the residuals from the log-log regression; the points fall close to the line within the confidence bands.
Although not perfect, these variables do appear to better follow the basic regression model. The residuals appear less skewed and there is less variation in the β€œwidth” of the residuals at different values of the explanatory variable. There does not appear to be any curvature in the relationship either.

6. Interpret the Transformed Slope.

Interpret the slope coefficient in the regression model using the log transformed variables.
Solution.
The regression equation is \(\hat{logprice} = 2.70 + 0.890\,logsqft\text{.}\)
If the log square footage increases by one (which corresponds to a ten-fold increase in square footage), we predicted the log price will increase by .890 (which corresponds to a \(10^{.89}\)-fold increase in price). If the log square footage is equal to 0 (square footage = 1), the predicted log price is 2.70 (price = \(10^{2.70}\)).

7. Back-Transformed Prediction.

Use the least squares regression line to predict the cost of a 3,000 square foot house.
Hint.
Substitute \(\log_{10}(3000)\) into the right-hand side of the equation to obtain a prediction for the \(\log_{10}(\text{price})\text{,}\) and then raise 10 to this power to determine the predicted price. Similarly, you can back transform the endpoints of the confidence and prediction intervals from R.
Solution.
\(\hat{logprice} = 2.70 + .890\,\text{logten}(3000) = 5.79\)
So the predicted price is \(10^{5.79} = \$623{,}215\text{.}\)

Discussion.

The log transformation has made improvements for both the normality condition and the equal variance condition. It is not uncommon for one transformation to β€œcorrect” more than one problem. We could continue to explore other transformations (e.g., square root and power transformations) until we find transformed data that are more appropriate for the basic regression model. Although these transformations are useful, we then have to be careful in how we interpret the regression coefficients and make predictions. If possible, it is usually most useful to β€œback-transform” to the original scale.

Subsection 27.5.2 Practice Problem 5.14

The datafile walmart.txt contains data on the number of stores and the number of SuperCenters that Wal-Mart had in operation between 1989 and 2002.

Checkpoint 27.5.1. Scatterplot Over Time.

Create a scatterplot of the number of SuperCenters that Wal-Mart has had in operation versus time.

Checkpoint 27.5.2. Basic Model Appropriate?

Would it be appropriate to use the basic regression model for these data? Explain.

Checkpoint 27.5.3. Square Root Transformation.

Transform the SuperCenters variable by taking the square root. Would it be appropriate to use the basic regression model for the relationship between this variable and year? Explain.

Checkpoint 27.5.4. Natural Log Transformation.

Transform the SuperCenters variable by taking the natural log. Would it be appropriate to use the basic regression model for the relationship between this variable and year? Explain.

Checkpoint 27.5.5. Choose a Model and Predict.

Choose the best model from either Question 3 or Question 4 (and justify your choice), find the least-squares regression equation and use it to predict how many SuperCenters Wal-Mart had in operation in 2003.

Checkpoint 27.5.6. Prediction Interval for 2003.

You have attempted of activities on this page.