[R] Time series plots- x axis frequency issues

Syd88 jhea2850 at uni.sydney.edu.au
Tue Dec 13 07:17:28 CET 2011

I am trying to create a TS residual plot for a weekly data set over several
years. However, the data set obtains alot of missing data which has been
omitted from the analysis. The only issue is when I make the plot for the TS
residual graph you have to state the frequency in the coding i.e. freq= 52.
This is a problem as some years only have 40 weeks of data etc. This means
instead of showing a x-axis of 2000-2005 it is showing 2000-2004.

Does anybody know how you can define different frequencies for the x axis
i.e. 37 weeks, 40 weeks, 52 weeks?

Please keep in mind that the code has to allow for a smooth line to be
presented over the top of the residual plot.

The code I am currently using is:

plot(ts(resid.log, start =c (2000,1), freq= 52), xaxt = 'n', yaxt = 'n',
xlab="",ylab="", main = "", mgp = c(1.5, 0.5, 0))
axis(1, at = c(2003:2010), cex.axis = 0.7, mgp = c(1.5, 0.6, 0)) 
axis(2, cex.axis = 0.7, mgp = c(1.5, 0.6, 0))
mtext("Residuals over time" , side=3, line=1, font= 2, cex= 0.81)
mtext("  Residuals" , side=2, line=2, cex= 0.65)
mtext("Time)" , side=1, line=2.5, cex= 0.65)

#fit smoothing line
lines(ts(lowess(resid.log)$y,start =c( 2000,1), freq = 52))


View this message in context: http://r.789695.n4.nabble.com/Time-series-plots-x-axis-frequency-issues-tp4188963p4188963.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list