Bayesian-lite Simulator

Finally, we have a long desired simulator for Bayesian-lite mode: coefficients from objective Bayes posterior and covariance matrix for innovations fixed. At first we did this only for one asset class: US stocks, and only one factor: volatility. Later, we do this for more asset classes, to complete this program. This is our main goal here.

We transformed the volatility using the Yeo-Johnson transform. We used the simplest model:

 \tilde{V}(t) = \alpha + \beta\tilde{V}(t-1) + W(t)

 Q(t) = a + bV(t) + V(t)Z(t)

where  V(t) = \exp(f(\tilde{V}(t))) and  f(v) is the inverse Yeo-Johnson transform.

We created a new repository. One Python file new-sim.py contains:

  • reading the data file
  • fitting regressions
  • extracting regression parameters
  • running the loop for 10000 simulations
  • analyzing results (text version of the graph)

A separate file bayesOLS.py contains objective Bayes simulation of regression parameters and simulation of noise terms, where we assume the standard error is constant. Finally, the inverse transform is coded in YJX.py.

We were very positively surprised that it takes such a short time. Only 10 seconds on my office computer. But the previous version without reading and fitting the data takes only 2 seconds on my office computer. Maybe we can multiply time by 5?

Update: I found a mistake, since I forgot to add correlation between the two innovation series. We need to: (a) simulate the two innovation series as bivariate Gaussian with mean zero vector and the covariance matrix which matches the empirical covariance matrix; (b) use one-dimensional innovations as an argument in the regression simulation functions.

Update: I used a more rigorous method of runtime count on my personal notebook. Then the old and new simulators generally take 6.5-7.0 seconds to run, both with 100 and 10000 Monte Carlo simulations. But this is strange that reading the data, fitting regressions etc and running these multiple Gaussian random variables seems not to make a difference! Why?

Update: I ran it on my office computer, both take around the same time. I think about 2 seconds. Crazy!

Conclusion: For us this is very good news since we now can proceed with the new simulator.

Published by


Leave a Reply