Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Right Censored ordered probit with Stata 11


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Right Censored ordered probit with Stata 11
Date   Mon, 26 Sep 2011 08:14:48 +0100

As far as I can tell you are ignoring Austin's advice in his last email.

I can't illuminate what is happening with your code and data.

Nick

On Mon, Sep 26, 2011 at 3:50 AM, Urmi Bhattacharya <[email protected]> wrote:
> Hi Nick and Austin,
>
> Thank you so much for your suggestions. I put the
> set trace on
> set traced 1
>
> followed by Owen's code and the simulation. It identified some errors
> I could correct by  wrapping up the unwrapped lines . But I am getting
> an error now and I can't understand what is causing it. I am providing
> the result that I am getting
>
> - version 11.0
>  - if replay() {
>    if "`e(cmd)'" != "coprbt" {
>    error 301
>    }
>    syntax [, level(passthru)]
>    }
>  - else {
>  - syntax varlist [if] [in] , censored(varname) [level(passthru) *]
>  - marksample touse
>  - preserve
>  - qui keep if `touse'
>  = qui keep if __000000
>  - gettoken depvar indepvars : varlist
>  - tempvar newdepvar
>  - egen `newdepvar'=group(`depvar')
>  = egen __000001=group(y)
>  - qui sum `newdepvar'
>  = qui sum __000001
>  - local maxvalue =r(max)
>  - forvalues i=1(1)`maxvalue' {
>  = forvalues i=1(1)3 {
>  - tempvar ucsample sumucs
>  - qui gen `ucsample'=0
>  = qui gen __000002=0
>  - qui replace `ucsample'=(`censored'!=1) if (`newdepvar'==`i')
>  = qui replace __000002=(c!=1) if (__000001==1)
>  - qui gen `sumucs'=sum(`ucsample')
>  = qui gen __000003=sum(__000002)
>  - local errorcount =0
>  - capture assert `sumucs'[_N]>0&`sumucs'[_N]<.
>  = capture assert __000003[_N]>0&__000003[_N]<.
>  - if _rc==9 {
>    di as error "WARNING: value number `i' has no uncensored obs"
>    }
>  - drop `sumucs'
>  = drop __000003
>  - drop `ucsample'
>  = drop __000002
>  - }
>  - tempvar ucsample sumucs
>  - qui gen `ucsample'=0
>  = qui gen __000004=0
>  - qui replace `ucsample'=(`censored'!=1) if (`newdepvar'==`i')
>  = qui replace __000004=(c!=1) if (__000001==2)
>  - qui gen `sumucs'=sum(`ucsample')
>  = qui gen __000005=sum(__000004)
>  - local errorcount =0
>  - capture assert `sumucs'[_N]>0&`sumucs'[_N]<.
>  = capture assert __000005[_N]>0&__000005[_N]<.
>  - if _rc==9 {
>    di as error "WARNING: value number `i' has no uncensored obs"
>    }
>  - drop `sumucs'
>  = drop __000005
>  - drop `ucsample'
>  = drop __000004
>  - }
>  - tempvar ucsample sumucs
>  - qui gen `ucsample'=0
>  = qui gen __000006=0
>  - qui replace `ucsample'=(`censored'!=1) if (`newdepvar'==`i')
>  = qui replace __000006=(c!=1) if (__000001==3)
>  - qui gen `sumucs'=sum(`ucsample')
>  = qui gen __000007=sum(__000006)
>  - local errorcount =0
>  - capture assert `sumucs'[_N]>0&`sumucs'[_N]<.
>  = capture assert __000007[_N]>0&__000007[_N]<.
>  - if _rc==9 {
>    di as error "WARNING: value number `i' has no uncensored obs"
>    }
>  - drop `sumucs'
>  = drop __000007
>  - drop `ucsample'
>  = drop __000006
>  - }
>  - local k =`maxvalue'-1
>  = local k =3-1
>  - global OGLFXH "`censored'"
>  = global OGLFXH "c"
>  - qui oprobit `newdepvar' `indepvars'
>  = qui oprobit __000001  x1 x2 x3
>  - tempname starting
>  - matrix `starting'=e(b)
>  = matrix __000008=e(b)
>  - tempname cutvector
>  - matrix `cutvector'=`starting'[1,"_cut1".."_cut`k'"]
>  = matrix __000009=__000008[1,"_cut1".."_cut2"]
>
> _cut2 not found
>
>    forvalues i=1(1)`k' {
>    local cut`i'=`cutvector'[1,`i']
>    local initlist "`initlist' /_cut`i'=`cut`i''"
>    local cutlist "`cutlist' /_cut`i'"
>    }
>    foreach var of local indepvars {
>    local `var'_b =`starting'[1,colnumb(`starting',"`var'")]
>    }
>    foreach var of local indepvars {
>    local initlist "`initlist' `var'=``var'_b'"
>    }
>    ml model lf coprbt_ll (`newdepvar'=`indepvars' , nocons ) `cutlist'
>    if `touse' , maximize title("Homemade Censored Ordered Probit")
> init(`initlist') `options'
>    ereturn local cmd "coprbt"
>    }
>
> r(111);
>
> end of do-file
>
> r(111);
>
> The "_cut2 not found" is in red suggesting that is where the problem
> is, but I cannot figure out what is causing it.
>
> Any suggestions?
>
> Thanks a lot.
>
> Urmi
> On Sat, Sep 24, 2011 at 8:14 PM, Austin Nichols <[email protected]> wrote:
>> Urmi Bhattacharya <[email protected]>:
>> I also guess that you have not got the line structure right in your
>> files, but I will also note that a quick simulation I ran indicated
>> that -oprobit- run only on uncensored obs outperforms unrestricted
>> -oprobit- and -coprbit-.  So start with
>>
>> .  oprobit y x1 x2 x3 if censored==0
>>
>> I am also guessing that other models would outperform all 3 options
>> mentioned here, but that will have to wait for another day.
>>

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index