[R] How to setup the tsp attribute of a dataset

Gabor Grothendieck ggrothendieck at gmail.com
Sat Nov 21 00:51:36 CET 2009


tsp is supposed to be applied to a ts object. If you are not using ts
objects then that is your problem.

On Fri, Nov 20, 2009 at 6:43 PM, Samik Raychaudhuri <samikr at gmail.com> wrote:
> Looks like there is a difference between when I use frequency(x) vs. when I
> use frequency(x.ts). If I try to get the tsp attribute of x by using attr(x,
> "tsp"), it still shows up as NULL. When I looked at the code of frequency()
> function (in stats), it seems to be looking at attr(x, "tsp"), which is
> NULL, so the function returns 1.
> Let me relate the context a bit. I am trying to use the function
> forecast:nsdiffs to perform a Canova-Hansen test for a given dataset. Even
> though I specify the seasonality, in an internal function, frequency(x) is
> used to find seasonality, and since that value is 1 (as I explained above:
> it looks at attr(x, "tsp")), the calculations do not succeed.
>
> On 11/20/2009 4:25 PM, Gabor Grothendieck wrote:
>>
>> Not for me.
>>
>>
>>>
>>> x <- 1:100
>>> x.ts <- ts(x, start = 1, frequency = 4)
>>> frequency(x.ts)
>>>
>>
>> [1] 4
>>
>>
>>
>>
>




More information about the R-help mailing list