Hello everybody,
I am trying to fit a model for dummy endogenous variables by maximum likelihood. However, I obtain an error message. Here is the code:
The first part for the individual likelihood contributions
program stackelberg_likelihood_theta
version 13.0
args lnf theta1 theta2 theta3 theta4 theta5 theta6
quietly replace `lnf'=ln(binormal(-`theta1',-`theta2',`theta6')-(binormal(-`theta1',-`theta2',`theta6')-binormal(-`theta1'-`theta3',-`theta2',`theta6')-binormal(-`theta1',-`theta2'-`theta5',`theta6')+binormal(-`theta1'-`theta3',-`theta2'-`theta5',`theta6'))) if $ML_y1==0 & $ML_y2==0 & `theta5'>=0
quietly replace `lnf'=ln(binormal(-`theta1',-`theta2',`theta6'))if $ML_y1==0 & $ML_y2==0 & `theta5'<0
quietly replace `lnf'=ln(binormal(`theta1',-`theta2'-`theta5',-`theta6'))if $ML_y1==1 & $ML_y2==0 & `theta5'>=0
quietly replace `lnf'=ln(binormal(`theta1',-`theta2'-`theta5',-`theta6')+(binormal(-`theta1',-`theta2'-`theta5',`theta6')-binormal(-`theta1',-`theta2',`theta6')-binormal(-`theta1'+`theta4',-`theta2'-`theta5',`theta6')+binormal(-`theta1'+`theta4',-`theta2',`theta6')))if $ML_y1==1 & $ML_y2==0 & `theta5'<0
quietly replace `lnf'=ln(binormal(-`theta1'-`theta3'+`theta4',`theta2',-`theta6'))if $ML_y1==0 & $ML_y2==1 & `theta5'>=0
quietly replace `lnf'=ln(binormal(-`theta1'-`theta3'+`theta4',`theta2',-`theta6')+(binormal(-`theta1'+`theta4',-`theta2'-`theta5',`theta6')-binormal(-`theta1'+`theta4',-`theta2',`theta6')-binormal(-`theta1'-`theta3'+`theta4',-`theta2'-`theta5',`theta6')+binormal(-`theta1'-`theta3'+`theta4',-`theta2',`theta6')))if $ML_y1==0 & $ML_y2==1 & `theta5'<0
quietly replace `lnf'=ln(binormal(`theta1'+`theta3'-`theta4',`theta2'+`theta5',`theta6')-(binormal(-`theta1'-`theta3',-`theta2',`theta6')-binormal(-`theta1'-`theta3',-`theta2'-`theta5',`theta6')-binormal(-`theta1'-`theta3'+`theta4',-`theta2',`theta6')+binormal(-`theta1'-`theta3'+`theta4',-`theta2'-`theta5',`theta6')))if $ML_y1==1 & $ML_y2==1 & `theta5'>=0
quietly replace `lnf'=ln(binormal(`theta1'+`theta3'-`theta4',`theta2'+`theta5',`theta6'))if $ML_y1==1 & $ML_y2==1 & `theta5'<0
end
And the second part which should fit the model. d_pd and d_m0 are dummy variables which are the dependent variables. theta1 should be a function of unemployment and gdp_grwoth and theta2 should be a function of inflation. theta3, theta4, theta5 and theta6 should only be simple estimates, i.e. just explained by a constant.
ml model lf stackelberg_likelihood_theta (d_pd = unemployment gdp_growth) (d_m0 = inflation) () () () ()
ml check
Ouput:
. ml check
Test 1: Calling stackelberg_likelihood_theta to check if it computes log
likelihood and
does not alter coefficient vector...
FAILED; stackelberg_likelihood_theta returned error 133.
Here is a trace of its execution:
------------------------------------------------------------------------------
-> stackelberg_likelihood_theta __00000I __00000J __00000K __00000L __00000M __00000N __00000O
- `begin'
= capture noisily version 13: stackelberg_likelihood_theta __00000I __00000J __00000K __00000L __00000M __00000N __00000O
------------------------------------------------------------------------------------------------------------------ begin stackelberg_likelihood_theta ---
- version 13.0
- args lnf theta1 theta2 theta3 theta4 theta5 theta6
- quietly replace `lnf'=ln(binormal(-`theta1',-`theta2',`theta6')-(binormal(-`theta1',-`theta2',`theta6')-binormal(-`theta1'-`theta3',-`theta2',`theta6')
> -binormal(-`theta1',-`theta2'-`theta5',`theta6')+binormal(-`theta1'-`theta3',-`theta2'-`theta5',`theta6'))) if $ML_y1==0 & $ML_y2==0 & `theta5'>=0
= quietly replace __00000I=ln(binormal(-__00000J,-__00000K,__00000O)-(binormal(-__00000J,-__00000K,__00000O)-binormal(-__00000J-__00000L,-__00000K,__0000
> 0O)-binormal(-__00000J,-__00000K-__00000N,__00000O)+binormal(-__00000J-__00000L,-__00000K-__00000N,__00000O))) if d_pd==0 & d_m0==0 & __00000N>=0
- quietly replace `lnf'=ln(binormal(-`theta1',-`theta2',`theta6'))if $ML_y1==0 & $ML_y2==0 & `theta5'<0
= quietly replace __00000I=ln(binormal(-__00000J,-__00000K,__00000O))if d_pd==0 & d_m0==0 & __00000N<0
unknown function ()
-------------------------------------------------------------------------------------------------------------------- end stackelberg_likelihood_theta ---
- `end'
= set trace off
------------------------------------------------------------------------------
Fix stackelberg_likelihood_theta.
So the error that occurs is unknown function () but I have no idea why... It would be fantastic if anybody could help me out.
Best, Lorenz
I am trying to fit a model for dummy endogenous variables by maximum likelihood. However, I obtain an error message. Here is the code:
The first part for the individual likelihood contributions
program stackelberg_likelihood_theta
version 13.0
args lnf theta1 theta2 theta3 theta4 theta5 theta6
quietly replace `lnf'=ln(binormal(-`theta1',-`theta2',`theta6')-(binormal(-`theta1',-`theta2',`theta6')-binormal(-`theta1'-`theta3',-`theta2',`theta6')-binormal(-`theta1',-`theta2'-`theta5',`theta6')+binormal(-`theta1'-`theta3',-`theta2'-`theta5',`theta6'))) if $ML_y1==0 & $ML_y2==0 & `theta5'>=0
quietly replace `lnf'=ln(binormal(-`theta1',-`theta2',`theta6'))if $ML_y1==0 & $ML_y2==0 & `theta5'<0
quietly replace `lnf'=ln(binormal(`theta1',-`theta2'-`theta5',-`theta6'))if $ML_y1==1 & $ML_y2==0 & `theta5'>=0
quietly replace `lnf'=ln(binormal(`theta1',-`theta2'-`theta5',-`theta6')+(binormal(-`theta1',-`theta2'-`theta5',`theta6')-binormal(-`theta1',-`theta2',`theta6')-binormal(-`theta1'+`theta4',-`theta2'-`theta5',`theta6')+binormal(-`theta1'+`theta4',-`theta2',`theta6')))if $ML_y1==1 & $ML_y2==0 & `theta5'<0
quietly replace `lnf'=ln(binormal(-`theta1'-`theta3'+`theta4',`theta2',-`theta6'))if $ML_y1==0 & $ML_y2==1 & `theta5'>=0
quietly replace `lnf'=ln(binormal(-`theta1'-`theta3'+`theta4',`theta2',-`theta6')+(binormal(-`theta1'+`theta4',-`theta2'-`theta5',`theta6')-binormal(-`theta1'+`theta4',-`theta2',`theta6')-binormal(-`theta1'-`theta3'+`theta4',-`theta2'-`theta5',`theta6')+binormal(-`theta1'-`theta3'+`theta4',-`theta2',`theta6')))if $ML_y1==0 & $ML_y2==1 & `theta5'<0
quietly replace `lnf'=ln(binormal(`theta1'+`theta3'-`theta4',`theta2'+`theta5',`theta6')-(binormal(-`theta1'-`theta3',-`theta2',`theta6')-binormal(-`theta1'-`theta3',-`theta2'-`theta5',`theta6')-binormal(-`theta1'-`theta3'+`theta4',-`theta2',`theta6')+binormal(-`theta1'-`theta3'+`theta4',-`theta2'-`theta5',`theta6')))if $ML_y1==1 & $ML_y2==1 & `theta5'>=0
quietly replace `lnf'=ln(binormal(`theta1'+`theta3'-`theta4',`theta2'+`theta5',`theta6'))if $ML_y1==1 & $ML_y2==1 & `theta5'<0
end
And the second part which should fit the model. d_pd and d_m0 are dummy variables which are the dependent variables. theta1 should be a function of unemployment and gdp_grwoth and theta2 should be a function of inflation. theta3, theta4, theta5 and theta6 should only be simple estimates, i.e. just explained by a constant.
ml model lf stackelberg_likelihood_theta (d_pd = unemployment gdp_growth) (d_m0 = inflation) () () () ()
ml check
Ouput:
. ml check
Test 1: Calling stackelberg_likelihood_theta to check if it computes log
likelihood and
does not alter coefficient vector...
FAILED; stackelberg_likelihood_theta returned error 133.
Here is a trace of its execution:
------------------------------------------------------------------------------
-> stackelberg_likelihood_theta __00000I __00000J __00000K __00000L __00000M __00000N __00000O
- `begin'
= capture noisily version 13: stackelberg_likelihood_theta __00000I __00000J __00000K __00000L __00000M __00000N __00000O
------------------------------------------------------------------------------------------------------------------ begin stackelberg_likelihood_theta ---
- version 13.0
- args lnf theta1 theta2 theta3 theta4 theta5 theta6
- quietly replace `lnf'=ln(binormal(-`theta1',-`theta2',`theta6')-(binormal(-`theta1',-`theta2',`theta6')-binormal(-`theta1'-`theta3',-`theta2',`theta6')
> -binormal(-`theta1',-`theta2'-`theta5',`theta6')+binormal(-`theta1'-`theta3',-`theta2'-`theta5',`theta6'))) if $ML_y1==0 & $ML_y2==0 & `theta5'>=0
= quietly replace __00000I=ln(binormal(-__00000J,-__00000K,__00000O)-(binormal(-__00000J,-__00000K,__00000O)-binormal(-__00000J-__00000L,-__00000K,__0000
> 0O)-binormal(-__00000J,-__00000K-__00000N,__00000O)+binormal(-__00000J-__00000L,-__00000K-__00000N,__00000O))) if d_pd==0 & d_m0==0 & __00000N>=0
- quietly replace `lnf'=ln(binormal(-`theta1',-`theta2',`theta6'))if $ML_y1==0 & $ML_y2==0 & `theta5'<0
= quietly replace __00000I=ln(binormal(-__00000J,-__00000K,__00000O))if d_pd==0 & d_m0==0 & __00000N<0
unknown function ()
-------------------------------------------------------------------------------------------------------------------- end stackelberg_likelihood_theta ---
- `end'
= set trace off
------------------------------------------------------------------------------
Fix stackelberg_likelihood_theta.
So the error that occurs is unknown function () but I have no idea why... It would be fantastic if anybody could help me out.
Best, Lorenz
Comment