QM 4 Nonlinear Regression Functions 1
QM 4 Nonlinear Regression Functions 1
QM 4 Nonlinear Regression Functions 1
A. linear-log Yi = β0 + β1ln(Xi) + ui
B. log-linear ln(Yi) = β0 + β1Xi + ui
C. log-log ln(Yi) = β0 + β1ln(Xi) + ui
------------------------------------------------------------------------------
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0109613 .0018155 -6.04 0.000 -.0145248 -.0073978
_cons | 1.14752 .0857724 13.38 0.000 .9791665 1.315873
------------------------------------------------------------------------------
------------------------------------------------------------------------------
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0421672 .0116423 -3.62 0.000 -.0650187 -.0193157
age_sq | .0003414 .0001258 2.71 0.007 .0000944 .0005883
_cons | 1.790814 .2520151 7.11 0.000 1.29616 2.285468
------------------------------------------------------------------------------
------------------------------------------------------------------------------
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0421672 .0116423 -3.62 0.000 -.0650187 -.0193157
age_sq | .0003414 .0001258 2.71 0.007 .0000944 .0005883
_cons | 1.790814 .2520151 7.11 0.000 1.29616 2.285468
------------------------------------------------------------------------------
------------------------------------------------------------------------------
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
ln_age | -.4827743 .0759712 -6.35 0.000 -.63189 -.3336587
_cons | 2.465469 .2862441 8.61 0.000 1.903631 3.027306
------------------------------------------------------------------------------
------------------------------------------------------------------------------
ln_crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.007402 .002394 -3.09 0.002 -.0121021 -.0027019
_cons | -.1227536 .1104286 -1.11 0.267 -.3395562 .0940489
------------------------------------------------------------------------------
------------------------------------------------------------------------------
ln_crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
ln_age | -.3294411 .0994137 -3.31 0.001 -.5246183 -.134264
_cons | .7794874 .371791 2.10 0.036 .0495566 1.509418
------------------------------------------------------------------------------
That is, d(crra) / d(age) might be different for men and women
• One can also include an interaction term D1×D2 between the two
binary dummy variables:
• Marginal effects:
• = β1 + β3∙D2 - marginal effect of D1 depends on D2
• = β2 + β3∙D1 - marginal effect of D2 depends on D1
Example with two binary variables
• Linear regression model with interaction effects between two
dummy variables (2×2 combination)
• One can also include a new variable, which is an interaction term D×X
between the dummy and continuous variable:
• Marginal effects:
• = β1 + β3∙X - Marginal effect of D depends on X
• = β2 + β3∙D - Marginal effect of X depends on D
Example with binary and continuous variables
• Linear regression model with interaction effects between one
dummy (female) and one continuous (age) variable
------------------------------------------------------------------------------
| Robust
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
female | .2945737 .1720918 1.71 0.087 -.0432079 .6323553
age | -.0081911 .0021792 -3.76 0.000 -.0124685 -.0039138
female_age | -.0066059 .003923 -1.68 0.093 -.014306 .0010942
_cons | 1.015739 .1051843 9.66 0.000 .8092837 1.222195
------------------------------------------------------------------------------
Example with binary and continuous variables
• Model: crra = β0 + β1female + β2age + β3(female×age)
------------------------------------------------------------------------------
| Robust
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
female | .2945737 .1720918 1.71 0.087 -.0432079 .6323553
age | -.0081911 .0021792 -3.76 0.000 -.0124685 -.0039138
female_age | -.0066059 .003923 -1.68 0.093 -.014306 .0010942
_cons | 1.015739 .1051843 9.66 0.000 .8092837 1.222195
------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Robust
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
female | .2945737 .1720918 1.71 0.087 -.0432079 .6323553
age | -.0081911 .0021792 -3.76 0.000 -.0124685 -.0039138
female_age | -.0066059 .003923 -1.68 0.093 -.014306 .0010942
_cons | 1.015739 .1051843 9.66 0.000 .8092837 1.222195
------------------------------------------------------------------------------
.8
crra
.6
.4
.2
20 40 60 80
Age
Males Females
C. Two continuous variables
Yi = β0 + β1X1,i + β2X2,i + ui
• X1 and X2 are continuous
• One can also include an interaction term X1×X2 between the dummy
and continuous variables:
• Marginal effects:
• d(y)/d(X1) = β1 + β3∙X2
• d(y)/d(X2) = β2 + β3∙X1
Exercises
• Generate an interaction term between female and city, and
estimate a linear regression model with crra as a function
of female and city (including the interaction term)
• Are the estimated coefficients in the model significantly
different from 0?
• What is the marginal effect of female on crra?
• What is the marginal effect of city on crra?
Exercise: interaction effects
• crra = b0 + b1∙female + b2∙city + b3∙female∙city
------------------------------------------------------------------------------
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
female | .0800496 .0666721 1.20 0.230 -.0508135 .2109126
city | .0822605 .078421 1.05 0.294 -.0716631 .2361841
female_city | -.0624956 .10921 -0.57 0.567 -.2768514 .1518603
_cons | .5937362 .0466075 12.74 0.000 .5022556 .6852168
------------------------------------------------------------------------------
------------------------------------------------------------------------------
| Robust
crra | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
male_city | .6759966 .0514091 13.15 0.000 .5750915 .7769018
male_rural | .5937362 .0393311 15.10 0.000 .5165377 .6709347
female_city | .6935506 .0687072 10.09 0.000 .5586931 .8284081
female_rural | .6737857 .0536792 12.55 0.000 .5684249 .7791465
------------------------------------------------------------------------------
• Non-linear functions
• Non-linear transformations of variables
• Interaction effects
Extra exercises
• Use Risk_Lab.dta
• Run a regression of crra on age and age2
• Are the estimated coefficients significant? Are they jointly
significant?
• Construct a 95% confidence interval for the estimated coefficients
on age and age2
• What is the marginal effect of age on crra?
• What is the predicted crra value for a 20 year old and a 30 year
old?
• Generate a dummy variable for each risk task.
• Are individual risk attitudes constant across the four decision tasks?
• Is the effect of female on crra significantly different across the four
decision tasks?
Short summary of Appendix 8.1
• Nonlinear least squares estimation
• Suppose Y is a non-linear function of the parameters in the model
• One example is the logistic function (we discuss the so-called logit
model later)
• One can extend the OLS estimation method to account for non-
linear functions such as the logistic function
• Non-linear least squares estimation minimizes the sum of squared
residuals, just like ordinary least squares estimation
• Typically we use maximum likelihod estimation to estimate the
model parameters (more on that later)
Short summary of Appendix 8.2
• Slopes and elasticities
• Identify the model, Y as a function of X
• When you derive the marginal effect (slope) you differentiate Y with
respect to X
• The elasticity is defined in the usual way as the percentage change
in Y divided by the percentage change in X
• If we are interested in elasticities we typically use log-transformations
of both Y and X, and the marginal effect is then the same as the
elasticity