2
$\begingroup$

This page from Mathematica 10 example: https://www.wolfram.com/mathematica/new-in-10/expanded-time-series-processes/model-the-conditional-value-at-risk-with-an-archpr.html

Has a problem with this command:

VaR = MovingMap[Sqrt[κ + {a, b}.(#^2)] quantile &, applLast, 2]

Returns the error message:

"Tensors {0.165773,0.0892862} and {0.000236628,0.0000288969,0.000123249} have incompatible shapes"

Any ideas what's wrong? Your help is much, much appreciated.

$\endgroup$
  • $\begingroup$ kglr's solution works. Infinite thanks. You just gotta change the DateListPlot to ListLinePlot to see the results. Here's the code: ListLinePlot[{applLast["Values"], VaR}, PlotRange -> All, PlotLegends -> {"returns", "value at risk"}] $\endgroup$ – Kambiz Homayounfar Sep 20 '18 at 7:38
2
$\begingroup$
vaR = MovingMap[Sqrt[κ + {a, b}.(#^2)] quantile &, applLast["States"][[1]], 1]

works without error (version 11.3 - Wolfram Cloud).

The problem with the original code: {a,b} is a two-vector, while MovingMap with window argument 2 produces 3-vectors, hence the error message:

 MovingMap[Mean, {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3],
  Subscript[x, 4], Subscript[x, 5]}, 2]

enter image description here

$\endgroup$
  • $\begingroup$ That MovingMap expression returns a different expression when run in version 10.0 vs 10.3. $\endgroup$ – Jason B. Sep 19 '18 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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