int n_obs (Input) Number of observations in the time series.
float z[] (Input) An array of length n_obs containing the time series. No missing values in the series are allowed.
int maxlag (Input) The maximum lag allowed when fitting an AR(p) model.
intn_differences (Input) The number of differences to perform. Argument n_differences must be greater than or equal to one.
intn_s_initial (Input) The number of rows of the array containing the seasonal differences.
ints_initial[] (Input) Array of dimension n_s_initial by n_differences containing the seasonal differences to test. All values of s_initial must be greater than or equal to one.
Return Value
Pointer to an array of length n_obs or n_obs-n_lost containing the optimum seasonally adjusted, autoregressive series. The first n_lost observations in this series are set to NaN, missing values. The seasonal adjustment is done by selecting optimum values for , (m=n_differences) and in the AR model:
where is the original time series, is the backward shift operator defined by , , is Gaussian white noise with and , , with , and is a centering parameter for the differenced series.
IMSLS_D_INITIAL, int n_d_initial, int d_initial[],
IMSLS_SET_FIRST_TO_NAN, or
IMSLS_EXCLUDE_FIRST,
IMSLS_CENTER, intn_center,
IMSLS_LOST, int*n_lost,
IMSLS_BEST_PERIODS, int **s,
IMSLS_BEST_PERIODS_USER, ints[],
IMSLS_BEST_ORDERS, int **d,
IMSLS_BEST_ORDERS_USER, int d[],
IMSLS_AR_ORDER, int *p,
IMSLS_AIC, float*aic,
0)
Optional Arguments
IMSLS_RETURN_USER, float w[] (Output) An array of length n_obs supplied by the user to hold the seasonally adjusted series returned by imsls_f_seasonal_fit.
IMSLS_D_INITIAL, intn_d_initial, intd_initial[] (Input) An array of dimension n_d_initial by n_differences containing the candidate values for d[], from which the optimum is being selected. All candidate values in d_initial[] must be non-negative and n_d_initial≥ 1.
Default: n_d_initial=1, d_initial an array of length n_differences filled with ones.
IMSLS_SET_FIRST_TO_NAN (Input)
or
IMSLS_EXCLUDE_FIRST (Input) If IMSLS_EXCLUDE_FIRST is specified, the first n_lost values are excluded from w due to differencing. The differenced series w is of length n_obs–n_lost. If IMSLS_SET_FIRST_TO_NAN is specified, the first n_lost observations are set to NaN (Not a Number).
Default: IMSLS_SET_FIRST_TO_NAN.
IMSLS_CENTER, intn_center (Input) If supplied, IMSLS_CENTER controls the method used to center the differenced series. If n_center=0 then the series is not centered. If n_center=1, the mean of the series is used to center the data, and if n_center=2, the median is used.
Default: n_center=1.
IMSLS_LOST, int*n_lost (Output) The number of observations lost due to differencing the time series. This is also equal to the number of NaN values that appear in the first n_lost locations of the returned seasonally adjusted series.
IMSLS_BEST_PERIODS, int**s (Output) Address of a pointer to an internally allocated array of length m=n_differences containing the optimum values for the seasonal adjustment parameters selected from the list of candidates contained in s_initial[].
IMSLS_BEST_PERIODS_USER, ints[] (Output) A user supplied array of length n_differences for storage of the array s.
IMSLS_BEST_ORDERS, int**d (Output) Address of a pointer to an internally allocated array of length m=n_differences containing the optimum values for the seasonal adjustment parameters selected from the list of candidates contained in d_initial[].
IMSLS_BEST_ORDERS_USER, intd[] (Output) A user supplied array of length n_differences for storage of the array d.
IMSLS_AR_ORDER, int*p (Output) The optimum value for the autoregressive lag.
IMSLS_AIC,float*aic (Output) Akaike’s Information Criterion (AIC) for the optimum seasonally adjusted model.
Description
Many time series contain seasonal trends and cycles that can be modeled by first differencing the series. For example, if the correlation is strong from one period to the next, the series might be differenced by a lag of 1. Instead of fitting a model to the series , the model is fitted to the transformed series: . Higher order lags or differences are warranted if the series has a cycle every 4 or 13 weeks.
Function imsls_f_seasonal_fit does not center the original series. If IMSLS_CENTER is specified with either n_center =1 or n_center =2, then the differenced series, , is centered before determination of minimum AIC and optimum lag. For every combination of rows in s_initial and d_initial, the series is converted to the seasonally adjusted series using the following computation
where , represent specific rows of arrays s_initial and d_initial respectively, and =n_differences.
This transformation of the series to is accomplished using function imsls_f_difference. After this transformation,
is (optionally) centered and a call is made to imsls_f_auto_uni_ar to automatically determine the optimum lag for an AR(p) representation for . This procedure is repeated for every possible combination of rows of s_initial and d_initial. The series with the minimum AIC is identified as the optimum representation and returned.
Example
Consider the Airline Data (Box, Jenkins and Reinsel 1994, p. 547) consisting of the monthly total number of international airline passengers from January 1949 through December 1960. Function imsls_f_seasonal_fit is used to compute the optimum seasonality representation of the adjusted series