Estimating Nonlinear Relationships
Since economic relationships are often not linear, we often need to allow for the possibility that the independent and dependent variable are nonlinearly related. Consider the following simple regression
price = ві + e2sqft + e (2.7)
The parameter, fi2 measures the expected change in price given an additional square foot of living space in the home. As specified, this marginal effect is the same for homes of every size. It might make more sense to allow the size of this marginal effect to depend on the size of the house. Larger houses also tend to be more luxurious and therefore another square foot of living area might add more to the average home price. This can be modeled by using a quadratic term in the model.
price = a1 + a2sqft2 + e (2.8)
The marginal effect of another square foot is now dprice/dsqft = 2a2sqft. The estimated elasticity is equal to
є = slOpe x = (2a2) X (2.9)
Obviously, the slope and elasticity depend on the size and price of the home. Thus, the user must select values at which these are to be evaluated. This is done in the script below where sloped for houses of size 2000, 4000, and 6000 square feet are computed. The elasticities are computed for prices of $117461.77, $302517.39, and $610943.42. The scalar and series that are used are not strictly necessary in gretl. I’ve used them here to make things more clear and it is a good programming practice in general.
1 open "@gretldirdatapoebr. gdt"
2 series sqft2 = sqft"2
3 ols price const sqft2
4 scalar slope_2000 = 2*$coeff(sqft2)*2000
5 scalar slope_4000 = 2*$coeff(sqft2)*4000
6 scalar slope_6000 = 2*$coeff(sqft2)*6000
7 scalar elast_2000 = slope_2000*2000/117461.77
8 scalar elast_4000 = slope_4000*4000/302517.39
9 scalar elast_6000 = slope_6000*6000/610943.42
The output from the regression is
price = 55776.6 + 0.0154213 sqft2
T = 1080 R2 = 0.6921 F (1,1078) = 2426.0 a = 68207.
(standard errors in parentheses)
and the graph of home price against size is shown in Figure 2.16.
Another way to estimate a nonlinear relationship between price and sqft is to alter the functional form of the model. A log-linear model uses the logarithm of a variable as the dependent variable, and the untransformed value of regressor as the independent variable. In the simple home price model this is
ln price = y1 + Y2sqft + e (2.10)
The logarithmic transformation is often used on data that come from a heavily skewed distribution that has a long-tail to the right. Taking a look at the histograms for price and it natural logarithm
shown in Figure 2.17 reveals just this sort of data and how the natural log can ‘regularize’ the series. These graphs were produced by first taking the natural log and then using the freq function to generate the graphs. The code is
1 series l_price = ln(price)
2 freq price
3 freq l_price