I am using the ts package to fit ARIMA models, and the tsdiag() function to plot diagnostics. In doing so I'm generating an awful lot of diagnostic plots of different models and different data sets all within the same R session. So my question is, is there an option in tsdiag() similar to <main="Title"> that I can use? This would be quite helpful when I print out the plots, so I can tell which plot goes with a particular data set and model. I can't seem to find any examples where this has been done, and no options (other than gof.lag) are listed in the R manual. library(ts) data(tbills) #Treasury Bills attach(tbills) ts.tbills<-ts(tbills) diff.tbills<-diff(ts.tbills) #Differenced Series arima.diff.tbills.100<-arima(ts.tbills, order=c(1,0,0)) win.metafile("HW_ARIMA/tbill1.wmf") tsdiag(arima.diff.tbills.100, main="Treasury Bills") #main= does not work, is there a way to name the plot? dev.off() ? Thanks for any help or ideas. ? Andrew Kniss Assistant Research Scientist University of Wyoming Dept. 3354? 1000 E. University Ave. Laramie, WY 82071 (307) 766-3949 akniss at uwyo.edu
You can use title, but the result is unsatisfying:> fit <- arima(lh, c(1,0,0)) > tsdiag(fit) > title("junk")Perhaps mtext with an appropriate par configuration? HTH, Andy> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Andrew Kniss > Sent: Monday, November 15, 2004 10:53 AM > To: r-help at stat.math.ethz.ch > Subject: [R] tsdiag() titles > > > I am using the ts package to fit ARIMA models, and the tsdiag() > function to > plot diagnostics. In doing so I'm generating an awful lot of diagnostic > plots of different models and different data sets all within the same R > session. So my question is, is there an option in tsdiag() similar to > <main="Title"> that I can use? This would be quite helpful when > I print out > the plots, so I can tell which plot goes with a particular data set and > model. I can't seem to find any examples where this has been done, and no > options (other than gof.lag) are listed in the R manual. > > library(ts) > data(tbills) #Treasury Bills > attach(tbills) > ts.tbills<-ts(tbills) > diff.tbills<-diff(ts.tbills) #Differenced Series > arima.diff.tbills.100<-arima(ts.tbills, order=c(1,0,0)) > win.metafile("HW_ARIMA/tbill1.wmf") > tsdiag(arima.diff.tbills.100, main="Treasury Bills") #main= does not > work, is there a way to name the plot? > dev.off() > > > Thanks for any help or ideas. > > Andrew Kniss > Assistant Research Scientist > University of Wyoming > Dept. 3354 > 1000 E. University Ave. > Laramie, WY 82071 > (307) 766-3949 > akniss at uwyo.edu > >
Did you notice that tsdiag() plots about three plots and gives each a title? You can add a title to the array of plots using title(outer=TRUE), surprisingly enough, but you will need to adjust the outer margins to make room for it. Something like par(oma=c(0,0,2,0)) fit <- arima(lh, c(1,0,0)) tsdiag(fit) title("Some title or another", outer = TRUE) On Mon, 15 Nov 2004, Andrew Kniss wrote:> I am using the ts package to fit ARIMA models, and the tsdiag() function to > plot diagnostics. In doing so I'm generating an awful lot of diagnostic > plots of different models and different data sets all within the same R > session. So my question is, is there an option in tsdiag() similar to > <main="Title"> that I can use? This would be quite helpful when I print out > the plots, so I can tell which plot goes with a particular data set and > model. I can't seem to find any examples where this has been done, and no > options (other than gof.lag) are listed in the R manual. > > library(ts) > data(tbills) #Treasury Bills > attach(tbills) > ts.tbills<-ts(tbills) > diff.tbills<-diff(ts.tbills) #Differenced Series > arima.diff.tbills.100<-arima(ts.tbills, order=c(1,0,0)) > win.metafile("HW_ARIMA/tbill1.wmf") > tsdiag(arima.diff.tbills.100, main="Treasury Bills") #main= does not > work, is there a way to name the plot? > dev.off() > > > Thanks for any help or ideas. > > Andrew Kniss > Assistant Research Scientist > University of Wyoming > Dept. 3354 > 1000 E. University Ave. > Laramie, WY 82071 > (307) 766-3949 > akniss at uwyo.edu > >-- 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