Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Rolling regression without "clear"


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Rolling regression without "clear"
Date   Thu, 13 Jun 2013 11:45:38 +0100

There is no difference in principle. Even if you have a stored scalar, say

scalar foo = 42

you can supply its value like this

...  , window(`=foo')

so that what happens is

1. Stata sees the expression to be evaluated `=foo'   -- goes then
into a corner -- and comes back with the result of that evaluation,
here 42

2. -rolling- itself sees -window(42)- and moves on.

If your name could be confused with a variable name, then

..., window(`=scalar(foo)')

disambiguates.  Documentation starts at -help macro-, but you have to
dig a bit deep to see it from documentation.

For a local macro,

..., window(`foo')

would work, but for a scalar, a beast of a different kind, syntax is
slightly different.


Nick
njcoxstata@gmail.com


On 13 June 2013 11:33, G. Anderson <ga274@cam.ac.uk> wrote:
> Great. Thanks Nick.
>
> Do you know whether it's possible to set the window size based on a stored
> scalar, rather than typing in the number?
>
> Thanks,
>
> Gareth
>
>
>
> On Jun 13 2013, G. Anderson wrote:
>
>> Hi,
>>
>> I am using the "rolling" command in Stata 12 to do rolling
>> regressions.However when I use
>>
>> rolling , window(150):regress depvar indvar
>>
>> I get the error message "no; data in memory would be lost"
>>
>> The only way I can get around this is by adding in the "clear" command,
>> but this deletes all of my dataset, which is not ideal. Is there a way
>> around this?
>>
>>
>> Thanks,
>>
>> Gareth
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
>>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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