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, is already up and running.

[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 <>
Subject   Re: st: "First numlist in weights( ...) invalid" error when using tssmooth to calculate a simple moving average
Date   Thu, 6 Sep 2012 13:56:27 +0100

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.


On Thu, Sep 6, 2012 at 1:11 PM, Aaron Kirkman <> 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 "";
> 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 <> 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 "";
>> 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, 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:

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