3
$\begingroup$

I'm trying to calculate the covariance of a function which depends upon time.

This is such that I have a series (as a minimal example):

enter image description here

As you'd expect. However, when I try to get a similar output from Mathematica (possibly using KroneckerDelta) I fail and I'm not sure how to correct it:

h >= 0;
Expectation[
  Y[t] * Y[t + h],
  {
    Distributed[Y[t], NormalDistribution[0, Subscript[\[Sigma], \[Epsilon]]]],
    Distributed[Y[t + h], NormalDistribution[0, Subscript[\[Sigma], \[Epsilon] + h]]]
  }
]

Resolves to 0. I've looked through related answers (apologies if I've missed the one that answers this) but they state that this is because Expectation is treating these two variables as independent.

Thus I tried to put them in a Multivariate distribution with:

h >= 0;
Expectation[
  Y[t] * Y[t + h],
  Distributed[
    {Y[t], Y[t + h]},
    MultinormalDistribution[
      0,
      DiagonalMatrix[ConstantArray[Subscript[\[Sigma], \[Epsilon]], 2]]
    ]
  ]
]

But I am clearly not doing this correctly unfortunately and I'm at a loss as to how to proceed. Can anyone advise on how I can get the answer I expect?

$\endgroup$

closed as off-topic by JimB, MarcoB, Coolwater, José Antonio Díaz Navas, b3m2a1 Feb 12 '18 at 7:25

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Your first two equations describe a set of independent random variables. If the covariance is zero between $Y_t$ and $Y_{t+h}$, then (at least with normally distributed random variables) you have independence among all of the random variables. So you don't have "nonzero covariance" as your title states. In this case the expectation is the product of the expectations which is zero. And what is the answer you expect? $\endgroup$ – JimB Jan 11 '18 at 17:46
  • 5
    $\begingroup$ I'm voting to close this question as off-topic because the question is about random variables with non-zero covariances but in the body the OP describes a covariance structure where the random variables have zero covariance. The OP was told about this a month ago and no relevant edits have yet to be made. $\endgroup$ – JimB Feb 10 '18 at 19:28
0
$\begingroup$

This should work:

Σ = DiagonalMatrix[ ConstantArray[σerr^2, {2} ] ];

dist = MultinormalDistribution[ { 0, 0}, Σ ];

Expectation[ y[t] × y[t+h], { y[t], y[t+h] } \[Distributed] dist ]

0

Expectation[ y[t] × y[t + 0], { y[t], y[t+h] } \[Distributed] dist ]

σerr^2

$\endgroup$
  • $\begingroup$ Hi, thanks for your help. Unofrtunately this isn't returning what I'm expecting. The zero answer is true for when $h \neq 0$ but not otherwise. In the opposing case it should resolve to $\sigma^2_{\epsilon}$ $\endgroup$ – Benny292 Dec 12 '17 at 12:45
  • $\begingroup$ @Benny292 As you can see, when $h = 0$ we have $y_t \times y_t$ and that will work out as it should. $\endgroup$ – gwr Dec 12 '17 at 16:07
  • $\begingroup$ Apologies but I may not be making myself clear. I'm looking for an answer that cover the general $h$ such that I should have either a case system or a KroneckerDelta[0,h]. Does that make sense? $\endgroup$ – Benny292 Dec 12 '17 at 16:55
0
$\begingroup$

Your first two equations describe a set of independent normally distributed random variables so the expectation of the product of any two with $h\ne0$ is zero and $\sigma^2_\epsilon$ when $h=0$.

A function to do this could be

expectation[h_] := Boole[h == 0] Subscript[σ, ϵ]^2

There's no need for any of the Mathematica distribution functions.

Or do you really mean a covariance structure different from what you describe?

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.