Hi everyone,
I am having trouble in estimating marginal effects after a user-written ordinal probit. The ordinal probit runs well but I get "variable __000001 not found" after the code for marginal effects. I have adapted the following code of a multinomial logic to my ordinal probit http://www.stata.com/statalist/archi.../msg00113.html
Can anyone tell me what I am doing wrong ? I am using an updated version of Stata 11.2 in a Mac. I have replicated this problem in a public data:
I am having trouble in estimating marginal effects after a user-written ordinal probit. The ordinal probit runs well but I get "variable __000001 not found" after the code for marginal effects. I have adapted the following code of a multinomial logic to my ordinal probit http://www.stata.com/statalist/archi.../msg00113.html
Can anyone tell me what I am doing wrong ? I am using an updated version of Stata 11.2 in a Mac. I have replicated this problem in a public data:
Code:
cap program drop lfoprobit1 program lfoprobit1 args lnf xb a1 a2 local y "$ML_y1" quietly replace `lnf' = ln( normal(`a1'-`xb')) if `y'==1 quietly replace `lnf' = ln( normal(`a2'-`xb') - normal(`a1'-`xb')) if `y'==2 quietly replace `lnf' = ln(1-normal(`a2'-`xb')) if `y'==3 end cap program drop lfoprobit6 program lfoprobit6, eclass ml model lf lfoprobit1 (rep78 = foreign length mpg, nocons) /cut1 /cut2 ml search, repeat(100) ml maximize, difficult eret local cmd="lfoprobit6" eret local predict="lfoprobit6_p" end cap program drop lfoprobit6_p program define lfoprobit6_p syntax newvarlist [if] [in], [ p1 p2 p3] tempvar xb2 xb3 xb4 touse marksample touse qui _predict double `xb2' if `touse', xb equation(#1) qui _predict double `xb3' if `touse', xb equation(#2) qui _predict double `xb4' if `touse', xb equation(#3) if "`p1'"!=""{ gen double `varlist'=normprob(_b[/cut1]-`xb2') } else if "`p2'"!=""{ gen double `varlist'=normprob(`xb3' - _b[/cut1]) - normprob(`xb3' - _b[/cut2]) } else if "`p3'"!=""{ gen double `varlist'=normprob(`xb4' - _b[/cut2]) } label var `varlist' end clear sysuse auto replace rep=1 if rep==2 | rep==5| rep==. recode rep (3=2) recode rep (4=3) lfoprobit6 I get : rep78 Coef. Std. Err. z P>z [95% Conf. Interval] eq1 foreign .2548369 .3573541 0.71 0.476 -.4455643 .9552381 length -.0035718 .0111222 -0.32 0.748 -.025371 .0182274 mpg -.0478152 .0398704 -1.20 0.230 -.1259598 .0303293 cut1 _cons -1.998984 2.835411 -0.71 0.481 -7.556287 3.55832 cut2 _cons -.9009799 2.832889 -0.32 0.750 -6.45334 4.65138 mfx, predict(p1) nonlinear I get : variable __000001 not found mfx, predict(p2) nonlinear mfx, predict(p3) nonlinear I get the same than above. margins, dydx(*) predict(p1) I get : variable __marg_pvar_1 not found