Automatic selection and fitting of a univariate autoregressive time series model. The lag for the model is automatically selected using Akaike's information criterion (AIC). Estimates of the autoregressive parameters for the model with minimum AIC are calculated using method of moments, method of least squares, or maximum likelihood.
#include
<imsls.h>
float *imsls_f_auto_uni_ar (int n_obs, float z[], int maxlag,
int *p,…,0)
The type double function is imsls_d_auto_uni_ar.
int n_obs
(Input)
Number of observations in the time series.
float z[]
(Input)
Array of length n_obs containing the
stationary time series.
int maxlag
(Input)
Maximum number of autoregressive parameters requested. It is required
that
1£ maxlag £ n_obs/2.
int *p
(Output)
Number of autoregressive parameters in the model with minimum AIC.
Vector of length 1+ maxlag containing the estimates for the constant and the autoregressive parameters in the model with minimum AIC. The estimates are located in the first 1+ p locations of this array.
float *imsls_f_auto_uni_ar
(int n_obs, float z[], int maxlag, int *p,
IMSLS_PRINT_LEVEL,
int iprint,
IMSLS_MAX_ITERATIONS,
int maxit,
IMSLS_METHOD, int method,
IMSLS_VAR_NOISE,
float *avar,
IMSLS_AIC, float
*aic,
IMSLS_MEAN_ESTIMATE,
float *z_mean,
IMSLS_RETURN_USER,
float *constant, float ar[],
0)
IMSLS_PRINT_LEVEL, int iprint
(Input)
Printing option:
0 — No printing.
1 — Prints final results
only.
2 — Prints intermediate and final
results.
Default: iprint = 0
IMSLS_MAX_ITERATIONS,
int maxit (Input)
Maximum number of
estimation iterations.
Default: maxit = 300
IMSLS_METHOD, int
method
(Input)
Estimation method option:
0 — Method
of moments
1 — Method of least squares
realized through Householder transformations
2 — Maximum likelihood
Default: method = 1
IMSLS_VAR_NOISE,
float *avar (Output)
Estimate of
innovation variance.
IMSLS_AIC, float
*aic
(Output)
Minimum AIC.
IMSLS_MEAN_ESTIMATE,
float *z_mean
(Input/Output)
Estimate of the mean of the time series z. On return, z_mean contains an
update of the mean.
Default: Time series z
is centered about its sample mean.
IMSLS_RETURN_USER,
float *constant, float
ar[] (Output)
If
specified, constant is the
constant parameter estimate, ar is an array of
length maxlag containing the
final autoregressive parameter estimates in its first p
locations.
Function auto_uni_ar automatically selects the order of the AR model that best fits the data and then computes the AR coefficients. The algorithm used in auto_uni_ar is derived from the work of Akaike, H., et. al (1979) and Kitagawa and Akaike (1978). This code was adapted from the UNIMAR procedure published as part of the TIMSAC-78 Library.
The best fit AR model is determined by successively fitting AR models with 0, 1, 2, ..., maxlag autoregressive coefficients. For each model, Akaike's Information Criterion (AIC) is calculated based on the formula
Function auto_uni_ar uses the approximation to this formula developed by Ozaki and Oda (1979),
where is an estimate of the residual variance of the series, commonly known in time series analysis as the innovation variance. By dropping the constant
the calculation is simplified to
The best fit model is the model with minimum AIC. If the number of parameters in this model is equal to the highest order autoregressive model fitted, i.e., p=maxlag, then a model with smaller AIC might exist for larger values of maxlag. In this case, increasing maxlag to explore AR models with additional autoregressive parameters might be warranted.
If method = 0, estimates of the autoregressive coefficients for the model with minimum AIC are calculated using method of moments. If method =1, the coefficients are determined by the method of least squares applied in the form described by Kitagawa and Akaike (1978). Otherwise, if method =2, the coefficients are estimated using maximum likelihood.
Consider the Wolfer Sunspot data (Anderson 1971, p. 660) consisting of the number of sunspots observed each year from 1770 through 1869. In this example, imsls_f_auto_uni_ar found the minimum AIC fit is an autoregressive model with 3 lags:
m the sample mean of the time series . Defining the overall constant by , we obtain the following equivalent representation:
The example computes estimates for for every of the three parameter estimation methods available.
imsls_f_data_sets (2, IMSLS_X_COL_DIM, 2,
/* Compute AR parameters for minimum AIC by method of moments */
printf("\n\nAIC Automatic Order selection\n");
printf("AR coefficients estimated using method of moments\n");
parameters = imsls_f_auto_uni_ar(n_obs, z, maxlag, &p,
printf("Order selected: %d\n", p);
printf("AIC = %11.4f, Variance = %11.4f\n", aic, avar);
printf("Constant estimate is %11.4f.\n", parameters[0]);
"Final AR coefficients estimated by method of moments",
/* Compute AR parameters for minimum AIC
printf("\n\nAIC Automatic Order selection\n");
printf("AR coefficients estimated using method of least squares\n");
imsls_f_auto_uni_ar(n_obs, z, maxlag, &p,
IMSLS_RETURN_USER, &constant, ar,
printf("Order selected: %d\n", p);
printf("AIC = %11.4f, Variance = %11.4f\n", aic, avar);
printf("Constant estimate is %11.4f.\n", constant);
"Final AR coefficients estimated by method of least squares",
/* Compute AR parameters for minimum AIC
by maximum likelihood estimation */
printf("\n\nAIC Automatic Order selection\n");
printf("AR coefficients estimated using maximum likelihood\n");
imsls_f_auto_uni_ar(n_obs, z, maxlag, &p,
IMSLS_RETURN_USER, &constant, ar,
printf("Order selected: %d\n", p);
printf("AIC = %11.4f, Variance = %11.4f\n", aic, avar);
printf("Constant estimate is %11.4f.\n", constant);
"Final AR coefficients estimated by maximum likelihood",
AR coefficients estimated using method of moments
AIC = 633.0114, Variance = 287.2694
Final AR coefficients estimated by method of moments
AR coefficients estimated using method of least squares
AIC = 633.0114, Variance = 144.7149
Final AR coefficients estimated by method of least squares
AR coefficients estimated using maximum likelihood
AIC = 633.0114, Variance = 218.8337
Final AR coefficients estimated by maximum likelihood
3 0.205 XE "ARIMA models:method of moments estimates" \r "ARIMA"
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |