 Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

Re: st: AW: Generalized residuals after ordered probit estimation

 From svsteink@uni-osnabrueck.de To statalist@hsphsun2.harvard.edu Subject Re: st: AW: Generalized residuals after ordered probit estimation Date Sun, 23 Oct 2011 11:25:16 +0200 (CEST)

Ahhhh, my new code seemed to work in two datasets but the results in the
third one indicate that it's still wrong:

____________________________
//In order to make the notations more comparable to Machin/Stewart (1990):
local i = 1
gen constant = - _b[/cut1]
while (`i' < e(k_cat)-1){
local u`i'
gen u`i' = _b[/cut`=`i'+1'] - _b[/cut`i']
local i = `i' + 1
}

//For notational brevity:
predict `xb_hat', xb
local i = 1
gen w0 = - `xb_hat' - constant
while (`i' < e(k_cat)-1){
local w`i'
gen w`i' = u`i' - `xb_hat' - constant
local i = `i' + 1
}

//Creates generalized residuals:
gen `gen_r' = 0
replace `gen_r' = (-normalden(w0))/(normal(w0))  if (`y' == 0)
replace `gen_r' = normalden(w`=`cut'-1')/(1 - normal(w`=`cut'-1'))  ///
if (`y' == `cut')
local i = 1
while (`i' < `cut'){
replace `gen_r' = (normalden(w`=`i'-1') -normalden(w`i'))/   ///
(normal(w`i')-normal(w`=`i'-1')) if (`y' == `i')
local i = `i' + 1
}

//diagnostics
qui sum `gen_r1'
gen zero = r(sum)
di zero                     //should be zero
________________________

Many thanks,
Sven

> Dear Stata-Listers,
>
>
> http://www.stata.com/support/faqs/stat/ologit_con.html
>
>
> Sorry to have bothered you,
> Sven
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von
> svsteink@Uni-Osnabrueck.DE
> Gesendet: Samstag, 22. Oktober 2011 19:43
> An: statalist@hsphsun2.harvard.edu
> Betreff: st: Generalized residuals after ordered probit estimation
>
> Dear Stata-Listers,
>
>
> I have some problems in calculating the generalized residuals after the
> estimation of an ordered probit model.
> For y = [0,1,2] it should be something like this:
>
> predict `xb_hat', xb
> gen r = 0
> replace r = (-normalden(_b[/cut1] - xb_hat))/(normal(_b[/cut1] - xb_hat))
> if  (y == 0) replace r = (normalden(_b[/cut1] - xb_hat) -
> normalden(_b[/cut2] -  xb_hat))/(normal(_b[/cut2] -
> xb_hat)-normal(_b[/cut1] - xb_hat))  if (y == 1)
> replace r = normalden(_b[/cut2] - xb_hat)/(1 - normal(_b[/cut2] - xb_hat))
>  if (y == 2)
>
> Unfortunately, the sum of my residuals is never even close to zero. Do you
> Perhaps I didn't really understood Stata's parameterization of the
> constant/cutpoints?
>
> Thanks,
> Sven
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/