Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correlated Generators #39

Merged
merged 13 commits into from
Aug 8, 2022
Merged

Correlated Generators #39

merged 13 commits into from
Aug 8, 2022

Conversation

alecloudenback
Copy link
Member

@alecloudenback alecloudenback commented Aug 6, 2022

Introduce
closes #17

using EconomicScenarioGenerators, Copulas

m = BlackScholesMerton(0.01,0.02,.15,100.)
s = ScenarioGenerator(
                      1,  # timestep
                      30, # projection horizon
                      m,  # model
                  )

ss = [s,s] # these don't have to be the exact same
g = GaussianCopula([1. 0.9; 0.9 1.])
c = Correlated(ss,g)

collect(c)

using Plots
plot(collect(c))

plot_2

cc @kasperrisager

Some disussion/todos:

  • collect(c) returns a vector of vectors:
julia> collect(c)
2-element Vector{Vector{Float64}}:
 [87.58135277304397, 74.84820358945774, 68.56323172218646, 57.30284156605987, 58.01804063220005, 70.50583190735524, 67.62514257297967, 67.75331112863375, 74.65392532963543, 64.16076510394042  …  29.363724347621254, 39.05933584030768, 44.259288501108955, 30.193440520663124, 35.12786141576387, 32.4511890981983, 33.791351345428474, 36.62555404546912, 41.56345911563408, 37.00931733615785]
 [94.43341734287529, 82.88074095422284, 76.91159150462514, 72.64687376383395, 67.09645675465482, 70.74338844031544, 69.82729451232233, 64.10372892726669, 73.7458039859808, 65.07849904945566  …  27.412784359429537, 30.282329238312855, 29.048030126437794, 21.385593116622168, 27.28257459517675, 23.8838298202843, 23.561602356185862, 26.207618041390134, 29.221929707995933, 26.89015829202149]
  • Only implemented for BlackScholesMerton currently, but could be extended to others pretty easily as long as the following are true (I'm not sure):
    • All models ultimately only need one random variate for the diffusion process. If there are multiple needed I'm not sure how that would be handled
    • Currently assumes that the random variate is gaussian - is there a way to pass the copula and use the marginal inverse CDF to get the variate for use in the diffusion process?
      • Maybe don't need to depend explicitly on Copulas given its interface?

@alecloudenback
Copy link
Member Author

@codecov
Copy link

codecov bot commented Aug 7, 2022

Codecov Report

Merging #39 (d35aad1) into main (1d43cb9) will increase coverage by 4.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #39      +/-   ##
==========================================
+ Coverage   90.16%   94.23%   +4.06%     
==========================================
  Files           4        4              
  Lines          61      104      +43     
==========================================
+ Hits           55       98      +43     
  Misses          6        6              
Impacted Files Coverage Δ
src/EconomicScenarioGenerators.jl 96.49% <100.00%> (+4.49%) ⬆️
src/Yields.jl 87.50% <100.00%> (+9.72%) ⬆️
src/equity.jl 75.00% <100.00%> (+3.57%) ⬆️
src/interest.jl 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@alecloudenback alecloudenback marked this pull request as ready for review August 8, 2022 04:19
@alecloudenback alecloudenback merged commit d291bdb into main Aug 8, 2022
@alecloudenback alecloudenback deleted the copulas branch August 8, 2022 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API for correlations of variables
1 participant