.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_data_analysis/estimate_stochastic_processes/plot_estimate_multivariate_arma.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_data_analysis_estimate_stochastic_processes_plot_estimate_multivariate_arma.py: Estimate a multivariate ARMA process ==================================== .. GENERATED FROM PYTHON SOURCE LINES 6-32 The objective of the Use Case is to estimate a multivariate ARMA model from a stationary time series using the maximum likelihood estimator and a centered normal white noise. The data can be a unique time series or several time series collected in a process sample. We estimate :math:`(\underline{\beta}, \sigma^2)` thanks to the *ARMALikelihoodFactory* object and its method *build*, acting on a time series or on a sample of time series. It produces a result of type *ARMA*. Note that no evaluation of selection criteria such as *AIC* and *BIC* is done. The synthetic data is generated from the 2-d ARMA model: .. math:: \begin{aligned} X_{0,t} - 0.5 X_{0,t-1} - 0.1 X_{1,t-1} = E_{0,t} - 0.4 E_{0,t-1} \\ X_{1,t} - 0.4 X_{0,t-1} - 0.5 X_{1,t-1} - 0.25 X_{0,t-2} = E_{1,t} - 0.4 E_{1,t-1} \end{aligned} with E the white noise: .. math:: E \sim \mathcal{N} ([0,0], [0.1,0.2]) .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. code-block:: default import openturns as ot ot.Log.Show(ot.Log.NONE) .. GENERATED FROM PYTHON SOURCE LINES 38-39 Create a 2-d ARMA process .. GENERATED FROM PYTHON SOURCE LINES 39-64 .. code-block:: default p = 2 q = 1 dim = 2 # Tmin , Tmax and N points for TimeGrid dt = 1.0 size = 400 timeGrid = ot.RegularGrid(0.0, dt, size) # white noise cov = ot.CovarianceMatrix([[0.1, 0.0], [0.0, 0.2]]) whiteNoise = ot.WhiteNoise(ot.Normal([0.0] * dim, cov), timeGrid) # AR/MA coefficients ar = ot.ARMACoefficients(p, dim) ar[0] = ot.SquareMatrix([[-0.5, -0.1], [-0.4, -0.5]]) ar[1] = ot.SquareMatrix([[0.0, 0.0], [-0.25, 0.0]]) ma = ot.ARMACoefficients(q, dim) ma[0] = ot.SquareMatrix([[-0.4, 0.0], [0.0, -0.4]]) # ARMA model creation arma = ot.ARMA(ar, ma, whiteNoise) arma .. raw:: html

ARMA(X_{0,t} - 0.5 X_{0,t-1} - 0.1 X_{1,t-1} = E_{0,t} - 0.4 E_{0,t-1}
X_{1,t} - 0.4 X_{0,t-1} - 0.5 X_{1,t-1} - 0.25 X_{0,t-2} = E_{1,t} - 0.4 E_{1,t-1}, E_t ~ Normal(mu = [0,0], sigma = [0.316228,0.447214], R = [[ 1 0 ]
[ 0 1 ]]))



.. GENERATED FROM PYTHON SOURCE LINES 65-66 Create a realization .. GENERATED FROM PYTHON SOURCE LINES 66-68 .. code-block:: default timeSeries = ot.TimeSeries(arma.getRealization()) .. GENERATED FROM PYTHON SOURCE LINES 69-70 Estimate the process from the previous realization .. GENERATED FROM PYTHON SOURCE LINES 70-75 .. code-block:: default factory = ot.ARMALikelihoodFactory(p, q, dim) factory.setInitialConditions(ar, ma, cov) arma_est = ot.ARMA(factory.build(timeSeries)) print('Estimated ARMA= ', arma_est) .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Estimated ARMA= ARMA(X_{0,t} - 0.555208 X_{0,t-1} - 0.172356 X_{1,t-1} + 0.060835 X_{0,t-2} + 0.0196977 X_{1,t-2} = E_{0,t} - 0.563682 E_{0,t-1} - 0.0886412 E_{1,t-1} X_{1,t} - 0.31059 X_{0,t-1} - 0.324568 X_{1,t-1} - 0.344984 X_{0,t-2} - 0.106736 X_{1,t-2} = E_{1,t} + 0.133454 E_{0,t-1} - 0.234867 E_{1,t-1}, E_t ~ Normal(mu = [0,0], sigma = [0.299621,0.455163], R = [[ 1 0.0160279 ] [ 0.0160279 1 ]])) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 3.766 seconds) .. _sphx_glr_download_auto_data_analysis_estimate_stochastic_processes_plot_estimate_multivariate_arma.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_estimate_multivariate_arma.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_estimate_multivariate_arma.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_