residuals <- arimares(b,x,y,params), REAL vectors b, y, REAL vector or matrix x, params = structure(pdq:vector(p,d,q), PDQ:vector(P,D,Q),seasonal:n1,cast:n2,cycles:n3,fitmean:T or F [,sigmahat:s]) integers >= 0 p, d, q, P, D, Q, n1, n2, n3, integer seasonal > 0, REAL scalar sigmahat |

residuals <- arimares(b,x,y,params) returns a REAL vector of residual from a (p,d,q)x(P,D,Q) ARIMA model with specified coefficients. The model may optionally have one or more linear predictors. Depending on arguments it can do one or more forecast/backcast cycles to estimate past residuals. It is intended for use by other macros. b = vector(mu,beta,phi,theta,phiS,thetaS) is a REAL vector of coefficients. mu is the mean, beta is a vector of coefficients of linear predictors in the columns of x, phi, theta, phiS and thetaS are vectors of AR, MA, seasonal AR and seasonal MA coefficients, respectively. Any of mu, beta, ..., thetaS are NULL if they are not in the model. x is either 0 (no linear predictors) or a nrows(y) by k REAL matrix of linear predictors. REAL vector y contains the time series being analyzed. params = structure(pdq:vector(p,d,q),PDQ:vector(P,D,Q),seasonal:n1, cast:n2,cycles:m3,fitmean:T or F [,sigmahat:s]) defines the form of the model and details about the algorithm used. The value is as follows residual vector sigmahat is not provided vector(sigmahat*sqrt(log(det)),residuals) sigmahat > 0 sqrt(log(det)) sigmahat < 0 The ARIMA model is Phi(B)*PhiS(B)*((1 - B)^d*(1 - B)^D*Y[t] - mu) = mu + Theta(B)*ThetaS(B)*Z(t), where B is the backshift operator. Here Phi(z) = 1 - phi[1]*z - phi[2]*z^2 - ... - phi[p]*z^p. Theta(z) = 1 - theta[1]*z - theta[2]*z^2 - ... - theta[q]*z^q PhiS(z) = 1 - phiS[1]*z^n1 - phiS[2]*z^(2*n1) - ... - phi[P]*z^(P*n1) ThetaS(z) = 1 - thetaS[1]*z^n1 - thetaS[2]*z^(2*n1) - ... - theta[Q]*z^(Q*n1) When there are k linear predictors, there is also an term X %*% beta on the right, where X is an nrows(y) by k matrix matrix of linear predictors with coefficient vector beta When another convention on the signs of the MA and/or AR coefficients is wanted, the calling macro must make the adjustment. That is, in the notation used in describing arima, arimares() assumes Arsign = -1, Masign = -1. The components of params are as follows: p,d,q integers >= 0, AR order, difference, MA order P,D,Q integers >= 0, seasonal AR order, seasonal difference, seasonal MA order n1 integer > 1, length of seasonal n2 integer >= - specifies how far to backcast n3 integer >= 0 number of cycles of fore/backcasting fitmean:T => mean will be fit s REAL scalar, estimate of residual stddev. Its presence signals that log(det(covariance matrix)) is to be computed. If sigmahat < 0, this is all that arimares() does, returning the scalar sqrt(log(det)). length(b) should be p + q + (P + Q)*seasonal + 1*fitmean + ncols(x)*isscalar(x)

Gary Oehlert 2003-01-15