On 20.08.2022 13:58, Cottrell, Allin wrote:
On Sat, Aug 20, 2022 at 6:20 AM Marcin Błażejowski
<marcin(a)wrzosy.nsb.pl> wrote:
> I'd like to estimate Ordered Logit and create discrete predicted values
> (inside a sample). Simple script:
>
> <hansl>
> set verbose off
> open wtp.gdt
> list X = 1 2 9 10 11
>
> yvalues = values(depvar)
>
> logit depvar 0 X
> cuts = $coeff[$model["nx"]+1:end]
>
> YHAT = ($yhat .<= cuts[1]) * yvalues[1]
> loop i=2..nelem(cuts) --quiet
> YHAT += (($yhat .> cuts[i-1]) && ($yhat .<= cuts[i])) *
yvalues[i]
> endloop
> YHAT += ($yhat .> cuts[end]) * yvalues[end]
> series yhat = YHAT
>
> printf "\ncorrectly predicted: (model) %d vs. (manual) %d\n",
> $model["correct"], sum(depvar == yhat)
> </hansl>
>
> What am I doing wrong?
I recommend looking at the code and documentation for the
oprobit_predict function package (which covers ordered logit as well
as probit).
Thanks, Allin. Now I see what is going on.
Marcin
--
Marcin Błażejowski