Skip to main content

Section 28.5 Investigation 5.14: Housing Prices

Exercises 28.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 stratum. 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.
  • Copy and paste the url for housing.txt into the data window of the Analyzing Two Quantitative Variables applet (below) and press Use Data (twice), being sure to put price on the y-axis and squarefoot on the x-axis (use the Change variable selections pull-down menus) to create a scatterplot of the size vs. selling price for this sample.
    • Make sure you have 83 observations
  • Use the applet to determine the least-squares regression line. (Check the Show Regression Line and R-squared boxes.)

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

Report the least-squares regression line for these data. Also report and interpret the value of \(r^2\) for these data.
Hint. R Instructions
Use lm for the regression line and summary for \(r^2\text{:}\)
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.
  • Check the Show residual plots box (under Explore models) in the applet to produce a histogram of the residuals (or a normal probability plot of the residuals), and a scatterplot of the residuals vs. the explanatory variable.

3. Residual Normality.

Is it reasonable to consider the residuals as following the normal distribution? Explain.
Hint. R Instructions
Access the residuals with lm(price~sqft)$residuals:
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.
  • Examine the scatterplot of the residuals vs. the square footage (also shown by Show residual plots).

4. Residual Pattern Checks.

Does there appear to be curvature in this graph?
Curvature (Yes/No):
Does the variability in the residuals appear to be roughly constant across the graph?
Roughly constant (Yes/No):
Hint. R Instructions
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.
  • Check the Show transformations box (under Explore models) in the applet.
  • Check the log10 (log base ten) radio button for both the response variable and the explanatory variable. This will take the log base 10 of both the price and square footage variables. (If Show residual plots is still checked, the residual plots update to the transformed model.)

5. Log Transformation.

Examine the scatterplot of the transformed variables. Do these transformed variables appear to be more suitable for the basic regression model? Explain.
Hint 1.
Keep in mind that R and JMP use β€œlog” for natural log. Use β€œlog10” in R and JMP for log base 10.
Hint 2. R Instructions
Create the transformed variables with log10, then refit and examine the residual plots:
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.
Predicted price: $
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{log10}(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 28.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 28.5.1. Scatterplot Over Time.

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

Checkpoint 28.5.2. Basic Model Appropriate?

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

Checkpoint 28.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 28.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 28.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 28.5.6. Prediction Interval for 2003.

You have attempted of activities on this page.