SPECIFIC SPLUS COMMANDS FOR TIME SERIES ANALYSIS postscript(file="plot.ps",horizontal=F) ## Plots directed to file "plot.ps" par(mfrow=c(3,1)) ## Basic Time Series Plot, Sample ACF and PACF yt <- scan("/u/r/e/reinsel/stat349/grind.dat") ## Read in time series data ny <- length(yt) ts.plot(yt, type="b", pch="*", main="Grinding Wheel Profile Data") yt.acr <- acf(yt, lag.max=25, plot = F) ## Create ACF for series yt acf.plot(yt.acr, main="ACF of Original Series yt") cat("\n ACF for original series yt",fill=T) print(yt.acr) yt.pacf <- acf(yt, lag.max=25, type="partial", plot = F) ## Create PACF for yt acf.plot(yt.pacf, main="PACF of Original Series yt") cat("\n PACF for original series yt",fill=T) print(yt.pacf) wt <- diff(yt) ## Create 1st differences of yt ## Specifying ARIMA Models, Fitting, Model Checking, and Forecasting # General form of multiplicative seasonal ARIMA model statement # model <- list(list(order=c(p,d,q)), list(order=c(P,D,Q), period=S)) par(mfrow=c(1,1)) model1 <- list(order=c(3,0,0)) ## Define ARIMA model to be fitted yfit1 <- arima.mle(yt, model=model1, xreg=rep(1,ny)) ## Estimate ARIMA model cat("\n ARIMA(3,0,0) model for original series yt",fill=T) print(yfit1) diag1 <- arima.diag(yfit1) ## Create Diagnostics for fitted model cat("\n ACF for residuals from ARIMA(3,0,0) model",fill=T) print(diag1$acf.list) cat("\n Box-Pierce statistics of residuals from ARIMA(3,0,0) model",fill=T) print(diag1$gof) forecast1 <- arima.forecast(yt,model=yfit1$model,n=10, xreg=rep(1,(ny+10)),reg.coef=yfit1$reg.coef) ## Obtain forecasts for model cat("\n Forecasts of yt for 10 time periods ahead based on ARIMA(3,0,0) model",fill=T) print(forecast1) q() ## Ends Splus session