S-Plus commands used in time series analysis ============================================== ** "%" denotes explanation I used monthly U.S. unemployment rate series as an illustration. x=read.table(file="m-unrate.txt") % Load data into S-Plus workspace rate=x[,4] % get the unemployment rate series plot(rate,type='l') % Plot the time series. zt = diff(rate) % Take the first difference t.test(zt) % Perform t-test to test E(zt) = 0. acf(zt,lag.max=15) % Obtain the first 15 lages of ACF acf(zt,type="partial",lag.max=15) % Obtain the first 15 lags of PACF. m1=arima.mel(zt, model=list(order=c(2,0,1))) % fit an ARIMA(2,0,1) model summary(m1) % Obtain the fitted results m1chk = arima.diag(m1) % Perform model checking and obtain std. residuals plot(m1) % obtain plots of model checking (similar to arima.diag) names(m1chk) % Produce what are contained in the object "m1chk". predict.arima(m1,n.predict=5) % produce 1- to 5-step ahead forecasts. Remarks: ======== (1) If you load the module "finmetrics", then you can use the command "autocorTest" to perform Q-test of ACF. (2) In S-Plus, arima.mle assumes zero mean of the time series. If the mean is not zero, you can do two things: (a) Create a regressor of "1" to add to the model. For example, the differenced unempolyment rate series has 691 observations. z1=rep(1,691) m1=arima.mle(zt,model=list(order=c(2,0,1)),xreg=z1) (b) Remove the sample mean before fitting the model. ztm = zt-mean(zt). END of Remarks ==============