* This program is for replicating Table 6.4 in the WandB textbook.
set more 1
use happy
gen rfaminc = faminc
replace rfaminc = faminc/1.020356234 if year == 85
replace rfaminc = faminc/1.019083969 if year == 86
replace rfaminc = faminc/1.021628499 if year == 87
replace rfaminc = faminc/1.034351145 if year == 88
replace rfaminc = faminc/1.063613232 if year == 89
replace rfaminc = faminc/1.091603053 if year == 90
replace rfaminc = faminc/1.132315522 if year == 91
replace rfaminc = faminc/1.176844784 if year == 92
replace rfaminc = faminc/1.218829517 if year == 93
replace rfaminc = faminc/1.251908397 if year == 94
replace rfaminc = faminc/1.272264631 if year == 95
replace rfaminc = faminc/1.288804071 if year == 96
replace rfaminc = faminc/1.312977099 if year == 97
gen hap4 = happy
recode hap4 0/5 = 1 6/7=2 8=3 9/10=4
gen age = 1900+year-gebjahr
gen agesq = age^2
tab hap4
gen rlinc = log(rfaminc)
* Reproducing the first column of Table 6.4 - the ordered logit
ologit hap4 age agesq health rlinc unemp
* The odds ratio form of the equation with accompanying Brant test o
* of the Single Index (Parallel Regressions) Assumption. If the null hypothesis of
* Parallel Regressions is rejected we should go to the generalized
* ordered logit model that is estimated in gologit or gologit2. In
* the case of the Happy data the null hypothesis of the Single Index
* is rejected. Use generalized ordered logit model which is reported below.
ologit hap4 age agesq health rlinc unemp, or
brant, detail
* Using the glogit2 command for estimating the generalized ordered logit model
* This routine was authored by Richard Williams. See Williams_gologit2.pdf
gologit2 hap4 age agesq health rlinc unemp
* The odds ratio form of the equation
gologit2 hap4 age agesq health rlinc unemp, or
* Now for the computation of the Likelihood Ratio test of the Single Index hypothesis.
* From the Ordered Logit model above we have a log likelihood value of -5680.0843.
* This is the restricted model that imposes the Single Index assumption.
* From the above Generalized Ordered Logit model we obtain the log likelihood
* value of -5667.3121. This represents the fit of the unrestricted model because
* we are not imposing the Single Index assumption. Then the likelihood ratio
* statistic is -2log(lambda) = -2(logl(restricted model) - logl(unrestricted model))
* = -2(-5680.0843 -(-5667.3121)) = -2(-12.7722) = 25.5444.
* The number of degrees of freedom of the chi-square test is 18 - 8 = 10
* where the number of parameters in the unrestricted model (gologit2) is 18
* while the number of parameters in the restricted model (ologit) is 7.
* It follows that the p-value associated with the observered statistic of
* 25.5444 is 0.004404 < 0.05. Therefore we reject the null hypothesis of a
* Single Index. You can use the EXCEL function chisq.dist.rt to obtain
* this probability value. Therefore, we see that the Brant and
* Likelihood Ratio tests give the same result. The generalized ordered logit model
* (gologit2) is to be preferred. That is, the Generalized Ordered Logit model, in this
* case, is to be preferred over the Stanard (Single Index) Ordered Logit model.