Extreme Optimization™: Complexity made simple.

Math and Statistics
Libraries for .NET

  • Home
  • Features
    • Math Library
    • Vector and Matrix Library
    • Statistics Library
    • Performance
    • Usability
  • Documentation
    • Introduction
    • Math Library User's Guide
    • Vector and Matrix Library User's Guide
    • Data Analysis Library User's Guide
    • Statistics Library User's Guide
    • Reference
  • Resources
    • Downloads
    • QuickStart Samples
    • Sample Applications
    • Frequently Asked Questions
    • Technical Support
  • Blog
  • Order
  • Company
    • About us
    • Testimonials
    • Customers
    • Press Releases
    • Careers
    • Partners
    • Contact us
Introduction
Deployment Guide
Nuget packages
Configuration
Using Parallelism
Expand Mathematics Library User's GuideMathematics Library User's Guide
Expand Vector and Matrix Library User's GuideVector and Matrix Library User's Guide
Expand Data Analysis Library User's GuideData Analysis Library User's Guide
Expand Statistics Library User's GuideStatistics Library User's Guide
Expand Data Access Library User's GuideData Access Library User's Guide
Expand ReferenceReference
  • Extreme Optimization
    • Features
    • Solutions
    • Documentation
    • QuickStart Samples
    • Sample Applications
    • Downloads
    • Technical Support
    • Download trial
    • How to buy
    • Blog
    • Company
    • Resources
  • Documentation
    • Introduction
    • Deployment Guide
    • Nuget packages
    • Configuration
    • Using Parallelism
    • Mathematics Library User's Guide
    • Vector and Matrix Library User's Guide
    • Data Analysis Library User's Guide
    • Statistics Library User's Guide
    • Data Access Library User's Guide
    • Reference
  • Statistics Library User's Guide
    • Statistical Variables
    • Numerical Variables
    • Statistical Models
    • Regression Analysis
    • Analysis of Variance
    • Time Series Analysis
    • Multivariate Analysis
    • Continuous Distributions
    • Discrete Distributions
    • Multivariate Distributions
    • Kernel Density Estimation
    • Hypothesis Tests
    • Appendices
  • Time Series Analysis
    • Exponential Smoothing
    • ARIMA Models
    • GARCH Models
    • Other Time Series Functions
  • ARIMA Models

ARIMA Models

Extreme Optimization Numerical Libraries for .NET Professional

Auto-Regressive Integrated Moving Average (ARIMA) models are used to model time series data and produce forecasts for future values.

The type of ARIMA model is usually specified as ARIMA(p,d,q). p is the autoregressive (AR)order, or the number of autoregressive components. q is the moving average (MA) order, or the number of moving average components in the model. d is the degree of differencing. When d is zero, the model is called an ARMA(p,q) model. When in addition p or q is zero, the model is called an MA(q) model or AR(p) model, respectively.

ARIMA models are implemented by the ArimaModel class.

Creating ARIMA Models

The ArimaModel class has two constructors. The first takes three arguments and is used to construct an ARMA(p,q) model. The first argument is a VectorT that contains the time series data. The second and third arguments are the autoregressive and moving average order, respectively. The following creates an ARMA(2,1), or equivalently, an ARIMA(2,0,1) model for a time series vector y.

C#
VB
C++
F#
Copy
var model1 = new ArimaModel(y, 2, 1);
Dim model1 = New ArimaModel(y, 2, 1)

No code example is currently available or this language may not be supported.

let model1 = new ArimaModel(y, 2, 1)

The second constructor takes four arguments and is used to construct ARIMA(p,d,q) models. The first argument is once again the VectorT that contains the time series data. The remaining arguments are the autoregressive order, degree of differencing, and the moving average order. For example, to create an ARIMA(1,1,1) model, we can write:

C#
VB
C++
F#
Copy
var model2 = new ArimaModel(y, 1, 1, 1);
Dim model2 = New ArimaModel(y, 1, 1, 1)

No code example is currently available or this language may not be supported.

let model2 = new ArimaModel(y, 1, 1, 1)

For an ARMA(p,q) model, the mean is usually not zero, and it is estimated by default. When a series is differenced enough times, the mean of the differenced series will be close to zero. For ARIMA models with nonzero degree of differencing, the mean is not estimated by default. In each case, the default behavior can be overridden by setting the EstimateMean property.

Computing the Model

The Compute method estimates the parameters of the model by minimizing the exact maximum likelihood function.

The parameters of the model can be retrieved through the Parameters collection. The first p parameters are the coefficients of the autoregressive components. The next q parameters are the coefficients of the moving average components. If the mean was estimated also, it is returned as the last parameter. The autoregressive and moving average coefficients can also be retrieved separately through the AutoRegressiveParameters and MovingAverageParameters properties.

The members of these collections are of type ParameterT, and can be used to obtain a wide range of information about the computed values, including the standard error, significance tests and confidence intervals.

C#
VB
C++
F#
Copy
model1.Fit();
Console.WriteLine("AR(0): {0}", model1.AutoRegressiveParameters[0].Value);
Console.WriteLine("MA(0): {0}", model1.MovingAverageParameters[0].Value);
Console.WriteLine("Mean: {0}", model1.Parameters[3].Value);
Console.WriteLine(model1.ParameterValues);
model1.Fit()
Console.WriteLine("AR(0): {0}", model1.AutoRegressiveParameters(0).Value)
Console.WriteLine("MA(0): {0}", model1.MovingAverageParameters(0).Value)
Console.WriteLine("Mean: {0}", model1.Parameters(3).Value)
Console.WriteLine(model1.ParameterValues)

No code example is currently available or this language may not be supported.

model1.Fit()
printfn "AR(0): %f" model1.AutoRegressiveParameters.[0].Value
printfn "MA(0): %f" model1.MovingAverageParameters.[0].Value
printfn "Mean: %f" model1.Parameters.[3].Value
printfn "%A" model1.ParameterValues
Verifying the Quality of the Model

Because an ARIMA model is computed by directly maximizing the likelihood function, it does not have the same range of diagnostic values available for linear regression models. Still, a number of standard measures are available.

The LogLikelihood method returns the logarithm of the likelihood of the computed model. The GetAkaikeInformationCriterion method returns the Akaike Information Criterion (AIC) value. This is commonly used to compare different models. The GetBayesianInformationCriterion method returns the Bayesian Information Criterion (BIC) value, which is sometimes used instead of the AIC.

C#
VB
C++
F#
Copy
var ll = model1.LogLikelihood;
var aic = model1.GetAkaikeInformationCriterion();
var bic = model1.GetBayesianInformationCriterion();
Dim ll = model1.LogLikelihood
Dim aic = model1.GetAkaikeInformationCriterion()
Dim bic = model1.GetBayesianInformationCriterion()

No code example is currently available or this language may not be supported.

let ll = model1.LogLikelihood
let aic = model1.GetAkaikeInformationCriterion()
let bic = model1.GetBayesianInformationCriterion()

Another way to test the model is by looking at the residuals. If the model is adequate, the residuals should no longer be correlated. This can be tested using the Ljung-Box test. This test is implemented by the LjungBoxTest class. The ARIMA model object provides a convenience method, GetLjungBoxTest, that returns the Ljung-Box test with the correct degrees of freedom. The method takes one argument: the number of auto-correlations to include in the test.

C#
VB
C++
F#
Copy
var lb = model1.GetLjungBoxTest(5);
Console.WriteLine("Ljung-Box χ2: {0:F2}", lb.Statistic);
Console.WriteLine("Ljung-Box p: {0:F4}", lb.PValue);
Dim lb = model1.GetLjungBoxTest(5)
Console.WriteLine("Ljung-Box χ2: {0:F2}", lb.Statistic)
Console.WriteLine("Ljung-Box p: {0:F4}", lb.PValue)

No code example is currently available or this language may not be supported.

let lb = model1.GetLjungBoxTest(5)
printfn "Ljung-Box χ2: %.2f" lb.Statistic
printfn "Ljung-Box p: %.4f" lb.PValue
Forecasting

Once the model has been computed, the Forecast method can then be used to forecast new values. This method has three overloads.

Without arguments, the method returns the one step ahead forecast based on the computed model. With a single argument, it computes a point forecast the specified number of steps ahead. It returns a VectorT that contains the point forecast for the specified number of periods.

C#
VB
C++
F#
Copy
var forecast = model2.Forecast(4);
Dim forecast = model2.Forecast(4)

No code example is currently available or this language may not be supported.

let forecast = model2.Forecast(4)
See Also

Reference

TimeSeriesModelT
ArimaModel

Copyright (c) 2004-2021 ExoAnalytics Inc.

Send comments on this topic to support@extremeoptimization.com

Copyright © 2004-2021, Extreme Optimization. All rights reserved.
Extreme Optimization, Complexity made simple, M#, and M Sharp are trademarks of ExoAnalytics Inc.
Microsoft, Visual C#, Visual Basic, Visual Studio, Visual Studio.NET, and the Optimized for Visual Studio logo
are registered trademarks of Microsoft Corporation.