# Compute Expectation of Autoregressive Moving-Average Process from Its Definition

This example explores an ARMA process with initial values. It constructs process values in terms of the sequence of innovations and uses enhanced support of random processes in Expectation to compute the mean and covariance of the process slices. Furthermore, stationary time series process is reinterpreted as time series process with random initial values.

Define autoregressive moving-average process values via its defining relation as a function of driving white noise process values .

 In:= Xtmax = 5; innovations = Table[\[ScriptE][t], {t, 0, tmax}]
 Out= Process values for ARMA(2,1) process.

 In:= Xpv = RecurrenceTable[ x[t] == Subscript[a, 1] x[t - 1] + Subscript[a, 2] x[t - 2] + \[ScriptE][t] + Subscript[b, 1] \[ScriptE][t - 1] && x[-1] == Subscript[y, -1] && x[-2] == Subscript[y, -2], x, {t, 0, tmax}];

Compute mean of process values for , given past process values, and given zero values of innovations in the past.

 In:= Xinnov\[ScriptCapitalD] = ProductDistribution[{NormalDistribution[0, \[Sigma]], Length[innovations]}];
 In:= Xepv = Expectation[pv /. \[ScriptE][_?Negative] :> 0, innovations \[Distributed] innov\[ScriptCapitalD]]
 Out= Compare to the values of the process mean function.

 In:= XMean[ARMAProcess[{Subscript[a, 1], Subscript[a, 2]}, {Subscript[b, 1]}, \[Sigma]^2, {Subscript[y, -2], Subscript[y, -1]}][ Range[0, tmax]]] - epv // Expand
 Out= Use Expectation to compute covariance function of process values under the same conditions.

 In:= XShort[covm = Expectation[ KroneckerProduct[#, #] &[(pv /. \[ScriptE][_?Negative] :> 0) - epv], innovations \[Distributed] innov\[ScriptCapitalD]], 5]
 Out//Short= Covariance function for a particular value of process parameters.

 In:= XMatrixForm[ covm /. {Subscript[a, 1] -> 5/6, Subscript[a, 2] -> -1/6, Subscript[b, 1] -> -1/2, \[Sigma] -> 1}]
 Out//MatrixForm= Compare computed covariance matrix to values of CovarianceFunction.

 In:= Xcovm - Table[ CovarianceFunction[ ARMAProcess[{Subscript[a, 1], Subscript[a, 2]}, {Subscript[b, 1]}, \[Sigma]^2, {Subscript[y, -2], Subscript[y, -1]}], s, t], {s, 0, tmax}, {t, 0, tmax}] // Simplify
 Out= Compute mean and covariance of process values assuming a Gaussian joint distribution for past values and past innovations.

 In:= XpastValuesJoint\[ScriptCapitalD] = MultinormalDistribution[{Subscript[\[Mu], 1], Subscript[\[Mu], 2], 0}, {{Subscript[\[ScriptS], 11], Subscript[\[ScriptS], 12], Subscript[\[ScriptS], 13]}, {Subscript[\[ScriptS], 12], Subscript[\[ScriptS], 22], Subscript[\[ScriptS], 23]}, {Subscript[\[ScriptS], 13], Subscript[\[ScriptS], 23], Subscript[\[ScriptS], 33]}}];
 In:= Xpv2 = Join[{Subscript[y, -2], Subscript[y, -1]}, pv];
 In:= Xepv2 = Expectation[ pv2, {innovations \[Distributed] innov\[ScriptCapitalD], {Subscript[y, -2], Subscript[ y, -1], \[ScriptE][-1]} \[Distributed] pastValuesJoint\[ScriptCapitalD]}]
 Out= In:= XShort[covm2 = Expectation[ KroneckerProduct[#, #] &[ pv2 - epv2], {innovations \[Distributed] innov\[ScriptCapitalD], {Subscript[y, -2], Subscript[ y, -1], \[ScriptE][-1]} \[Distributed] pastValuesJoint\[ScriptCapitalD]}], 5]
 Out//Short= Weak stationarity condition implies that the mean values should be equal and the covariance matrix values across subdiagonals should be the same. This determines parameters of the joint distribution of past values.

 In:= X{sol} = Solve[ Join[{Equal @@ epv2}, Table[Equal @@ Diagonal[covm2, k], {k, 0, Length[covm2] - 1}]], {Subscript[\[Mu], 1], Subscript[\[Mu], 2], Subscript[\[ScriptS], 12], Subscript[\[ScriptS], 13], Subscript[\[ScriptS], 23], Subscript[\[ScriptS], 11], Subscript[\[ScriptS], 22], Subscript[\[ScriptS], 33]}] // Simplify
 Out= Compare to the covariance function of weakly stationary ARMA(2,1) process.

 In:= XFirst[covm2 /. sol] - CovarianceFunction[ ARMAProcess[{Subscript[a, 1], Subscript[a, 2]}, {Subscript[b, 1]}, \[Sigma]^2], {tmax + 2}]["Values"] // Simplify
 Out= ## Mathematica

Questions? Comments? Contact a Wolfram expert »