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: "First numlist in weights( ...) invalid" error when using tssmooth to calculate a simple moving average


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: "First numlist in weights( ...) invalid" error when using tssmooth to calculate a simple moving average
Date   Thu, 6 Sep 2012 18:59:58 +0100

Sorry; I evidently didn't make myself clear enough, or you've missed
some very minor ironies of style. Where the error arises is not in
doubt.

-set trace- is sufficient to tell exactly where the error occurs and
using it lies behind my previous post. Also, the error occurs when
int(N/2) exceeds 1600, which as you say is when N >= 3202.

I haven't copied my post to Stata tech support, so you may want to
press them gently on the point.

Nick

On Thu, Sep 6, 2012 at 6:42 PM, Aaron Kirkman <[email protected]> wrote:
> I don't know if this code is sufficient to figure out exactly where
> the error occurs, but errors occur when _N >= 3202 on my system (Stata
> MP 12.1, Unix).
>
> ##
> set more off
> forvalues i = 3100/3300 {
>         clear
>         capture set obs `i'
>         gen x = runiform()
>         gen t  = _n
>         capture tsset t
>         capture tssmooth ma wtma = x, weights(1 2 3 4 <5>)
>         if _rc == 198 {
>                 display as error `i'
>         }
> }
> ##
>
> Aaron
>
> On Thu, Sep 6, 2012 at 7:56 AM, Nick Cox <[email protected]> wrote:
>> Yes; I can reproduce this. My impressions are
>>
>> 1. Your syntax is legal so far as -tssmooth- documentation is concerned.
>>
>> 2. -tssmooth- is passing your numlist to -numlist- for checking, but
>> there is a conflict of views, which leads to an error message.
>>
>> -tssmooth- is saying that as far as it is concerned, the numlist can
>> be 2674 elements long (in essence, half the number of your
>> observations). However, -numlist- won't play with candidate numlists
>> longer than 1600 elements, so it bails out without trying to examine
>> the list.
>>
>> There is, I think, confusion between two distinct tests, which must be
>> both be passed. -tssmooth- should check before it passes your numlist
>> to -numlist- that the numlist is OK as far as the time series aspect
>> is concerned. Then the call to -numlist- should not specify a maximum.
>>
>> A wild guess is that -numlist- was developed on series less than about
>> 3200 values long, where this doesn't bite.
>>
>> My tentative three-letter summary is "bug". StataCorp will have a view.
>>
>> Nick
>>
>> On Thu, Sep 6, 2012 at 1:11 PM, Aaron Kirkman <[email protected]> wrote:
>>> I noticed an error in the code I copied to the mailing list, although
>>> it's merely a typo and fixing it doesn't correct the -numlist- error.
>>> The -copy- line should not have a semicolon, and instead should be
>>> this:
>>>
>>> copy "http://ichart.finance.yahoo.com/table.csv?s=PNRA&a=05&b=10&c=1991&d=07&e=24&f=2012&g=d&ignore=.csv";
>>> pnra.csv, replace
>>>
>>> I can reproduce this error on both Unix and Windows machines (which
>>> may not be relevant), but can anyone else reproduce this error with
>>> the code in the previous thread?
>>>
>>> Thank you,
>>> Aaron Kirkman
>>>
>>> On Wed, Sep 5, 2012 at 8:32 PM, Aaron Kirkman <[email protected]> wrote:
>>>> Dear Statalist,
>>>>
>>>> I'm using the -tssmooth- command to calculate a simple moving average
>>>> of stock prices, but I get a syntax error of "First numlist in
>>>> weights(1 2 3 4 <5>) invalid" when running these commands.
>>>>
>>>> ##
>>>>
>>>> copy "http://ichart.finance.yahoo.com/table.csv?s=PNRA&a=05&b=10&c=1991&d=07&e=24&f=2012&g=d&ignore=.csv";
>>>> pnra.csv, replace
>>>> insheet using pnra.csv, comma clear
>>>> gen dateInt = date(date, "YMD")
>>>> drop date
>>>> rename dateInt date
>>>> tsset date
>>>> tssmooth ma wtma1 = adjclose, weights(1 2 3 4 <5>)
>>>>
>>>> ##
>>>>
>>>> I also receive an error if I specify other variations of this numlist
>>>> or other weights entirely, e.g.
>>>>
>>>> tssmooth ma wtma2 = adjclose, weights(1/4 <5>)
>>>> tssmooth ma wtma3 = adjclose, weights(1(1)4 <5>)
>>>>
>>>>
>>>> Specifying a window does work, however.
>>>>
>>>> tssmooth ma wtma4 = adjclose, window(4 1)
>>>>
>>>> However, this syntax works for another data set, so I'm not quite sure
>>>> about the problem with this code. For example, this code works when
>>>> using a dataset from Baum's "Introduction to Modern Econometrics Using
>>>> Stata."
>>>>
>>>> ##
>>>>
>>>> use http://www.stata-press.com/data/imeus/grunfeld, clear
>>>> tsset
>>>> tssmooth ma wtma1 = invest, weights(1 2 3 4 <5>)
>>>> tssmooth ma wtma2 = invest, weights(1/4 <5>)
>>>> tssmooth ma wtma3 = invest, weights(1(1)4 <5>)
>>>>
>>>> ##
>>>>
>>>> Is there a nuance to the syntax that I'm missing?
>>>>
*
*   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