Pete Aling <[email protected]> has some follow-up questions about
using -ml- to fit his model:
> Thanks so much for the help with the question I posted last week. Your
> solutions helped a lot. There are two issues I'm still having though.
> 1. The likelihood function isn't the log of the Gaussian density function as
> you thought but rather minus twice the log of the Gaussian density. However,
> when I run the program I get an error message.
Unfortunately, one cannot perform "maximum" likelihood of
-2 * ln(likelihood function)
since the '-' in '-2' flips the log likelihood up-side-down, turning the
maximum into a minimum. If Pete wants 'optimized' arguments to
-2 * ln(likelihood function)
he should try using -ml- to get MLE's from
ln(likelihood function)
In short, remove '-2*' from the formula for the log likelihood.
> 2. The model I'm estimating was the unrestricted version of a number of
> models. These models are created by imposing parameter restrictions on the
> alpha, beta, and gamma coefficients. My question is how do I impose and test
> these restrictions?
> They are 1. beta = 0, gamma = 0
> 2. gamma = 0
> 3. gamma = 1/2
> 4. alpha = 0, beta = 0, gamma = 1
> 5. alpha = 0, gamma = 1
> 6. gamma = 1
> 7. alpha = 0, beta = 0, gamma = 3/2
> 8. alpha = 0
Pete can impose these constraints by first defining them using the
-constraint- command, and specifying the -constraints()- option on the call to
-ml model-.
However, the constraint 'beta = 0' will cause divide-by-zero problems in the
current likelihood evaluator. Dividing by zero will result in missing values
in the log likelihood, causing -ml- to quit.
Pete can add some logic to his -myest- likelihood evaluator (after removing
the '-2*') to handle the case when beta is 0 (but only because l'Hospital's
rule indicates that the limit exists as beta goes to 0). For example, here is
how I would change Pete's -myest- likelihood evaluator:
program myest
version 9 // Pete metions he was using Stata 9
args lnf alpha beta sigma2 gamma
tempvar a b c d e m s
quietly gen double `a' = `sigma2'
quietly gen double `b' = cond(beta == 0, 1, ///
(exp(2*`beta') - 1)/(2*`beta') ///
)
quietly gen double `c' = 2*`gamma'
quietly gen double `d' = exp(`beta')
quietly gen double `e' = cond(beta == 0, 1, ///
(`d'-1)/`beta' ///
)
quietly gen double `m' = `d'*ltbrate+`alpha'*`e'
quietly gen double `s' = `a'*`b'*(ltbrate^`c')
quietly replace `lnf' = lnnormalden($ML_y1,`m',`s')
end
--Jeff
[email protected]
*
* 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/