RNARM
Generates a time series from a specified ARMA model.
Required Arguments
CNST — Overall constant. (Input)
See Comments.
PAR — Vector of length NPAR containing the autoregressive parameters. (Input)
LAGAR — Vector of length NPAR containing the order of the autoregressive parameters. (Input)
The elements of LAGAR must be greater than or equal to one.
PMA — Vector of length NPMA containing the moving average parameters. (Input)
LAGMA — Vector of length NPMA containing the order of the moving average parameters. (Input)
The elements of LAGMA must be greater than or equal to one.
IADIST — Option for normally distributed innovations. (Input)
IADIST
Action
0
Innovations are generated from a normal distribution (white noise) with mean 0 and variance AVAR.
1
Innovations are specifed by the user.
AVAR — Variance of the normal distribution, if used. (Input)
For IADIST = 0, AVAR is input; and for IADIST = 1, AVAR is unused.
A — Vector of length NW + max(LAGMA(j)) containing the innovations. (Input or output)
For IADIST = 1, A is input; and for IADIST = 0, A is output.
WI — Vector of length max(LAGAR(i)) containing the initial values of the time series. (Input)
W — Vector of length NW containing the generated time series. (Output)
Optional Arguments
NW — Number of observations of the time series to generate. (Input)
NW must be greater than or equal to one.
Default: NW = size (W,1).
NPAR — Number of autoregressive parameters. (Input)
NPAR must be greater than or equal to zero.
Default: NPAR = size (PAR,1).
NPMA — Number of moving average parameters. (Input)
NPMA must be greater than or equal to zero.
Default: NPMA = size (PMA,1).
FORTRAN 90 Interface
Generic: CALL RNARM (CNST, PAR, LAGAR, PMA, LAGMA, IADIST, AVAR, A, WI,
W [])
Specific: The specific interface names are S_RNARM and D_RNARM.
FORTRAN 77 Interface
Single: CALL RNARM (NW, CNST, NPAR, PAR, LAGAR, NPMA, PMA, LAGMA, IADIST, AVAR, A, WI, W)
Double: The double precision name is DRNARM.
Description
Routine RNARM simulates an ARMA(p, q) process, {Wt} for t = 1, 2, n (with n = NW, p = NPAR, and q = NPMA). The model is
ɸ(B)Wt = θ0 + θ(B)At      t  ZZ
where B is the backward shift operator,
ɸ(B) = 1  ɸ1B  ɸ2B2    ɸpBp
θ(B) = 1  θ1B  θ2B2    θqBq
Let μ be the mean of the time series {Wt}. The overall constant θ0 (CNST) is
Comments
1. The time series is generated according to the following model:
X(i) = CNST + PAR(1) * X(i  LAGAR(1)) +  + PAR(NPAR* X(i  LAGAR(NPAR)) + A(i PMA(1) * A(i  LAGMA(1))    PMA(NPMA* A(i  LAGAR(NPMA))
where
X(t) = W(t),t = 1, 2, NW
and
W(t) = WI(t + p),t = 1  p, 2  p, ,  1, 0
with p = max(LAGAR(k)).
The constant is related to the mean of the series, WMEAN, as follows:
CNST = WMEAN * (1  PAR(1   PAR(NPAR))
2. Time series whose innovations have a nonnormal distribution may be simulated by setting IADIST = 1 and by providing the appropriate innovations in A and start values in WI.
3. The routine RNSET can be used to initialize the seed of the random number generator. The routine RNOPT can be used to select the form of the generator.
Examples
Example 1
In this example, RNARM is used to generate a time series of length five, using an ARMA model with three autoregressive parameters and two moving average parameters. The start values are 0.1000, 0.0500, and 0.0375.
 
USE RNARM_INT
USE UMACH_INT
USE RNSET_INT
 
IMPLICIT NONE
INTEGER NPAR, NPMA, NW
PARAMETER (NPAR=3, NPMA=2, NW=5)
!
INTEGER I, IADIST, ISEED, LAGAR(NPAR), LAGMA(NPMA), NOUT
REAL A(NW+2), AVAR, CNST, PAR(NPAR), PMA(NPMA), W(NW), &
WI(3)
!
CALL UMACH (2, NOUT)
LAGAR(1) = 1
LAGAR(2) = 2
LAGAR(3) = 3
PAR(1) = 0.500
PAR(2) = 0.250
PAR(3) = 0.125
LAGMA(1) = 1
LAGMA(2) = 2
PMA(1) = -0.500
PMA(2) = -0.250
IADIST = 0
CNST = 1.0
AVAR = 0.1
WI(1) = 0.1
WI(2) = 0.05
WI(3) = 0.0375
ISEED = 123457
CALL RNSET (ISEED)
CALL RNARM (CNST, PAR, LAGAR, PMA, LAGMA, &
IADIST, AVAR, A, WI, W)
WRITE (NOUT,99999) (W(I),I=1,NW)
99999 FORMAT (' Simulated ARMA(3,2) series ', 5F7.4)
END
Output
 
Simulated ARMA(3,2) series 1.4033 2.2200 2.2864 2.8878 2.8322
Example 2
In this example, 500 observations from an ARMA(2, 2) process are simulated using RNARM; and then routine NSPE is used to estimate the parameters of the model. The model is used as an example by Priestley (1981), page 139.
 
USE RNARM_INT
USE RNSET_INT
USE NSPE_INT
 
IMPLICIT NONE
INTEGER NPAR, NPMA, NW
PARAMETER (NPAR=2, NPMA=2, NW=500)
!
INTEGER IADIST, ISEED, LAGAR(NPAR), LAGMA(NPMA)
REAL A(NW+2), AVAR, AVAR1, CNST, CNST1, PAR(NPAR), &
PAR1(NPAR), PMA(NPMA), PMA1(NPMA), W(NW), WI(2), WMEAN
!
LAGAR(1) = 1
LAGAR(2) = 2
PAR(1) = -1.4
PAR(2) = -0.5
LAGMA(1) = 1
LAGMA(2) = 2
PMA(1) = 0.2
PMA(2) = 0.1
IADIST = 0
CNST = 0.0
AVAR = 1.0
WI(1) = 0.0
WI(2) = 0.0
ISEED = 123457
CALL RNSET (ISEED)
CALL RNARM (CNST, PAR, LAGAR, PMA, LAGMA, &
IADIST, AVAR, A, WI, W)
CALL NSPE (W, CNST1, PAR1, PMA1, AVAR1, IPRINT=1)
END
Output
 
Results from NSPE/N2PE
WMEAN = .02192622
CONST = .0695866
AVAR = 1.0936457
PAR
1 2
-1.533 -0.641
PMA
1 2
0.0560 0.1294
Published date: 03/19/2020
Last modified date: 03/19/2020