[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: invalid name problem when coding my own ml problem

Subject   st: invalid name problem when coding my own ml problem
Date   Mon, 27 Jul 2009 11:30:01 -0300

Apologies to all if this is a question that did not warrant the use of
statalist, I've looked for a couple days for the answer to my problem and
haven't been able to find it. I'm writing my own maximum likelihood program to
run in stata 10 for windows and whenever I run ml check on the code it returns
" ' invalid name" after parsing the first line of the actual likelihood
function. It appears to me that it's having problems with the fact that I've
put my parameters in single quotes but all the material I've read has led me to
believe this is the correct syntax. In fact I have a copy of Maximum Likelihood
Estimation with Stata third edition by Gould, Pitblado and Sribney and aside
from my likelihood function itself being different my code seems to be
identical to the examples they use in this book. The output given when I run ml
check is shown below (code is included in the output). Is there some part of the
proper syntax I didn't understand correctly?

- version 1.0
- args lnf xb sd sigmau sigmav rho sigmaw1 sigmaw2
- tempvar det J u v w1 w2 uuplimit ulowlimit
- quietly {
- gen double 'det' = sqrt('sigmav'^2*'sigmau'*'sigmav'+'sigmau'^2+4*'rho'^2)
' invalid name
gen double 'J' = abs((-4*'rho'*'det')/((-'sigmav'^2+'sigmau'^2-
gen double 'v' = $ML_y3-'sd'
gen double 'w1' = (2*'rho'/('sigmav'^2-'sigmau'^2+'det'))*'u' +
gen double 'uuplimit' = $ML_y2-'xb'+'v'
gen double 'ulowlimit' = $ML_y1-'xb'+'v'
replace 'lnf' = ln('J') + ln(normalden('w1',0,'sigmaw1')) +
       ln(normalden(-'xb'+'v',0,'sigmaw2')) if$ML_y2 == 0
replace 'lnf' = ln('J') + ln(normalden('w1',0,'sigmaw1')) + ln(normal(($ML_y2-
       'xb'+'v')/'sigmaw2')-normal(($ML_y1-'xb'+'v')/'sigmaw2')) if $ML_y2 != 0
       & $ML_y2 != .
replace 'lnf' = ln('J') + ln(normalden('w1',0,'sigmaw1')) + ln(1-normal(($ML_y1-
       'xb'+'v')/'sigmaw2')) if $ML_y2 == .

Thank you all very much for your time and input,
Ryan MacLeod
Mount Allison University
*   For searches and help try:

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