I believe -norm()- functions as -normal()- (CDF), which I think is
what I want (the non-hard-coded version described below, which also
uses -norm()-, matches the "probit foreign mpg" result).
By the way, I've been looking at Nick Cox's example at
http://www.stata.com/statalist/archive/2006-03/msg01102.html as a
basis for ml estimation with only hard-coded variables, but although
that works fine, I can't figure out what I'm doing differently...
On 5/17/07, Nick Cox <n.j.cox@durham.ac.uk> wrote:
-norm()- is not a synonym for -normalden()-.
The difference is between the cumulative distribution
function and the density function.
This may have some bearing on your problem.
Nick
n.j.cox@durham.ac.uk
P.S. Good name, but you may have to change it.
Nick B.
> 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')
> end
>
> 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
> `p'=norm(((`theta1'*mpg)^`theta3'+(`theta2'*length)^`theta3')^
> `theta4')
> quietly replace `lnf' = $ML_y1*ln(`p')+(1-$ML_y1)*ln(1-`p')
> end
>
> 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:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/