Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Using ml with hard-coded variables.

From   Partha Deb <>
Subject   Re: st: Using ml with hard-coded variables.
Date   Thu, 17 May 2007 21:24:09 -0400


At least for your simplified model, changing

ml model lf probit1 (foreign=) / beta1


ml model lf probit1 (foreign=)

fixes the problem. There's only one parameter in your model, and it is implied by the constant specified in foreign= . You might have subtle singularities in your more "complicated" model.

Hope this helps.


Nick B. wrote:

I'm a beginner here, trying to use Stata's ml to estimate a
probit-like equation with non-linear terms.  However, whenever I try
using hard-coded independent variables, I get the following error:

initial:       log likelihood = -51.292891
alternative:   log likelihood =  -1877.398
rescale:       log likelihood = -48.015768
rescale eq:    log likelihood = -48.015768
could not calculate numerical derivatives
flat or discontinuous region encountered

Even when I simplify my system, I still get these errors, so I must be
doing something wrong.

For instance, using the built-in auto data, I try
sysuse auto
capture program drop probit1

program define probit1
    args lnf theta1
    tempvar p
    quietly gen double `p'=norm(`theta1'*mpg)
    quietly replace `lnf' = $ML_y1*ln(`p')+(1-$ML_y1)*ln(1-`p')

ml model lf probit1 (foreign=) /beta1
ml max
This produces the error, even though it is almost identical to the
textbook example for using ml for probit.  Specifically, replacing the
relevant lines with the non-hard-coded version

quietly gen double `p'=norm(`theta1')
ml model lf probit1 (foreign=mpg)

works fine.  So I assume I am doing something basic wrong in switching
to hard-coded variables.

The reason I need the hard-coded variables is that what I'm really
trying to estimate is closer to
capture program drop probit2

program define probit2
    args lnf theta1 theta2 theta3 theta4
    tempvar p
    quietly gen double
    quietly replace `lnf' = $ML_y1*ln(`p')+(1-$ML_y1)*ln(1-`p')

ml model lf probit2 (foreign=) /beta1 /beta2 /gamma1 /gamma2

ml max
Which of course produces the same error.

Any help would be greatly appreciated.
*   For searches and help try:
Partha Deb
Department of Economics
Hunter College
ph:  (212) 772-5435
fax: (212) 772-5398

Emancipate yourselves from mental slavery
None but ourselves can free our minds.
	- Bob Marley

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index