I have been working on some examples of plotting time series for my new book
Modeling Financial Time Series with R and I noticed something funny with
plot.xts() from the R package xtsExtra when trying to plot quarterly time
series created from the xts function to.quarterly. Here is an example:

 

> sessionInfo()

R version 3.0.2 (2013-09-25)

Platform: x86_64-w64-mingw32/x64 (64-bit)

 

locale:

[1] LC_COLLATE=English_United States.1252 

[2] LC_CTYPE=English_United States.1252   

[3] LC_MONETARY=English_United States.1252

[4] LC_NUMERIC=C                          

[5] LC_TIME=English_United States.1252    

 

attached base packages:

[1] stats     graphics  grDevices utils     datasets  methods  

[7] base     

 

other attached packages:

[1] xtsExtra_0.0-1 quantmod_0.4-0 TTR_0.22-0     Defaults_1.1-1

[5] xts_0.9-7      zoo_1.7-10    

 

loaded via a namespace (and not attached):

[1] grid_3.0.2      lattice_0.20-23 tools_3.0.2   

 

> getSymbols("GS")

> GS.Ad.xts = Ad(GS)
> GS.Ad.quarterly.xts = to.quarterly(GS.Ad.xts, OHLC=FALSE)
> periodicity(GS.Ad.quarterly.xts)
Quarterly periodicity from 2007 Q1 to 2014 Q1 
> GS.Ad.quarterly.xts = to.quarterly(GS.Ad.xts, OHLC=FALSE)
> periodicity(GS.Ad.quarterly.xts)
Quarterly periodicity from 2007 Q1 to 2014 Q1 
> head(GS.Ad.quarterly.xts)
        GS.Adjusted
2007 Q1       191.4
2007 Q2       201.1
2007 Q3       201.5
2007 Q4       200.2
2008 Q1       154.3
2008 Q2       163.4
Warning message:
timezone of object (UTC) is different than current timezone (). 
> class(index(GS.Ad.quarterly.xts))
[1] "yearqtr"
> # Error in axis format for time plot
> plot(GS.Ad.quarterly.xts, lwd=2, col="blue")

 

In the resulting plot, the format for the axis is not correct. Instead of
showing the date as "Q1 2007", I see "%b 2007".

Also, I notice a strange error related to timezones. 

 

> Sys.timezone()
[1] "PST"

 

Do I have to change my system timezone to UTC prior to downloading the data
to get rid of this error?

Thanks for any help.

 

Eric Zivot                                               

Robert Richards Chaired Professor of Economics

Adjunct Professor of Finance                            

Adjunct Professor of Statistics

Adjunct Professor of Applied Mathematics 

Department of Economics

Box 353330                  email:  ezivot@u.washington.edu 

University of Washington    phone:  206-543-6715            

Seattle, WA 98195-3330
www:  http://faculty.washington.edu/ezivot                  

 


	[[alternative HTML version deleted]]

