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 <[email protected]>
To   [email protected]
Subject   Re: st: Using ml with hard-coded variables.
Date   Fri, 18 May 2007 00:24:52 -0400

Oops, the curse of the too-quick response.

This should do it.

sysuse auto

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

ml model lf probit1 (foreign=) /beta1
ml max




Nick B. wrote:
Well, the suggested fix does produce an estimate, but 1) it only
estimates b0 (the constant) rather than both b0 and mpg's b1, and 2)
the b0 estimate doesn't match either beta from "probit foreign mpg".

So I'm still stuck on how to make the basic hard-coded ml probit work...

On 5/17/07, Partha Deb <[email protected]> wrote:
Nick,

At least for your simplified model, changing

ml model lf probit1 (foreign=) / beta1

to

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.

Partha


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')
> 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/

--
Partha Deb
Department of Economics
Hunter College
ph:  (212) 772-5435
fax: (212) 772-5398
http://urban.hunter.cuny.edu/~deb/

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

*
*   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/
--
Partha Deb
Department of Economics
Hunter College
ph:  (212) 772-5435
fax: (212) 772-5398
http://urban.hunter.cuny.edu/~deb/

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

*
*   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/



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