Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: ml - could not calculate numerical derivatives missing values encountered


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: ml - could not calculate numerical derivatives missing values encountered
Date   Thu, 15 Dec 2011 15:00:19 +0100

2011/12/15 Alan Marshall :
> I have worked out the log-likelihood function as below. <snip>
> *line 3
> Quietly replace `lnf'=2*`a'*${dx_Dis}1+`b'*${Yxl}1*${dx_Dis}1-(${Nx_Dis}1*ln(1+(exp(2*(`a'+`b'*${Yxl}1)))))

${dx_Dis}1, *${Yxl}1, and ${Nx_Dis}1 look very suspicious to me. If
you have a global called dx_Dis1 than calling it ${dx_Dis}1, will do
the following: Stata looks for a global macro called dx_Dis, can't
find it, so evaluates that to nothing, and than sees the 1. So in that
case ${dx_Dis}1 always evaluates to 1. If you want to refer to a
global macro called dx_Dis1 than you should call it $dx_Dis1 or
${dx_Dis1}.

It may make sense when you want to refer to a variable called for
example foo1 and the global macro dx_Dis contains the string foo. In
that case Stata will first evaluate the macro dx_Dis to foo and than
attach the 1 at the end. I would never do something like that though,
as it would make debugging such code a pain. It is much much much
better to let the macro dx_Dis contain the string foo1

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index