[Rd] Inconsistent behaviour when manipulating a ts object with frequency = 12 or 4

Simone Giannerini sgiannerini at gmail.com
Wed May 31 19:29:43 CEST 2006


many thanks for the reply,

On 5/31/06, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
> Attempting to change element 24 of a length 6 time series is inconsistent!

of course it is, my post was also motivated by the fact that you
obtain different answers also  within the same frequency, depending on
the index,  for instance:

> x <- ts(rnorm(6),frequency=12)
> x
         Jan        Feb        Mar        Apr        May        Jun
1  0.9255213  0.4829785 -0.5963106 -2.1852868 -0.6748659 -2.1190612
> x[7] <- NA
> x
         Jan        Feb        Mar        Apr        May        Jun        Jul
1  0.9255213  0.4829785 -0.5963106 -2.1852868 -0.6748659 -2.1190612         NA

so that I thought maybe it was worth pointing this out even if the
series are invalid.

> You end up with an invalid series, and the print methods are different for
> different frequencies, hence different error messages.
>
> Please do not send the same post repeatedly!

I apologize, I thought there was a problem with the first post.
Regards,

Simone


>
> On Wed, 31 May 2006, Simone Giannerini wrote:
>
> > Dear All,
> >
> > I found the following  under R 2.3.0 on WINXP (tested on 2 PCs, I do
> > not have access to Linux from this PC, sorry ... )
> >
> >> set.seed(10)
> >> x <- ts(rnorm(6),frequency=7)
> >> x
> > Time Series:
> > Start = c(1, 1)
> > End = c(1, 6)
> > Frequency = 7
> > [1]  0.01874617 -0.18425254 -1.37133055 -0.59916772  0.29454513  0.38979430
> >> x[24] <- NA
> >> x
> > Time Series:
> > Start = c(1, 1)
> > End = c(1, 6)
> > Frequency = 7
> > [1]  0.01874617 -0.18425254 -1.37133055 -0.59916772  0.29454513
> > 0.38979430          NA          NA          NA          NA          NA
> > [12]          NA          NA          NA          NA          NA
> >   NA          NA          NA          NA          NA          NA
> > [23]
> > ## OK ********************
> >
> >> x <- ts(rnorm(6),frequency=12) # THE SAME BUT WITH frequency = 12
> >> x
> >         Jan        Feb        Mar        Apr        May        Jun
> > 1 -1.2080762 -0.3636760 -1.6266727 -0.2564784  1.1017795  0.7557815
> >> x[24] <- NA
> >> x
> > Error in matrix(c(rep.int("", start.pad), format(x, ...), rep.int("",  :
> >        length of 'dimnames' [1] not equal to array extent
> > In addition: Warning message:
> > data length [30] is not a sub-multiple or multiple of the number of
> > columns [12] in matrix
> >
> >> x <- ts(rnorm(6),frequency=4) # THE SAME BUT WITH frequency = 4
> >> x
> >         Qtr1        Qtr2        Qtr3        Qtr4
> > 1 -0.23823356  0.98744470  0.74139013  0.08934727
> > 2 -0.95494386 -0.19515038
> >> x[24] <- NA
> >> x
> > Error in matrix(c(rep.int("", start.pad), format(x, ...), rep.int("",  :
> >        length of 'dimnames' [1] not equal to array extent
> > In addition: Warning message:
> > data length [26] is not a sub-multiple or multiple of the number of
> > rows [7] in matrix
> >
> >
> > Is this behaviour expected for frequencies 12 and 4?
> >
> > Thank you
> >
> > Simone
> >
> > ***************************************************
> > platform       i386-pc-mingw32
> > arch           i386
> > os             mingw32
> > system         i386, mingw32
> > status
> > major          2
> > minor          3.0
> > year           2006
> > month          04
> > day            24
> > svn rev        37909
> > language       R
> > version.string Version 2.3.0 (2006-04-24)
> >
> >> Sys.getlocale()
> > [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> > States.1252;LC_MONETARY=English_United
> > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
> >
> > ______________________________________________________
> >
> > Simone Giannerini
> > Dipartimento di Scienze Statistiche "Paolo Fortunati"
> > Universita' di Bologna
> > Via delle belle arti 41 - 40126  Bologna,  ITALY
> > Tel: +39 051 2098248  Fax: +39 051 232153
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >
>
> --
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>


-- 
______________________________________________________

Simone Giannerini
Dipartimento di Scienze Statistiche "Paolo Fortunati"
Universita' di Bologna
Via delle belle arti 41 - 40126  Bologna,  ITALY
Tel: +39 051 2098248  Fax: +39 051 232153



More information about the R-devel mailing list