|
JMSLTM Numerical Library 6.1 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.imsl.stat.ARSeasonalFit
public class ARSeasonalFit
Estimates the optimum seasonality parameters for a time series using an autoregressive model, AR(p), to represent the time series.
ARMA time series modeling assumes the time series is stationary. Seasonal
trends and cycles violate this assumption, which can lead to inaccurate
predictions. However, in many cases the nonstationary series can be
transformed into a stationary series 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
original series
, the model is fitted to the
transformed series:
. Higher order
lags or differences are warranted if the series has cycles every 4 or 13
weeks. Class ARSeasonalFit is designed to help identify the
optimum differencing for a series with seasonal trends or cycles.
ARSeasonalFit assumes the original series has no missing
values, is equally spaced in time and is not centered before computing the
optimum differencing. However, by default the transformed series is centered
using the mean of that series. Users can change this default using the
setCentersetCenter is set to
NO_CENTERCENTER_MEANCENTER_MEDIANsetCenter
is set to CENTER_MEAN or CENTER_MEDIAN then the
differenced series,
is centered before determination
of minimum AIC and optimum lag.
For every combination of rows in sInitial and dInitial
, the series
is converted to the seasonally
adjusted series using the following computation
![]()
sInitial
and dInitial respectively, and m is the number of
differences, or m=sInitial[0].length.
This transformation of the series
to
is computed using the Difference class.
After this transformation the transformed series
![]()
NO_CENTER is specified, and the
ARAutoUnivariateThis procedure is repeated for every possible combination of rows in
sInitial and dInitial. The series with the minimum
AIC is identified as the optimum representation and returned in the methods
getAROrdergetOptimumSgetOptimumDgetAICgetAR
getTransformedTimeSeries
| Field Summary | |
|---|---|
static int |
CENTER_MEAN
Indicates the transformed series should be centered using the average of the differenced series. |
static int |
CENTER_MEDIAN
Indicates the transformed series should be centered using the median of the differenced series. |
static int |
NO_CENTER
Indicates the transformed series should not be centered. |
| Constructor Summary | |
|---|---|
ARSeasonalFit(int maxlag,
int[][] sInitial,
double[] z)
Constructor for ARSeasonalFit. |
|
| Method Summary | |
|---|---|
void |
compute()
Computes the minimum AIC and optimum values for s and d based upon the candidates provided in sInitial and
dInitial, and computes the values for the transformed series,
|
double |
getAIC()
Returns the final estimate for Akaike's Information Criterion (AIC) at the optimum. |
double[] |
getAR()
Returns the final autoregressive parameter estimates at the optimum in the transformed series |
int |
getAROrder()
Returns optimum number of lags, p, for the optimum autoregressive AR(p) model. |
int |
getCenter()
Returns the current setting for centering the input time series. |
int[][] |
getDInitial()
Returns the candidate values for d to evaluate. |
boolean |
getExclude()
Returns the current setting for excluding or replacing the inital values in the transformed series. |
int |
getMaxlag()
Returns the maximum lag used to fit the AR(p) model. |
int |
getNLost()
Returns the number of values in the initial part of the series lost to differencing. |
int[] |
getOptimumD()
Returns the optimum values for d selected among the candidates in dInitial. |
int[] |
getOptimumS()
Returns the optimum values for s selected among the candidates in sInitial. |
int[][] |
getSInitial()
Returns the the candidate values for s to evaluate. |
double[] |
getTimeSeries()
Returns the time series. |
double[] |
getTransformedTimeSeries()
Returns the transformed series, |
void |
setCenter(int center)
Controls centering of the differenced series. |
void |
setDInitial(int[][] dInitial)
Sets the candidate values for selecting the optimum seasonal adjustment prior to calling the compute method. |
void |
setExclude(boolean exclude)
Controls whether to exclude or replace the inital values in the transformed series. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int CENTER_MEAN
public static final int CENTER_MEDIAN
public static final int NO_CENTER
| Constructor Detail |
|---|
public ARSeasonalFit(int maxlag,
int[][] sInitial,
double[] z)
ARSeasonalFit.
maxlag - an int scalar specifying the maximum lag
allowed when fitting an AR(p) model.sInitial - an int matrix where each row represents
seasonal differences to evaluate. The number of columns
in sInitial represent the number of
differences to perform. All values of sInitial
must be greater than zero.z - an input double array containing the time
series.| Method Detail |
|---|
public void compute()
throws ARMA.MatrixSingularException,
ARMA.TooManyCallsException,
ARMA.IncreaseErrRelException,
ARMA.NewInitialGuessException,
ARMA.IllConditionedException,
ARMA.TooManyITNException,
ARMA.TooManyFcnEvalException,
ARMA.TooManyJacobianEvalException,
ARMA.NoProgressException,
ARAutoUnivariate.TriangularMatrixSingularException,
ARMAMaxLikelihood.NonInvertibleException,
ARMAMaxLikelihood.NonStationaryException,
ARMAMaxLikelihood.InitialMAException
sInitial and
dInitial, and computes the values for the transformed series,
Warnings are printed if a row in sInitial is skipped due
to too many observations lost in the differenced series or if problems
occurred computing the optimum AIC using the differenced series.
ARMA.MatrixSingularException - is thrown if the input matrix is
singular
ARMA.TooManyCallsException - is thrown if the number of calls
to the function has exceeded the maximum number of
iterations times the number of moving average (MA)
parameters + 1.
ARMA.IncreaseErrRelException - is thrown if the bound for the
relative error is too small
ARMA.NewInitialGuessException - is thrown if the iteration has
not made good progress
ARMA.IllConditionedException - is thrown if the problem is
ill-conditioned
ARMA.TooManyITNException - is thrown if the maximum number of
iterations is exceeded
ARMA.TooManyFcnEvalException - is thrown if the maximum number
of function evaluations is exceeded
ARMA.TooManyJacobianEvalException - is thrown if the maximum
number of Jacobian evaluations is exceeded
NoProgressException - is thrown when the algorithm is not
making any progress. Try a new initial guess.
ARMAMaxLikelihood.NonStationaryException - is thrown if the
final maximum likelihood estimates for the time series
are nonstationary
ARMAMaxLikelihood.NonInvertibleException - is thrown if the
final maximum likelihood estimates for the time series
are noninvertible
ARMAMaxLikelihood.InitialMAException - is thrown if the initial
values provided for the moving average terms using
setMA are noninvertible. In this case,
ARMAMaxLikelihood terminates and does not compute
the time series estimates.
ARAutoUnivariate.TriangularMatrixSingularException - is thrown
if the input triangular matrix is singular.
ARMA.NoProgressExceptionpublic double getAIC()
double equal to
public double[] getAR()
throws ARMA.MatrixSingularException,
ARMA.TooManyCallsException,
ARMA.IncreaseErrRelException,
ARMA.NewInitialGuessException,
ARMA.IllConditionedException,
ARMA.TooManyITNException,
ARMA.TooManyFcnEvalException,
ARMA.TooManyJacobianEvalException,
ARMA.NoProgressException,
ARAutoUnivariate.TriangularMatrixSingularException,
ARMAMaxLikelihood.NonInvertibleException,
ARMAMaxLikelihood.NonStationaryException,
ARMAMaxLikelihood.InitialMAException
double array containing the estimates for the
autoregressive parameters
ARMA.MatrixSingularException - is thrown if the input matrix is
singular
ARMA.TooManyCallsException - is thrown if the number of calls
to the function has exceeded the maximum number of
iterations times the number of moving average (MA)
parameters + 1.
ARMA.IncreaseErrRelException - is thrown if the bound for the
relative error is too small
ARMA.NewInitialGuessException - is thrown if the iteration has
not made good progress
ARMA.IllConditionedException - is thrown if the problem is
ill-conditioned
ARMA.TooManyITNException - is thrown if the maximum number of
iterations is exceeded
ARMA.TooManyFcnEvalException - is thrown if the maximum number
of function evaluations is exceeded
ARMA.TooManyJacobianEvalException - is thrown if the maximum
number of Jacobian evaluations is exceeded
NoProgressException - is thrown when the algorithm is not
making any progress. Try a new initial guess.
ARMAMaxLikelihood.NonStationaryException - is thrown if the
final maximum likelihood estimates for the time series
are nonstationary
ARMAMaxLikelihood.NonInvertibleException - is thrown if the
final maximum likelihood estimates for the time series
are noninvertible
ARMAMaxLikelihood.InitialMAException - is thrown if the initial
values provided for the moving average terms using
setMA are noninvertible. In this case,
ARMAMaxLikelihood terminates and does not compute
the time series estimates.
ARAutoUnivariate.TriangularMatrixSingularException - is thrown
if the input triangular matrix is singular.
ARMA.NoProgressExceptionpublic int getAROrder()
int containing the optimum number of lags in the
autoregressive model used to fit the transformed series
public int getCenter()
int containing the setting for center equal to 0,
1, or 2, which implies
NO_CENTERCENTER_MEANCENTER_MEDIANpublic int[][] getDInitial()
int matrix containing the candidate values for
d to evaluatepublic boolean getExclude()
If exclude is true, then inital values in the transformed
series that cannot be computed are set to missing, NaN. This
ensures that the length of the transformed series
is equal to the length of the time series, z.length
. If exclude is set to false, then inital values in
the transformed series
that cannot be computed
are removed. This makes the length of the transformed series
equal to z.length-nLost where nLost
is the number of lost values obtained from method
getNLost
public int getMaxlag()
int scalar containing the maximum lag allowed
when fitting an AR(p) model
public int getNLost()
throws ARMA.MatrixSingularException,
ARMA.TooManyCallsException,
ARMA.IncreaseErrRelException,
ARMA.NewInitialGuessException,
ARMA.IllConditionedException,
ARMA.TooManyITNException,
ARMA.TooManyFcnEvalException,
ARMA.TooManyJacobianEvalException,
ARMA.NoProgressException,
ARAutoUnivariate.TriangularMatrixSingularException,
ARMAMaxLikelihood.NonInvertibleException,
ARMAMaxLikelihood.NonStationaryException,
ARMAMaxLikelihood.InitialMAException
int containing the number of values in the
initial part of the series lost to differencing. These lost
values will be set to missing or dropped in the transformed
series, depending upon the setting for exclude.
ARMA.MatrixSingularException - is thrown if the input matrix is
singular
ARMA.TooManyCallsException - is thrown if the number of calls
to the function has exceeded the maximum number of
iterations times the number of moving average (MA)
parameters + 1.
ARMA.IncreaseErrRelException - is thrown if the bound for the
relative error is too small
ARMA.NewInitialGuessException - is thrown if the iteration has
not made good progress
ARMA.IllConditionedException - is thrown if the problem is
ill-conditioned
ARMA.TooManyITNException - is thrown if the maximum number of
iterations is exceeded
ARMA.TooManyFcnEvalException - is thrown if the maximum number
of function evaluations is exceeded
ARMA.TooManyJacobianEvalException - is thrown if the maximum
number of Jacobian evaluations is exceeded
NoProgressException - is thrown when the algorithm is not
making any progress. Try a new initial guess.
ARMAMaxLikelihood.NonStationaryException - is thrown if the
final maximum likelihood estimates for the time series
are nonstationary
ARMAMaxLikelihood.NonInvertibleException - is thrown if the
final maximum likelihood estimates for the time series
are noninvertible
ARMAMaxLikelihood.InitialMAException - is thrown if the initial
values provided for the moving average terms using
setMA are noninvertible. In this case,
ARMAMaxLikelihood terminates and does not compute
the time series estimates.
ARAutoUnivariate.TriangularMatrixSingularException - is thrown
if the input triangular matrix is singular.
ARMA.NoProgressException
public int[] getOptimumD()
throws ARMA.MatrixSingularException,
ARMA.TooManyCallsException,
ARMA.IncreaseErrRelException,
ARMA.NewInitialGuessException,
ARMA.IllConditionedException,
ARMA.TooManyITNException,
ARMA.TooManyFcnEvalException,
ARMA.TooManyJacobianEvalException,
ARMA.NoProgressException,
ARAutoUnivariate.TriangularMatrixSingularException,
ARMAMaxLikelihood.NonInvertibleException,
ARMAMaxLikelihood.NonStationaryException,
ARMAMaxLikelihood.InitialMAException
dInitial.
int array of length dInitial[0].length
containing the optimum values for d selected
among the candidates in dInitial
ARMA.MatrixSingularException - is thrown if the input matrix is
singular
ARMA.TooManyCallsException - is thrown if the number of calls
to the function has exceeded the maximum number of
iterations times the number of moving average (MA)
parameters + 1.
ARMA.IncreaseErrRelException - is thrown if the bound for the
relative error is too small
ARMA.NewInitialGuessException - is thrown if the iteration has
not made good progress
ARMA.IllConditionedException - is thrown if the problem is
ill-conditioned
ARMA.TooManyITNException - is thrown if the maximum number of
iterations is exceeded
ARMA.TooManyFcnEvalException - is thrown if the maximum number
of function evaluations is exceeded
ARMA.TooManyJacobianEvalException - is thrown if the maximum
number of Jacobian evaluations is exceeded
NoProgressException - is thrown when the algorithm is not
making any progress. Try a new initial guess.
ARMAMaxLikelihood.NonStationaryException - is thrown if the
final maximum likelihood estimates for the time series
are nonstationary
ARMAMaxLikelihood.NonInvertibleException - is thrown if the
final maximum likelihood estimates for the time series
are noninvertible
ARMAMaxLikelihood.InitialMAException - is thrown if the initial
values provided for the moving average terms using
setMA are noninvertible. In this case,
ARMAMaxLikelihood terminates and does not compute
the time series estimates.
ARAutoUnivariate.TriangularMatrixSingularException - is thrown
if the input triangular matrix is singular.
ARMA.NoProgressException
public int[] getOptimumS()
throws ARMA.MatrixSingularException,
ARMA.TooManyCallsException,
ARMA.IncreaseErrRelException,
ARMA.NewInitialGuessException,
ARMA.IllConditionedException,
ARMA.TooManyITNException,
ARMA.TooManyFcnEvalException,
ARMA.TooManyJacobianEvalException,
ARMA.NoProgressException,
ARAutoUnivariate.TriangularMatrixSingularException,
ARMAMaxLikelihood.NonInvertibleException,
ARMAMaxLikelihood.NonStationaryException,
ARMAMaxLikelihood.InitialMAException
sInitial.
int array of length sInitial[0].length
containing the optimum values for s selected among
the candidates in sInitial
ARMA.MatrixSingularException - is thrown if the input matrix is
singular
ARMA.TooManyCallsException - is thrown if the number of calls
to the function has exceeded the maximum number of
iterations times the number of moving average (MA)
parameters + 1.
ARMA.IncreaseErrRelException - is thrown if the bound for the
relative error is too small
ARMA.NewInitialGuessException - is thrown if the iteration has
not made good progress
ARMA.IllConditionedException - is thrown if the problem is
ill-conditioned
ARMA.TooManyITNException - is thrown if the maximum number of
iterations is exceeded
ARMA.TooManyFcnEvalException - is thrown if the maximum number
of function evaluations is exceeded
ARMA.TooManyJacobianEvalException - is thrown if the maximum
number of Jacobian evaluations is exceeded
NoProgressException - is thrown when the algorithm is not
making any progress. Try a new initial guess.
ARMAMaxLikelihood.NonStationaryException - is thrown if the
final maximum likelihood estimates for the time series
are nonstationary
ARMAMaxLikelihood.NonInvertibleException - is thrown if the
final maximum likelihood estimates for the time series
are noninvertible
ARMAMaxLikelihood.InitialMAException - is thrown if the initial
values provided for the moving average terms using
setMA are noninvertible. In this case,
ARMAMaxLikelihood terminates and does not compute
the time series estimates.
ARAutoUnivariate.TriangularMatrixSingularException - is thrown
if the input triangular matrix is singular.
ARMA.NoProgressExceptionpublic int[][] getSInitial()
int matrix containing the candidate values for
s to evaluatepublic double[] getTimeSeries()
double array containing the time series values
public double[] getTransformedTimeSeries()
throws ARMA.MatrixSingularException,
ARMA.TooManyCallsException,
ARMA.IncreaseErrRelException,
ARMA.NewInitialGuessException,
ARMA.IllConditionedException,
ARMA.TooManyITNException,
ARMA.TooManyFcnEvalException,
ARMA.TooManyJacobianEvalException,
ARMA.NoProgressException,
ARAutoUnivariate.TriangularMatrixSingularException,
ARMAMaxLikelihood.NonInvertibleException,
ARMAMaxLikelihood.NonStationaryException,
ARMAMaxLikelihood.InitialMAException
is an array of length z.length
or z.length-nLost containing the optimum seasonally
adjusted, autoregressive series, where nLost is the first
lost observations in this series that are dropped due to differencing. If
the missing values are not dropped the first nLost values of
will be set (Double.NaN). The
getNLostnLost.
The seasonal adjustment is done by selecting optimum values for
,
(m is number of differences or sIinitial[0].length)
and p in the AR model:
![]()
double array of length z.length or
z.length-nLost, depending upon the setting for
setExclude
ARMA.MatrixSingularException - is thrown if the input matrix is
singular
ARMA.TooManyCallsException - is thrown if the number of calls
to the function has exceeded the maximum number of
iterations times the number of moving average (MA)
parameters + 1.
ARMA.IncreaseErrRelException - is thrown if the bound for the
relative error is too small
ARMA.NewInitialGuessException - is thrown if the iteration has
not made good progress
ARMA.IllConditionedException - is thrown if the problem is
ill-conditioned
ARMA.TooManyITNException - is thrown if the maximum number of
iterations is exceeded
ARMA.TooManyFcnEvalException - is thrown if the maximum number
of function evaluations is exceeded
ARMA.TooManyJacobianEvalException - is thrown if the maximum
number of Jacobian evaluations is exceeded
NoProgressException - is thrown when the algorithm is not
making any progress. Try a new initial guess.
ARMAMaxLikelihood.NonStationaryException - is thrown if the
final maximum likelihood estimates for the time series
are nonstationary
ARMAMaxLikelihood.NonInvertibleException - is thrown if the
final maximum likelihood estimates for the time series
are noninvertible
ARMAMaxLikelihood.InitialMAException - is thrown if the initial
values provided for the moving average terms using
setMA are noninvertible. In this case,
ARMAMaxLikelihood terminates and does not compute
the time series estimates.
ARAutoUnivariate.TriangularMatrixSingularException - is thrown
if the input triangular matrix is singular.
ARMA.NoProgressExceptionpublic void setCenter(int center)
center - an int scalar value equal
NO_CENTER
CENTER_MEANCENTER_MEDIAN
center=CENTER_MEANpublic void setDInitial(int[][] dInitial)
dInitial - an int array of candidate values for d
to evaluate. All values must be non-negative.
dInitial must have the same number of
differences (columns) as sInitial. By
default, dInitial is initialized to all
ones.public void setExclude(boolean exclude)
If exclude is true, then inital values in the transformed
series that cannot be computed are set to missing, NaN. This
ensures that the length of the transformed series
is equal to the length of the time series, z.length
. If exclude is set to false, then inital values in
the transformed series
that cannot be computed
are removed. This makes the length of the transformed series
equal to z.length-nLost where nLost
is the number of lost values obtained from method
getNLost
exclude - a boolean value that controls whether values
in Double.NaN. By default, exclude
=true
|
JMSLTM Numerical Library 6.1 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||