* Analysis of Nonlinear Consumption Function
*
* Keywords:
* regression, nonlinear, consumption, function, f-test, lagrange
*
* Description:
* We illustrate how to estimate a Nonlinear specificatoin of the Consumption
* Function and perform hypothesis testing and confidence interval estimation,
* specifically we do an F-test and a Lagrange Multiplier test
*
* Author(s):
* Noel Roy
* Skif Pankov
*
* Source:
* William H. Greene, Econometric Analysis - 7th Edition
* Pearson International Edition, Chapter 7, Example 7.4 (page 231)
*
* Reading the datafile and naming the variables, specifying to ignore the
* first line of the file
read (TableF5-2.shd) year qtr gdp c inv g y cpi m1 r / skiplines=1
* Estimating the linear OLS model
ols c y
* Estimating a nonlinear model of consumption on output with 1 equation and 3
* coefficients to estimate, specifying to print the covariance matrix and save
* estimated coefficients in a vector x
nl 1 / ncoef=3 pcov coef=x
eq c=alpha+beta*y**gamma
end
* Testing a coefficient restriction on a previous model
test gamma=1
* Testing the hypothesis that the mpc in the previous model equals 1
test beta*gamma*6634.9**(gamma-1)=1
* Even if convergence takes place, all that can be assured is convergence
* to a local maximum. It is good practice in non-linear estimation to try
* several starting values for the coefficients in order to ensure that
* convergence to a global maximum has occurred. In the present case,
* since the estimate for gamma is greater than 1, it would be worthwhile to
* try a starting value less than 1, say 0.5
genr newy=y**0.5
?ols c newy /coef=newb
* An alternative to the coef command is to read starting values into a
* vector and specify this vector with the start= option. The starting
* values must be placed in the order they appear in the eq command
dim st 3
gen1 st(1)=newb(2)
gen1 st(2)=newb(1)
gen1 st(3)=0.5
nl 1 / ncoef=3 pcov start=st iter=250
eq c=alpha+beta*y**gamma
end