Statalist


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

st: mata problem "too many string literals"


From   "Glenn Goldsmith" <[email protected]>
To   <[email protected]>
Subject   st: mata problem "too many string literals"
Date   Mon, 23 Feb 2009 14:01:56 -0000

Hi John,

It's a little difficult to tell what the problem is without knowing exactly
what's in your locals, so you may need to provide more information to get a
useful answer.

I would have assumed from your description that they're varlists, and that
the problem was therefore likely to be that -st_data()- requires them as
string vectors. If that were the case, then

M1 = st_data(.,tokens("`M1'"))
Etc.

should do the trick. 

However, when I throw a straight varlist at -st_data()- I get a different
error message to the one you're getting (either "invalid expression", or
"variable not found", depending on whether the varlist is enclosed in
quotes). So that may not be the issue after all.

It may also be worth mentioning that using local macros inside mata
functions can cause problems unless you're sure what you're doing. The
crucial thing to remember is that they're dereferenced at compile time, so
if you change their contents after you've compiled the -obj()- function, the
function won't know. It's not clear exactly how you're using them here, so
you may be safe; but if you need to pass arguments to your objective
function, use -optimize_init_argument()- instead.

HTH,

Glenn.



>Hi there,
>I am writing an optimization program using mata, in which the
>objective function is given by obj(). However, my program cannot run
>because of the following error:
>
>: void obj (todo, r, C, g, H)
>> {
>
>>         M1 = st_data(.,`M1')
>>         M2 = st_data(.,`M2')
>>         M3 = st_data(.,`M3')
>>         M4 = st_data(.,`M4')
>>         M5 = st_data(.,`M5')
>>         M6 = st_data(.,`M6')
>>         M7 = st_data(.,`M7')
>>         M8 = st_data(.,`M8')
>too many string literals
>(217 lines skipped)
>---------------------------------------------------------------------------
>---------------------------------------------------------------------------
>-------
>r(3000);
>
>end of do-file
>
>r(3000);
>
>
>Macros Mi has been defined at the beginning of the program. By
>defining these macros, I try to avoid writing a very long line of
>variables in the objective function.
>
>Any help and suggestion is highly appreciated!
>
>Sincerely,
>John

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index