g05pj Method
関数リスト一覧   NagLibrary Namespaceへ  ライブラリイントロダクション  本ヘルプドキュメントのchm形式版

g05pj generates a realization of a multivariate time series from a vector autoregressive moving average (VARMA) model. The realization may be continued or a new realization generated at subsequent calls to g05pj.

Syntax

C#
public static void g05pj(
	int mode,
	int n,
	int k,
	double[] xmean,
	int ip,
	double[] phi,
	int iq,
	double[] theta,
	double[,] var,
	double[] r,
	G05..::.G05State g05state,
	double[,] x,
	out int ifail
)
Visual Basic (Declaration)
Public Shared Sub g05pj ( _
	mode As Integer, _
	n As Integer, _
	k As Integer, _
	xmean As Double(), _
	ip As Integer, _
	phi As Double(), _
	iq As Integer, _
	theta As Double(), _
	var As Double(,), _
	r As Double(), _
	g05state As G05..::.G05State, _
	x As Double(,), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g05pj(
	int mode, 
	int n, 
	int k, 
	array<double>^ xmean, 
	int ip, 
	array<double>^ phi, 
	int iq, 
	array<double>^ theta, 
	array<double,2>^ var, 
	array<double>^ r, 
	G05..::.G05State^ g05state, 
	array<double,2>^ x, 
	[OutAttribute] int% ifail
)
F#
static member g05pj : 
        mode:int * 
        n:int * 
        k:int * 
        xmean:float[] * 
        ip:int * 
        phi:float[] * 
        iq:int * 
        theta:float[] * 
        var:float[,] * 
        r:float[] * 
        g05state:G05..::.G05State * 
        x:float[,] * 
        ifail:int byref -> unit 

Parameters

mode
Type: System..::.Int32
On entry: a code for selecting the operation to be performed by the method.
mode=0
Set up reference vector and compute a realization of the recent history.
mode=1
Generate terms in the time series using reference vector set up in a prior call to g05pj.
mode=2
Combine the operations of mode=0 and 1.
mode=3
A new realization of the recent history is computed using information stored in the reference vector, and the following sequence of time series values are generated.
If mode=1 or 3, then you must ensure that the reference vector r and the values of k, ip, iq, xmean, phi, theta, var and ldvar have not been changed between calls to g05pj.
Constraint: mode=0, 1, 2 or 3.
n
Type: System..::.Int32
On entry: n, the number of observations to be generated.
Constraint: n0.
k
Type: System..::.Int32
On entry: k, the dimension of the multivariate time series.
Constraint: k1.
xmean
Type: array< System..::.Double >[]()[]
An array of size [k]
On entry: μ, the vector of means of the multivariate time series.
ip
Type: System..::.Int32
On entry: p, the number of autoregressive parameter matrices.
Constraint: ip0.
phi
Type: array< System..::.Double >[]()[]
An array of size [k×k×ip]
On entry: must contain the elements of the ip×k×k autoregressive parameter matrices of the model, ϕ1,ϕ2,,ϕp. If phi is considered as a three-dimensional array, dimensioned as phik,k,ip, then the i,jth element of ϕl would be stored in phii,j,l; that is, phi[l-1×k×k+j-1×k+i-1] must be set equal to the i,jth element of ϕl, for l=1,2,,p and i,j=1,2,,k.
Constraint: the elements of phi must satisfy the stationarity condition.
iq
Type: System..::.Int32
On entry: q, the number of moving average parameter matrices.
Constraint: iq0.
theta
Type: array< System..::.Double >[]()[]
An array of size [k×k×iq]
On entry: must contain the elements of the iq×k×k moving average parameter matrices of the model, θ1,θ2,,θq. If theta is considered as a three-dimensional array, dimensioned as theta(k,k,iq), then the i,jth element of θl would be stored in thetai,j,l; that is, theta[l-1×k×k+j-1×k+i-1] must be set equal to the i,jth element of θl, for l=1,2,,q and i,j=1,2,,k.
Constraint: the elements of theta must be within the invertibility region.
var
Type: array< System..::.Double ,2>[,](,)[,]
An array of size [ldvar, k]
Note: ldvar must satisfy the constraint: ldvark
On entry: var[i-1,j-1] must contain the (i,j)th element of Σ, for i,j=1,2,,k. Only the lower triangle is required.
Constraint: the elements of var must be such that Σ is positive semi-definite.
r
Type: array< System..::.Double >[]()[]
An array of size [lr]
Note: lr must satisfy the constraint:
  • if k6, lr5r2+1×k2+4r+3×k+4;
  • if k<6, lr ip+iq 2+1×k2+ 4×ip+iq+3×k+maxkrkr+2,k2 ip+iq 2+ll+3+k2iq+1+4.
Where r=maxip,iq and if ip=0, l=kk+1/2, or if ip1, l=kk+1/2+ip-1k2.
See [Further Comments] for some examples of the required size of the array r.
On entry: if mode=1 or 3, the array r as output from the previous call to g05pj must be input without any change.
If mode=0 or 2, the contents of r need not be set.
On exit: information required for any subsequent calls to the method with mode=1 or 3. See [Further Comments].
g05state
Type: NagLibrary..::.G05..::.G05State
An object of type G05.G05State.
x
Type: array< System..::.Double ,2>[,](,)[,]
An array of size [ldx, n]
Note: ldx must satisfy the constraint: ldxk
On exit: x[i-1,t-1] will contain a realization of the ith component of Xt, for i=1,2,,k and t=1,2,,n.
ifail
Type: System..::.Int32 %
On exit: ifail=0 unless the method detects an error (see [Error Indicators and Warnings]).

Description

At your request a new realization of the time series may be generated more efficiently using the information in a reference vector created during a previous call to g05pj. See the description of the parameter mode in [Parameters] for details.
The method returns a realization of X1,X2,,Xn. On a successful exit, the recent history is updated and saved in the array r so that g05pj may be called again to generate a realization of Xn+1,Xn+2,,etc. See the description of the parameter mode in [Parameters] for details.
Further computational details are given in Shea (1988). Note, however, that g05pj uses a spectral decomposition rather than a Cholesky factorization to generate the multivariate Normals. Although this method involves more multiplications than the Cholesky factorization method and is thus slightly slower it is more stable when faced with ill-conditioned covariance matrices. A method of assigning the AR and MA coefficient matrices so that the stationarity and invertibility conditions are satisfied is described in Barone (1987).

References

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (ldvar, lr, ldx, lstate) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry, mode0, 1, 2 or 3.
ifail=2
On entry, n<0.
ifail=3
On entry, k<1.
ifail=5
On entry, ip<0.
ifail=6
The autoregressive parameter matrices, stored in phi, are such that the model is non-stationary.
ifail=7
On entry, iq<0.
ifail=8
On entry, the moving average parameter matrices, stored in theta, are such that the model is non-invertible.
ifail=9
The covariance matrix Σ, stored in var, is not positive-definite.
ifail=10
On entry, ldvar<k.
ifail=11
Either r has been corrupted or the value of k is not the same as when r was set up in a previous call to g05pj with mode=0 or 2.
ifail=12
On entry, lr is too small.
ifail=13
On entry, g05state vector was not initialized or has been corrupted.
ifail=15
On entry, ldx<k.
ifail=20
This is an unlikely exit brought about by an excessive number of iterations being needed by the NAG Library method used to evaluate the eigenvalues of Aϕ or Bθ.
ifail=21
g05pj has not been able to calculate all the required elements of the array r. This is likely to be because the AR parameters are very close to the boundary of the stationarity region.
ifail=22
This is an unlikely exit brought about by an excessive number of iterations being needed by the NAG Library method used to evaluate the eigenvalues of the covariance matrix.
ifail=23
g05pj has not been able to calculate all the required elements of the array r. This is an unlikely exit brought about by an excessive number of iterations being needed by the NAG Library method used to evaluate eigenvalues to be stored in the array r. If this error occurs please contact NAG.
ifail=26
The AR parameters are outside the stationarity region.
ifail=29
An excessive number of iterations were required by the NAG method used to evaluate the eigenvalues of the covariance matrix.
ifail=36
The reference vector cannot be computed because the AR parameters are too close to the boundary of the stationarity region.
ifail=211
An excessive number of iterations were required by the NAG method used to evaluate the eigenvalues stored in the reference vector.
ifail=-4000
ifail=-8000
ifail=-6000

Accuracy

Further Comments

Note that, in reference to ifail=8, g05pj will permit moving average parameters on the boundary of the invertibility region.
The elements of r contain amongst other information details of the spectral decompositions which are used to generate future multivariate Normals. Note that these eigenvectors may not be unique on different machines. For example the eigenvectors corresponding to multiple eigenvalues may be permuted. Although an effort is made to ensure that the eigenvectors have the same sign on all machines, differences in the signs may theoretically still occur.
The following table gives some examples of the required size of the array r, specified by the parameter lr, for k=1,2 or 3, and for various values of p and q.
        q
 
    0 1 2 3
 
    13 20 31 46
  0 36 56 92 144
    85 124 199 310
 
    19 30 45 64
  1 52 88 140 208
    115 190 301 448
p
    35 50 69 92
  2 136 188 256 340
    397 508 655 838
 
    57 76 99 126
  3 268 336 420 520
    877 1024 1207 1426
Note that g13dx may be used to check whether a VARMA model is stationary and invertible.
The time taken depends on the values of p, q and especially n and k.

Example

See Also