Class ARIMA
java.lang.Object
smile.timeseries.ARIMA
- All Implemented Interfaces:
Serializable
Autoregressive integrated moving average (ARIMA) model.
An ARIMA model generalizes the autoregressive moving-average (ARMA) model
to non-stationary time series by applying differencing one or more times
to eliminate trend and achieve stationarity.
The model is conventionally denoted as ARIMA(p, d, q), where:
pis the order of the autoregressive (AR) part,dis the degree of differencing (the integrated part),qis the order of the moving-average (MA) part.
Given a time series \(X_t\), the differenced series is: \[ Y_t = (1 - B)^d X_t = \Delta^d X_t \] where \(B\) is the backshift operator (\(B X_t = X_{t-1}\)). An \(\text{ARMA}(p, q)\) process is then fitted to \(Y_t\): \[ Y_t = c + \sum_{i=1}^p \phi_i Y_{t-i} + \epsilon_t + \sum_{j=1}^q \theta_j \epsilon_{t-j} \] When forecasting future values, predictions are first generated on the differenced series and then integrated (undifferenced) back to the original level of the series.
References
- George E. P. Box, Gwilym M. Jenkins, Gregory C. Reinsel, and Greta M. Ljung. Time Series Analysis: Forecasting and Control. 5th edition, John Wiley & Sons, 2015.
- Peter J. Brockwell and Richard A. Davis. Introduction to Time Series and Forecasting. 3rd edition, Springer, 2016.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the adjusted R2 on the fitted series.doubleaic()Returns the Akaike information criterion (AIC).double[]ar()Returns the linear coefficients of AR(p).arma()Returns the underlying ARMA model on the differenced series.doublebic()Returns the Bayesian information criterion (BIC).intd()Returns the degree of differencing.intdf()Returns the degrees of freedom of residual variance.static ARIMAfit(double[] x, int p, int q) Fits an ARIMA(p, 0, q) model without differencing (equivalent to ARMA(p, q)).static ARIMAfit(double[] x, int p, int d, int q) Fits an ARIMA(p, d, q) model.double[]Returns in-sample fitted values on the original series scale.doubleforecast()Returns 1-step ahead forecast on the original scale.double[]forecast(int l) Returns l-step ahead forecast on the original scale.doubleReturns the intercept / drift term.doubleReturns the log-likelihood of the model under Gaussian errors.double[]ma()Returns the linear coefficients of MA(q).doublemean()Returns the mean of the fitted (differenced) series.intp()Returns the order of AR.intq()Returns the order of MA.doubleR2()Returns the coefficient of determination R2 on the fitted series.double[]Returns in-sample residuals on the original series scale.doubleRSS()Returns the residual sum of squares.toString()double[][]ttest()Returns the hypothesis testing of the coefficients.doublevariance()Returns the residual variance.double[]x()Returns the original time series.
-
Constructor Details
-
ARIMA
Constructor.- Parameters:
x- the original time series.p- the order of AR.d- the degree of differencing.q- the order of MA.arma- the underlying ARMA model.diff- the intermediate differencing stages.
-
-
Method Details
-
x
public double[] x()Returns the original time series.- Returns:
- the original time series.
-
p
public int p()Returns the order of AR.- Returns:
- the order of AR.
-
d
public int d()Returns the degree of differencing.- Returns:
- the degree of differencing.
-
q
public int q()Returns the order of MA.- Returns:
- the order of MA.
-
arma
Returns the underlying ARMA model on the differenced series.- Returns:
- the ARMA model.
-
mean
public double mean()Returns the mean of the fitted (differenced) series.- Returns:
- the mean.
-
ar
public double[] ar()Returns the linear coefficients of AR(p).- Returns:
- the AR coefficients.
-
ma
public double[] ma()Returns the linear coefficients of MA(q).- Returns:
- the MA coefficients.
-
intercept
public double intercept()Returns the intercept / drift term.- Returns:
- the intercept.
-
fittedValues
public double[] fittedValues()Returns in-sample fitted values on the original series scale.- Returns:
- in-sample fitted values.
-
residuals
public double[] residuals()Returns in-sample residuals on the original series scale.- Returns:
- in-sample residuals.
-
RSS
public double RSS()Returns the residual sum of squares.- Returns:
- the residual sum of squares.
-
variance
public double variance()Returns the residual variance.- Returns:
- the residual variance.
-
df
public int df()Returns the degrees of freedom of residual variance.- Returns:
- the degrees of freedom.
-
R2
public double R2()Returns the coefficient of determination R2 on the fitted series.- Returns:
- R2.
-
adjustedR2
public double adjustedR2()Returns the adjusted R2 on the fitted series.- Returns:
- adjusted R2.
-
logLikelihood
public double logLikelihood()Returns the log-likelihood of the model under Gaussian errors.- Returns:
- the log-likelihood.
-
aic
public double aic()Returns the Akaike information criterion (AIC).- Returns:
- the AIC.
-
bic
public double bic()Returns the Bayesian information criterion (BIC).- Returns:
- the BIC.
-
ttest
public double[][] ttest()Returns the hypothesis testing of the coefficients.- Returns:
- the hypothesis testing table.
-
fit
Fits an ARIMA(p, d, q) model.- Parameters:
x- the time series.p- the order of AR.d- the degree of differencing.q- the order of MA.- Returns:
- the fitted ARIMA model.
-
fit
Fits an ARIMA(p, 0, q) model without differencing (equivalent to ARMA(p, q)).- Parameters:
x- the time series.p- the order of AR.q- the order of MA.- Returns:
- the fitted ARIMA model.
-
forecast
public double forecast()Returns 1-step ahead forecast on the original scale.- Returns:
- 1-step ahead forecast.
-
forecast
public double[] forecast(int l) Returns l-step ahead forecast on the original scale.- Parameters:
l- the number of forecast steps.- Returns:
- l-step ahead forecast.
-
toString
-