Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Nonlinear econometrics for finance

Sample regression

Real estate is a key asset. Investing in real estate represents the biggest investment decision for most households over their lifetimes.  A real estate company in Baltimore wants to estimate a model to relate the house prices to several characteristics of the house.  The data come from Zillow and consists of a sample of houses in the Baltimore area for the year 2014. The data are contained in the le housing data.xslx and provide the following information:

1.  Zillow id of the house (id)

2. price in dollars (price)

3. street address (street)

4. postal code (zip)

5. year the house was built (yearBuilt)

6. size of the house measured in square feet (sqft)

7. number of bathrooms (bathrooms)

8. number of bedrooms (bedrooms).

Given this information, you need to analyze house prices using Python.

1.  Generate a histogram of the house prices and compute descriptive statistics (mean, median, variance, standard deviation, minimum, maximum). What do you notice?

Answer.  The histogram of the prices is shown in Figure 1 (top panel).  The de- scriptive statistics are shown in the table below:

Mean     Median  Max       Min       Std.Dev. Variance

221436

196003

1114086

23651

148332

22002505131

From the gure, we observe that there are a few outliers (in the right tail) and the distribution of the prices is not symmetric.

 

Figure 1: Histograms of prices and log-prices

2. Now, take a log transformation of the house prices.   Plot the histogram of the log-prices. What do you notice?

Answer.  The distribution of the log-prices is considerably more bell-shaped.  In the regression below, we will therefore assume that the errors are normal.   One thing that we should take into account when moving from prices to log-prices is that the regression coefficients should be interpreted differently (see the response to Question 4).

3. Run a regression of the log-prices on the explanatory variables:

log(pricei ) = β0 + β1 agei + β2 sizei + β3 bathroomsi + β4 bedroomsi + εi where εi  is an error term.

Answer. The following table reports the estimated coefficients, the standard errors, the t statistics (for testing H0   : βj   = 0 Aj) and the p-values (again, for testing H0  : βj  = 0 Aj):

variable

βˆ

se(βˆ)

t stats

p-values

constant

11.224

0.088575

126.71

0

age

0 0013385

0 00055896

2 3946

0 016906

size

0.00050645

0.0000439

11.534

0

bathrooms

0.35332

0.027232

12.974

0

bedrooms

-0.26537

0.023925

-11.091

0

4. Interpret the coefficients of the regression above. What does the model say about the house prices?

Answer. The dependent variable is in logs. This means that each coefficient should be interpreted as the percentage change in price if we change the corresponding regressor by one unit, keeping everything else fixed. Let us focus on age, for example, but the same logic applies to all regressors. Because

log(pricei ) = β0 + β1 agei + β2 sizei + β3 bathroomsi + β4 bedroomsi + εi ,

we have that

 = β1  ÷  = β1  ÷  = β1 ,

since the derivative of the log-price with respect to price is one over the price (i.e.,    = 1/pricei ).  Thus, β1  represents the percentage price change when we increase the age of the house by one year, keeping everything else the same.  One can think of it as the return on the house if we keep it for another year and sell it next year, without doing any renovation or changes (everything else being the same).

As most realtors would suggest, there is value in adding one bathroom to your house.  Indeed, our estimates suggest that if we add one bathroom, the price will go up by an average of 35%. And, of course, bigger houses are more expensive.

5. Why do you think the number of bedrooms has a negative effect on the log-price?

Answer. A possible explanation is that everything else equal (so, given the overall size of the house), an additional bedroom implies that each bedroom is smaller in size.  The living areas could be smaller too, which may also negatively affect the overall value of the house.

6. We want to test whether the effect of age on log-prices is statistically significant. What test would you use? Compute the test statistic and interpret the result.

Answer.  The hypothesis test has the null H0  : β1  = 0 and the alternative Ha  : β1   0. The test statistic for this hypothesis is

βˆ1  - 0   d

se(βˆ1 ) tn_k ,                  (1)

where tn_k  is the t distribution with n - k degrees of freedom, n is the number of observations and k is the number of regressors. In our model, k = 5 (I am including the column of ones in the regressors because it is associated with the intercept). At the 5% level, we reject if the t statistic is larger than (about) 2 in absolute value. Similarly, we reject if the p-value of the test is smaller than 5%. The t statistic is 2.3946. It is larger than 2, so we reject the null hypothesis. The p-value of the test is 0.0169 which, once more, leads to rejection. Thus, βˆ1  is statistically significant” (which means that it is  statistically different from zero”).  Said differently, age seems to matter as a predictor.

7. Test whether age and size are jointly different than zero.

Answer. This is a test of the following joint hypothesis:

H0  : β1  = 0 and β2  = 0

against the alternative hypothesis

Ha  : either β1   0 or β2   0.

We cannot use a t statistic for this test. The reason is that we are testing 2 linear restrictions, not just one.  We can, however, use an F test.  We set up the null hypothesis in the following way. Let R be the matrix

0   1   0   0   0

and let γ = [0 0]T . Thus, we can write the null hypothesis as

β0

Rβ = γ        =  ╱  、0(0) .

β4

The test statistics for this test is

F   =

8. Test whether β1  = 2β2 .

Answer. This is a single linear restriction on the coefficients. We can indeed write the null hypothesis as H0  : β1  - 2β2  = 0 and the alternative as Ha  : β1  - 2β2    0. In matrix notation, we define the vector c = [0 1  - 2 0 0]T  and the scalar γ = 0, and write the null hypothesis as

cT β = γ 0

β(β)1(0)

1   -2   0   0.(.) β2  .(.)  = 0.

β(β)4(3).                                    (2)

Because there is only one restriction,  we could test the null hypothesis by us- ing a classical t statistic (see lecture notes on linear econometrics, Chapter 1, in OneDrive):

 cT  - γ         d

p-value = 0.562 > 0.05). The restriction is supported by the data. Alternatively, we could use a one-sided F test:

 

σ 2 (n_k)

9. Using your model, predict the price of a house with 3 bedrooms, 3 bathrooms, size of 3500 square feet and built in 1985. Explain how you compute your prediction.

Answer.  To predict the log price we just plug the values of the regressors in the estimated model and obtain

log一(pricei ) = βˆ0 + βˆ1 Agei + βˆ2 sizei + βˆ3 bathroomsi + βˆ4 bedroomsi                   (3)

where the βˆk for k = 0, 1, 2, 3, 4 are estimated by least squares. One may be tempted to predict the prices in levels (pricei ) as

pricei  = elog(pricei)  = e[βˆγ+βˆ1 Agei+βˆ2 sizei+βˆ3 bathroomsi+βˆ bedroomsi]              (4)

but this is not completely exact (even though it will not be penalized).  If we are interested in predicting price levels, we need to apply a simple correction based on the following result.

Aside/  If X is a normal random variable, X  N (µ, σ2 ), and we define another random variable Y  = eX ,  then Y  is  a log-normal random variable.   Specifically, Y = eX    log N (m, v) with mean m = eµ+   and variance v = [eσ 2   - 1]e2µ+σ2 . You will see the same result in derivatives in the context of the Black and Scholes option pricing model.

Since our error terms look normal (after the log transformation), then log(pricei )  N (xi β, σ 2 ). So, we can assume that the prices are log-normal, that is

pricei  = elog(pricei)   log N (mi , vi ),

where, as before in the aside, the letters m and v stand for the mean and variance of the log-normal distribution.  In our case, the mean mi  is mi  = xi β +  . Thus, our prediction for the price of the house is

pricei  = eβˆγ+βˆ1 Agei+βˆ2 sizei+βˆ3 bathroomsi+βˆ bedroomsi+ n(ε)L(十)k(ε) ,                (5)

where we have substituted the value σ2 in the formula for the mean of the log-normal

random variable with its estimator 2  =n(ε)_(十)k(ε) .