NSLSE
Computes least‑squares estimates of parameters for a nonseasonal ARMA model.
Required Arguments
W — Vector of length NOBS containing the stationary time series. (Input)
PAR — Vector of length NPAR containing the autoregressive parameters.(Input/ Output)
On input, PAR contains the preliminary estimate. On output, PAR contains the final estimate.
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/Output)
On input, PMA contains the preliminary estimate. On output, PMA contains the final estimate.
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.
MAXBC — Maximum length of backcasting. (Input)
MAXBC must be greater than or equal to zero.
CNST — Estimate of the overall constant. (Output)
For IMEAN = 0, CNST is set to zero. For IMEAN = 1,
CNST = WMEAN * (1 ‑ PAR(1) ‑ PAR(2) ‑ … ‑ PAR(NPAR)).
COV — NP by NP variance‑covariance matrix of the estimates of the parameters where
NP = IMEAN + NPAR + NPMA. (Output)
The ordering of variables in COV is WMEAN (if defined), PAR, and PMA. NP must 1
or more.
AVAR — Estimate of the random shock variance. (Output)
AVAR = (A(1)2 + … + A(NA)2)/(NOBS ‑ IMEAN ‑ NPAR ‑ NPMA).
Optional Arguments
NOBS — Number of observations in the stationary time series W. (Input)
NOBS must be greater than IARDEG + IMADEG where IARDEG = max(LAGAR(i)) and IMADEG = max(LAGMA(j)).
Default: NOBS = size (W,1).
IPRINT — Printing option. (Input)
Default: IPRINT = 0.
IPRINT | Action |
---|
0 | No printing is performed. |
1 | Prints the least‑squares estimates of the parameters, their associated standard errors, and the residual sum of squares at the final iteration. |
2 | Prints the least‑squares estimates of the parameters and the residual sum of squares at each iteration and at the final iteration. Print the standard errors of the parameters at the final iteration. |
IMEAN — Option for centering the time series W. (Input)
Default: IMEAN = 0.
IMEAN | Action |
---|
0 | W is not centered. |
1 | W is centered about WMEAN. Centering the time series W about WMEAN is equivalent to inclusion of the overall constant in the model. |
WMEAN — Estimate of the mean of the time series W. (Input/Output, if IMEAN = 1; not used if IMEAN = 0)
For IMEAN = 1, on input, WMEAN contains the preliminary estimate, on output, WMEAN contains the final estimate.
Default: WMEAN = 0.0.
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).
TOLBC — Tolerance level used to determine convergence of the backcast algorithm. (Input)
Backcasting terminates when the absolute value of a backcast is less than TOLBC. Typically, TOLBC is set to a fraction of WSTDEV where WSTDEV is an estimate of the standard deviation of the time series. If TOLBC = 0.0, then TOLBC = 0.01 * WSTDEV is used.
Default: TOLBC = 0.0.
TOLSS — Tolerance level used to determine convergence of the nonlinear least‑squares algorithm. (Input)
Default: TOLSS = 0.0.
TOLSS represents the minimum relative decrease in sum of squares between two iterations required to determine convergence. Hence, TOLSS must be greater than or equal to zero and less than one where TOLSS = 0.0 specifies the default value is to be used. The default value is
max{10−10, EPS2∕3} for single precision and
max{10−20, EPS2∕3} for double precision
where
EPS =
AMACH(4). See the documentation for routine
AMACH in the
Reference Material.
LDCOV — Leading dimension of COV exactly as specified in the dimension statement in the calling program. (Input)
Default: LDCOV = size (COV,1).
NA — Number of residuals computed (including backcasts). (Output)
If NB values of the time series are backcast, then NA = NOBS ‑ IARDEG + NB.
A — Vector of length NOBS ‑ IARDEG + MAXBC containing the residuals (including backcasts) at the final parameter estimate point in the first NA locations. (Output)
FORTRAN 90 Interface
Generic: CALL NSLSE (W, PAR, LAGAR, PMA, LAGMA, MAXBC, CNST, COV, AVAR [, …])
Specific: The specific interface names are S_NSLSE and D_NSLSE.
FORTRAN 77 Interface
Single: CALL NSLSE (NOBS, W, IPRINT, IMEAN, WMEAN, NPAR, PAR, LAGAR, NPMA, PMA, LAGMA, MAXBC, TOLBC, TOLSS, CNST, COV, LDCOV, NA, A, AVAR)
Double: The double precision name is DNSLSE.
Description
Routine NSLSE computes least‑squares estimates of parameters for a nonseasonal ARMA model given a sample of n = NOBS observations {Wt} for t = 1, 2, …, n.
Suppose the time series {Wt} is generated by a nonseasonal ARMA model of the form
where B is the backward shift operator, μ is the mean of Wt,
with p = NPAR and q = NPMA. Without loss of generality, we assume
so that the nonseasonal ARMA model is of order (pʹ, qʹ) where pʹ = lɸ(p) and qʹ = lθ(q). Note that the usual hierarchal model assumes
Consider the sum of squares function
where
and T is the backward origin. The random shocks {At} are assumed to be independent and identically distributed
random variables. Hence, the log‑likelihood function is given by
where f(,μ,ɸ,θ) is a function of μ, ɸ, and θ.
For T = 0, the log‑likelihood function is conditional on the past values of both Wt and At required to initialize the model. The method of selecting these initial values usually introduces transient bias into the model (Box and Jenkins 1976, pages 210–211). For T = ∞, this dependency vanishes, and the estimation problem concerns maximization of the unconditional log‑likelihood function. Box and Jenkins (1976, page 213) argue that
dominates
The parameter estimates that minimize the sum of squares function are called least‑squares estimates. For large n, the unconditional least‑squares estimates are approximately equal to the maximum likelihood estimates.
In practice, a finite value of
T will enable sufficient approximation of the unconditional sum of squares function. The values of [
At] needed to compute the unconditional sum of squares are computed iteratively with initial values of
Wt obtained by back‑forecasting. The residuals (including backcasts), estimate of random shock variance, and covariance matrix of the final parameter estimates are also computed. Note that application of an appropriate transformation using routine
BCTR followed by differencing using routine
DIFF allows for fitting of nonseasonal ARIMA models. The algorithm for nonseasonal ARIMA models is developed in Chapter 7 of Box and Jenkins (1976). The extension to multiplicative seasonal ARIMA models is given in Box and Jenkins (1976, pages 500–504).
Comments
1. Workspace may be explicitly provided, if desired, by use of N2LSE/DN2LSE. The reference is:
CALL N2LSE (NOBS, W, IPRINT, IMEAN, WMEAN, NPAR, PAR, LAGAR, NPMA, PMA, LAGMA, MAXBC, TOLBC, TOLSS, CNST, COV, LDCOV, NA, A, AVAR, XGUESS, XSCALE, FSCALE, X, FVEC, FJAC, LDFJAC, RWKUNL, IWKUNL, WKNSRE, AI, FCST)
The additional arguments are as follows:
XGUESS — Work vector of length NP.
XSCALE — Work vector of length NP.
FSCALE — Work vector of length M.
X — Work vector of length NP.
FVEC — Work vector of length M.
FJAC — Work vector of length M * NP.
LDFJAC — Integer scalar equal to M.
RWKUNL — Work vector of length 10 * NP + 2 * M ‑ 1.
IWKUNL — Work vector of length NP.
WKNSRE — Work vector of length NOBS + MAXBC.
AI — Work vector of length IMADEG.
FCST — Work vector of length MAXBC.
2 Informational error
Type | Code | Description |
---|
3 | 1 | Least‑squares estimation of the parameters has failed to converge. Increase MAXBC and/or TOLBC and/or TOLSS. The estimates of the parameters at the last iteration may be used as new starting values. |
Example
Consider the Wölfer Sunspot Data (Anderson 1971, page 660) consisting of the number of sunspots observed each year from 1749 through 1924. The data set for this example consists of the number of sunspots observed from 1770 through 1869. Routine
NSPE is first invoked to compute preliminary estimates for an ARMA(2, 1) model. Then,
NSLSE is invoked with the preliminary estimates as input in order to compute the least‑squares estimates
for the ARMA(2, 1) model
where the errors At are independently distributed each normal with mean zero and variance
Note at the end of the output a warning error appears. Most of the time this error message can be ignored. There are three general reasons this error can occur.
1. Convergence was declared using the criterion based on TOLSS, but the gradient of the residual sum of squares function was nonzero. This occurred in this example. Either the message can be ignored or TOLSS can be reduced to allow more iterations and a slightly more accurate solution.
2. Convergence is declared based on the fact that a very small step was taken, but the gradient of the residual sum of squares function was nonzero. The message can usually be ignored. However, sometimes the algorithm is making very slow progress and is not near a minimum.
3. Convergence is not declared after 100 iterations.
Examination of the history of iterations using IPRINT = 2 and trying a smaller value for TOLSS can help you determine what caused the error message.
USE GDATA_INT
USE NSPE_INT
USE NSLSE_INT
IMPLICIT NONE
INTEGER IARDEG, IMEAN, LDCOV, LDX, MAXBC, MDX, NOBS, NP, &
NPAR, NPMA
PARAMETER (IARDEG=2, IMEAN=1, LDX=176, MAXBC=10, MDX=2, &
NOBS=100, NPAR=2, NPMA=1, NP=NPAR+NPMA+IMEAN, &
LDCOV=NP)
!
INTEGER IPRINT, LAGAR(NPAR), LAGMA(NPMA), MAXIT, NA, NCOL, &
NROW
REAL A(NOBS-IARDEG+MAXBC), AVAR, CNST, COV(LDCOV,NP), &
PAR(NPAR), PMA(NPMA), RELERR, TOLBC, TOLSS, W(NOBS), &
WMEAN, X(LDX,MDX)
!
EQUIVALENCE (W(1), X(22,2))
!
DATA LAGAR/1, 2/, LAGMA/1/
! Wolfer Sunspot Data for
! years 1770 through 1869
CALL GDATA (2, X, NROW, NCOL)
! USE Default Convergence parameters
! Compute preliminary parameter
! estimates for ARMA(2,1) model
IPRINT = 1
CALL NSPE (W, CNST, PAR, PMA, AVAR, IPRINT=IPRINT, WMEAN=WMEAN)
!
TOLBC = 0.0
TOLSS = 0.125
IPRINT = 2
!
CALL NSLSE (W, PAR, LAGAR, PMA, LAGMA, MAXBC, CNST, COV, &
AVAR, IMEAN=IMEAN, WMEAN=WMEAN, TOLSS=TOLSS, &
IPRINT=IPRINT)
!
END
Output
Results from NSPE/N2PE
WMEAN = 46.9760
CONST = 15.5440
AVAR = 287.242
PAR
1 2
1.244 -0.575
PMA
-0.1241
----------------------------------------------------------------------
Iteration 1
WMEAN = 52.638233185
PAR
1 2
1.264 -0.606
PMA
-0.1731
Residual SS (including backcasts) = 23908.66210937500
Number of residuals = 108
Number of backcasts = 10
----------------------------------------------------------------------
Iteration 2
WMEAN = 54.756504059
PAR
1 2
1.360 -0.688
PMA
-0.1411
Residual SS (including backcasts) = 23520.71484375000
Number of residuals = 108
Number of backcasts = 10
----------------------------------------------------------------------
Final Results, Iteration 3
Parameter Estimate Std. Error t-ratio
WMEAN 53.9187279 5.5178852 9.7716293
PAR
1 1.3925704 0.0960639 14.4962845
2 -0.7329484 0.0866115 -8.4624796
PMA
1 -0.1375125 0.1223797 -1.1236545
CNST = 18.3527489
AVAR = 243.4830170
Residual SS (including backcasts) = 23374.3691406
Number of residuals = 108
Residual SS (excluding backcasts) = 20931.7519531
Number of residuals = 98
*** WARNING ERROR 1 from NSLSE. Least squares estimation of the parameters
*** has failed to converge. Increase MAXBC and/or TOLBC and/or
*** TOLSS. The estimates of the parameters at the last iteration
*** may be used as new starting values.