2
$\begingroup$

I like to calculate the mean and standard deviation of a price series, using the Kalman filter. I am somehow stuck with the deviation, or have some problem in understanding, which my research could not solve.

mean(t) =  mean(t-1) + K(t) * ( price(t) - mean(t-1) )

with Kalman gain K(t) = R(t-1) / (R(t-1) + Ve), state variance R(t) = (1 - K(t)) * R(t-1) and measurement error Ve practically as some pre-defined parameter, similarly to the lookback period in a simple mean.

I've read a few times that the variance R should give kind of variance (and thus standard deviation) of the price series. But with a K < 1, R with every iteration just gets smaller and is no way the deviation of the price series. This only would make sense for a constant value to measure, where with every measurement iteration we get more certainty. Is my concept of the Kalman filter too simplistic? Can anybody give me a hint please.

$\endgroup$
  • $\begingroup$ @ Mike if you upload data I will take a look $\endgroup$ – rrg Dec 28 '16 at 12:24
2
$\begingroup$

Rt in your notation is "filtered" variance R(t|t). The prediction of variance R(t+1|t) adds another term which is not guaranteed to be decreasing overtime.

I think another critical assumption is Ve in your equation. How do you define Ve? For price series Ve as a proxy for volatility makes sense to be time-varying, and probably exhibit some auto-correlation.

$\endgroup$
2
$\begingroup$

I would suggest check out the Wikipedia page first and use more stylized notations.

In your update equation mean(t) = mean(t-1) + K(t) * ( price(t) - mean(t-1) ) you are basically saying that your state process is mean(t) and price(t) is a measurement of mean(t). This doesn't sound legit

On the other hand, you could have a mean reverting process $$\text{price}(t) = \text{price}(t-1) + \alpha (\text{mean}(t-1) - \text{price}(t-1))$$

Although it looks similar, it's fundamentally different from the update equation in Kalman filter.

Then the state vector for this process could be $X_t = \begin{bmatrix}\text{price}(t) \\ \text{mean}(t) \end{bmatrix}$ and state transition equation could be $$\begin{bmatrix}\text{price}(t) \\ \text{mean}(t) \end{bmatrix} = \begin{bmatrix} 1-\alpha & \alpha \\ 0 & 1 \end{bmatrix} \begin{bmatrix}\text{price}(t) \\ \text{mean}(t) \end{bmatrix} + \begin{bmatrix}\epsilon_1(t) \\ \epsilon_2(t) \end{bmatrix}$$

Denote $F_t = \begin{bmatrix} 1-\alpha & \alpha \\ 0 & 1 \end{bmatrix}$ then the above equation is simply $$X_t = F_tX_t + \epsilon_t$$

The measurement equation could be

$$Z_t = H_tX_t + \nu_t$$

where $Z_t$ is the acutal price series and $H_t = \begin{bmatrix} 1 & 0 \end{bmatrix}$

The you can use the Kalman filter two-step recursion to estimate the mean(t)

$\endgroup$
0
$\begingroup$

You need to run over the times series once for initial variance, and a second time with updated Kalman params for the state variance (your Rt). This is two step recursion

$\endgroup$

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.