Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_tsa_uni_arima_update (g13ag)

## Purpose

nag_tsa_uni_arima_update (g13ag) accepts a series of new observations of a time series, the model of which is already fully specified, and updates the ‘state set’ information for use in constructing further forecasts. The previous specifications of the time series model should have been obtained by using nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af) to estimate the relevant parameters. The supplied state set will originally have been produced by nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af), but may since have been updated by earlier calls to nag_tsa_uni_arima_update (g13ag).
A set of residuals corresponding to the new observations is returned. These may be of use in checking that the new observations conform to the previously fitted model.

## Syntax

[st, anexr, ifail] = g13ag(st, mr, par, c, anx, 'nst', nst, 'npar', npar, 'nuv', nuv)
[st, anexr, ifail] = nag_tsa_uni_arima_update(st, mr, par, c, anx, 'nst', nst, 'npar', npar, 'nuv', nuv)

## Description

The time series model is specified as outlined in Section [Description] in (g13ae) or (g13af). This also describes how the state set, which contains the minimum amount of time series information needed to construct forecasts, is made up of
 (i) the differenced series wt${w}_{t}$ (uncorrected for the constant c$c$), for (N − P × s) < t ≤ N$\left(N-P×s\right), (ii) the d′${d}^{\prime }$ values required to reconstitute the original series xt${x}_{t}$ from the differenced series wt${w}_{t}$, (iii) the intermediate series et${e}_{t}$, for (N − max (p, Q × s )) < t ≤ N $\left(N-\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,Q×s\right)\right), and (iv) the residual series at${a}_{t}$, for (N − q) < t ≤ N$\left(N-q\right).
If the number of original undifferenced observations was n$n$, then d = d + (D × s)${d}^{\prime }=d+\left(D×s\right)$ and N = nd$N=n-{d}^{\prime }$.
To update the state set, given a number of new undifferenced observations xt${x}_{t}$, t = n + 1,n + 2,,n + k$t=n+1,n+2,\dots ,n+k$, the four series above are first reconstituted.
Differencing and residual calculation operations are then applied to the new observations and k$k$ new values of wt,et${w}_{t},{e}_{t}$ and at${a}_{t}$ are derived.
The first k$k$ values in these three series are then discarded and a new state set is obtained.
The residuals in the at${a}_{t}$ series corresponding to the k$k$ new observations are preserved in an output array. The parameters of the time series model are not changed in this function.

None.

## Parameters

### Compulsory Input Parameters

1:     st(nst) – double array
nst, the dimension of the array, must satisfy the constraint nst = P × s + D × s + d + q + max (p,Q × s)${\mathbf{nst}}=P×s+D×s+d+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,Q×s\right)$. (As returned by nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af)).
The state set derived from nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af), or as modified using earlier calls of nag_tsa_uni_arima_update (g13ag).
2:     mr(7$7$) – int64int32nag_int array
The orders vector (p,d,q,P,D,Q,s)$\left(p,d,q,P,D,Q,s\right)$ of the ARIMA model, in the usual notation.
Constraints:
• p,d,q,P,D,Q,s0$p,d,q,P,D,Q,s\ge 0$;
• p + q + P + Q > 0$p+q+P+Q>0$;
• s1$s\ne 1$;
• if s = 0$s=0$, P + D + Q = 0$P+D+Q=0$;
• if s > 1$s>1$, P + D + Q > 0$P+D+Q>0$.
3:     par(npar) – double array
npar, the dimension of the array, must satisfy the constraint npar = p + q + P + Q${\mathbf{npar}}=p+q+P+Q$.
The estimates of the p$p$ values of the φ$\varphi$ parameters, the q$q$ values of the θ$\theta$ parameters, the P$P$ values of the Φ$\Phi$ parameters and the Q$Q$ values of the Θ$\Theta$ parameters in the model – in that order, using the usual notation.
4:     c – double scalar
The constant to be subtracted from the differenced data.
5:     anx(nuv) – double array
The new undifferenced observations which are to be used to update st.

### Optional Input Parameters

1:     nst – int64int32nag_int scalar
Default: The dimension of the array st.
The number of values in the state set array st.
Constraint: nst = P × s + D × s + d + q + max (p,Q × s)${\mathbf{nst}}=P×s+D×s+d+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(p,Q×s\right)$. (As returned by nag_tsa_uni_arima_estim (g13ae) or nag_tsa_uni_arima_estim_easy (g13af)).
2:     npar – int64int32nag_int scalar
Default: The dimension of the array par.
The number of φ$\varphi$, θ$\theta$, Φ$\Phi$ and Θ$\Theta$ parameters in the model.
Constraint: npar = p + q + P + Q${\mathbf{npar}}=p+q+P+Q$.
3:     nuv – int64int32nag_int scalar
Default: The dimension of the array anx.
k$k$, the number of new observations in anx.

wa nwa

### Output Parameters

1:     st(nst) – double array
The updated values of the state set.
2:     anexr(nuv) – double array
The residuals corresponding to the new observations in anx.
3:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, npar ≠ p + q + P + Q${\mathbf{npar}}\ne p+q+P+Q$, or the orders vector mr is invalid (check the constraints in Section [Parameters]).
ifail = 2${\mathbf{ifail}}=2$
 On entry, nst ≠ P × s + D × s + d + q + max (Q × s,p)${\mathbf{nst}}\ne P×s+D×s+d+q+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(Q×s,p\right)$.
ifail = 3${\mathbf{ifail}}=3$
 On entry, nuv ≤ 0${\mathbf{nuv}}\le 0$.
ifail = 4${\mathbf{ifail}}=4$
 On entry, nwa < 4 × npar + 3 × nst$\mathit{nwa}<4×{\mathbf{npar}}+3×{\mathbf{nst}}$.

## Accuracy

The computations are believed to be stable.

The time taken by nag_tsa_uni_arima_update (g13ag) is approximately proportional to ${\mathbf{nuv}}×{\mathbf{npar}}$.

## Example

```function nag_tsa_uni_arima_update_example
st = [0.0118;
-0.0669;
0.1296;
-0.0394;
0.0422;
0.1809;
0.1211;
0.0281;
-0.2231;
-0.1181;
-0.1468;
0.0835;
5.8201;
-0.0157;
-0.0361;
-0.0266;
-0.0199;
0.0298;
0.029;
0.0147;
0.0373;
-0.0931;
0.0223;
-0.0172;
-0.0353;
-0.0413];
mr = [int64(0);1;1;0;1;1;12];
par = [0.327;
0.627];
c = 0;
anx = [5.8861;
5.8348;
6.0064;
5.9814;
6.0403;
6.157;
6.3063;
6.3261;
6.1377;
6.0088;
5.8916;
6.0039];
[stOut, anexr, ifail] = nag_tsa_uni_arima_update(st, mr, par, c, anx)
```
```

stOut =

0.0660
-0.0513
0.1716
-0.0250
0.0589
0.1167
0.1493
0.0198
-0.1884
-0.1289
-0.1172
0.1123
6.0039
0.0444
-0.0070
0.0253
0.0019
0.0354
-0.0460
0.0374
0.0151
-0.0237
0.0032
0.0188
0.0067
0.0126

anexr =

0.0309
0.0031
0.0263
0.0105
0.0388
-0.0333
0.0265
0.0238
-0.0159
-0.0020
0.0182
0.0126

ifail =

0

```
```function g13ag_example
st = [0.0118;
-0.0669;
0.1296;
-0.0394;
0.0422;
0.1809;
0.1211;
0.0281;
-0.2231;
-0.1181;
-0.1468;
0.0835;
5.8201;
-0.0157;
-0.0361;
-0.0266;
-0.0199;
0.0298;
0.029;
0.0147;
0.0373;
-0.0931;
0.0223;
-0.0172;
-0.0353;
-0.0413];
mr = [int64(0);1;1;0;1;1;12];
par = [0.327;
0.627];
c = 0;
anx = [5.8861;
5.8348;
6.0064;
5.9814;
6.0403;
6.157;
6.3063;
6.3261;
6.1377;
6.0088;
5.8916;
6.0039];
[stOut, anexr, ifail] = g13ag(st, mr, par, c, anx)
```
```

stOut =

0.0660
-0.0513
0.1716
-0.0250
0.0589
0.1167
0.1493
0.0198
-0.1884
-0.1289
-0.1172
0.1123
6.0039
0.0444
-0.0070
0.0253
0.0019
0.0354
-0.0460
0.0374
0.0151
-0.0237
0.0032
0.0188
0.0067
0.0126

anexr =

0.0309
0.0031
0.0263
0.0105
0.0388
-0.0333
0.0265
0.0238
-0.0159
-0.0020
0.0182
0.0126

ifail =

0

```