* The World Health Report
*
* Keywords:
* regression, ols, f-test, wald test, world health report, who
*
* Description:
* We illustrate how to estimate linear OLS models for life expectancy, derived
* on the data from the World Health Report, and how to test the significance
* of coefficients using F and Wald tests
*
* Author(s):
* Noel Roy
* Skif Pankov
*
* Source:
* William H. Greene, Econometric Analysis - 7th Edition
* Pearson International Edition, Chapter 6, Example 6.10 (page 213)
*
* Reading the datafile and naming the variables, specifying to ignore the
* first 2 lines of the file
read (TableF6-3.shd) comp dale year hexp hc3 small country groupti oecd gini geff &
voice tropics popden pubthe gdpc / skiplines=2
* Turning off warnings of skipped observations
set nowarnskip
* Skipping observations when year is not 1997
skipif (year .ne. 1997)
* The dataset includes political subunits of countries, which must be extracted.
* Skip observations when small is greater than 0 (0 implies country unit)
skipif (small .gt. 0)
* Generating the square of education variable
genr hc3sq = hc3**2
* Running OLS regressions for all countries
ols dale hexp hc3 hc3sq
ols dale hexp hc3 hc3sq gini tropics popden pubthe gdpc geff voice
* Testing significance of the additional variables in the second regression
* using an F-test
test
test gini
test tropics
test popden
test pubthe
test gdpc
test geff
test voice
end
* Saving the Sum of Squred Errors, numbers of observations and coefficients from
* previous regression in separate variables
gen1 sse=$sse
gen1 k=$k
gen1 n=$n
* Skipping if country is not in the oecd
skipif (oecd .eq. 0)
* Running the regressions above for the OECD countries only, specifying to save
* the estimated coefficients and covariance matrix in separate variables
ols dale hexp hc3 hc3sq
ols dale hexp hc3 hc3sq gini tropics popden pubthe gdpc geff voice / coef=theta1 cov=v1
* Testing the significance of additional variables
test
test gini
test tropics
test popden
test pubthe
test gdpc
test geff
test voice
end
* Saving sum of squared errors (sse) to test for structural break
gen1 sse1=$sse
* Non-oecd regressions
* We must restore the non-oecd countries to the sample by removing the skip
* indicators
delete skip$
* Restoring the skipping of all except 1997 countries
skipif (year .ne. 1997)
skipif (small .gt. 0)
* Skipping if the country is an OECD member
skipif (oecd .eq. 1)
* Running the regressions above for the non-OECD countries, specifying to save
* the estimated coefficients and covariance matrix in separate variables.
ols dale hexp hc3 hc3sq
ols dale hexp hc3 hc3sq gini tropics popden pubthe gdpc geff voice /coef=theta2 cov=v2
* Testing the significance of additional variables
test
test gini
test tropics
test popden
test pubthe
test gdpc
test geff
test voice
end
* Saving the sum of squared errors (sse) to test for structural breaks
gen1 sse2=$sse
* Calculating F-statistic for structural break
gen1 f = ((sse-(sse1+sse2))/k)/((sse1+sse2)/(n-2*k))
* Outputting the F-statistic
print f
* Calculating degrees of freedom
gen1 df=n-2*k
* Computing the probability density function (pdf) and the cummulative density
* function (cdf) for variable f, specifying that it has an F-distribution with k and
* df degrees of freedom - this gives the value of the test statistic
distrib f / type=f df1=k df2=df
* Calculating Wald test statistic w in equation using shazam's matrix
* manipulation capabilities.
matrix w = (theta1-theta2)'inv(v1+v2)(theta1-theta2)
* Outputting w
print w
* The wald statistic is asymptotic chi-square, so we can use the distrib
* command to calculate its p value
distrib w / type=chi df=k
stop