Closed judydickey closed 1 year ago
Hi @judydickey, nothing wrong on my side but this may be caused by the keyword argument "type" which is also the name of a built-in function. I updated the code and changed the keyword argument to "plot_type".
Problem should be fixed :)
Be sure to upgrade to the last version.
!pip install --upgrade pycop
Let me know if this is fixed.
Thanks
Thank you so much for the quick response! Python is my primary coding language, but I am working on a project that really needs copulas, and was having to use R instead. I was thrilled to see your package appear! I hope you continue to expand it, perhaps to computing and plotting return periods?
Judy
On Sun, Nov 20, 2022 at 12:58 PM Maxime Nicolas @.***> wrote:
Hi @judydickey, nothing wrong on my side but this may be caused by the keyword argument "type" which is also the name of a built-in function. I updated the code and changed the keyword argument to "plot_type". Problem should be fixed :) Be ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Hi @judydickey https://urldefense.com/v3/__https://github.com/judydickey__;!!KwNVnqRv!ECkkERjnVRYRLStYjA_3gVHmEwlQqAbkEQ-COCE0rGUaf-vME6z3m8w45l_JxyvZcf-2dQW85sim78sbiSY_6FUE-s8$, nothing wrong on my side but this may be caused by the keyword argument "type" which is also the name of a built-in function. I updated the code and changed the keyword argument to "plot_type".
Problem should be fixed :)
Be sure to upgrade to the last version. !pip install --upgrade pycop Let me know if this is fixed.
Thanks
— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/maximenc/pycop/issues/3*issuecomment-1321214302__;Iw!!KwNVnqRv!ECkkERjnVRYRLStYjA_3gVHmEwlQqAbkEQ-COCE0rGUaf-vME6z3m8w45l_JxyvZcf-2dQW85sim78sbiSY_Mw4_dKw$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/APFZS7FLFRXCBCCHSPCB4SDWJJYG7ANCNFSM6AAAAAASE6CMMM__;!!KwNVnqRv!ECkkERjnVRYRLStYjA_3gVHmEwlQqAbkEQ-COCE0rGUaf-vME6z3m8w45l_JxyvZcf-2dQW85sim78sbiSY_fR_P9VE$ . You are receiving this because you were mentioned.Message ID: @.***>
Judy Dickey | Graduate Research Assistant Department of Atmospheric Sciences | Texas A&M University 3150 TAMU | College Station, TX 77843-0000 @.***
So I ran this real quick with my data, and it works with the gumbel copula, but not with an empirical copula: [image: image.png] [image: image.png]
I really need to be able to use my own data - have you created any additional documentation that explains how to do this?
Judy
On Sun, Nov 20, 2022 at 12:58 PM Maxime Nicolas @.***> wrote:
Hi @judydickey, nothing wrong on my side but this may be caused by the keyword argument "type" which is also the name of a built-in function. I updated the code and changed the keyword argument to "plot_type". Problem should be fixed :) Be ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Hi @judydickey https://urldefense.com/v3/__https://github.com/judydickey__;!!KwNVnqRv!ECkkERjnVRYRLStYjA_3gVHmEwlQqAbkEQ-COCE0rGUaf-vME6z3m8w45l_JxyvZcf-2dQW85sim78sbiSY_6FUE-s8$, nothing wrong on my side but this may be caused by the keyword argument "type" which is also the name of a built-in function. I updated the code and changed the keyword argument to "plot_type".
Problem should be fixed :)
Be sure to upgrade to the last version. !pip install --upgrade pycop Let me know if this is fixed.
Thanks
— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/maximenc/pycop/issues/3*issuecomment-1321214302__;Iw!!KwNVnqRv!ECkkERjnVRYRLStYjA_3gVHmEwlQqAbkEQ-COCE0rGUaf-vME6z3m8w45l_JxyvZcf-2dQW85sim78sbiSY_Mw4_dKw$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/APFZS7FLFRXCBCCHSPCB4SDWJJYG7ANCNFSM6AAAAAASE6CMMM__;!!KwNVnqRv!ECkkERjnVRYRLStYjA_3gVHmEwlQqAbkEQ-COCE0rGUaf-vME6z3m8w45l_JxyvZcf-2dQW85sim78sbiSY_fR_P9VE$ . You are receiving this because you were mentioned.Message ID: @.***>
Judy Dickey | Graduate Research Assistant Department of Atmospheric Sciences | Texas A&M University 3150 TAMU | College Station, TX 77843-0000 @.***
Hi @judydickey, you're welcome, thanks for your comments :)
Right now plotting the empirical copula is a bit experimental but still manageable.
Following this example:
import pandas as pd
import numpy as np
df = pd.read_csv("https://raw.githubusercontent.com/maximenc/pycop/master/data/msci.csv")
df.index = pd.to_datetime(df["Date"], format="%m/%d/%Y")
df = df.drop(["Date"], axis=1)
for col in df.columns.values:
df[col] = np.log(df[col]) - np.log(df[col].shift(1))
df = df.dropna()
You can access the 3d plot in the following manner:
from pycop import empirical
data = df[["US","HongKong"]]
cop = empirical(data)
n_split = 50 # The number of splits used to compute the grid
cop.plot_pdf(n_split)
And the contour plot:
from pycop import utils
utils.empiricalplot(df[["US","HongKong","Japan"]].T.values)
Let me know if this is working for you.
Thanks again! It looks like this would work, but I may have an issue in my data:
[image: image.png] My x values are steadily increasing, but the y values are not: [image: image.png]
I'll see what I can do to make the input a little friendlier. :)
Judy
On Mon, Nov 21, 2022 at 10:26 AM Maxime Nicolas @.***> wrote:
Hi @judydickey, you're welcome, thanks for your comments :) Right now plotting the empirical copula is a bit experimental but still manageable. Following this example: import pandas as pd import numpy as np df = pd. read_csv("https: //raw. githubusercontent. com/maximenc/pycop/master/data/msci. csv") ZjQcmQRYFpfptBannerStart This Message Is From an External Sender This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Hi @judydickey https://urldefense.com/v3/__https://github.com/judydickey__;!!KwNVnqRv!CfnFkxkO-Zcy1rMcXqgXotEgCAnIVnk-_wz8jlSVA1fBjBbfvdfSxw2OJa377p63u7bDGOIB2ysF3YtL2EbCW0nq4k8$, you're welcome, thanks for your comments :)
Right now plotting the empirical copula is a bit experimental but still manageable.
Following this example:
import pandas as pd import numpy as np df = pd.read_csv(" https://raw.githubusercontent.com/maximenc/pycop/master/data/msci.csv") df.index = pd.to_datetime(df["Date"], format="%m/%d/%Y") df = df.drop(["Date"], axis=1)
for col in df.columns.values: df[col] = np.log(df[col]) - np.log(df[col].shift(1))
df = df.dropna()
You can access the 3d plot in the following manner:
from pycop import empirical
data = df[["US","HongKong"]]
cop = empirical(data)
n_split = 50 # The number of splits used to compute the grid cop.plot_pdf(n_split)
And the contour plot:
from pycop import utils utils.empiricalplot(df[["US","HongKong","Japan"]].T.values)
Let me know if this is working for you.
— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/maximenc/pycop/issues/3*issuecomment-1322329711__;Iw!!KwNVnqRv!CfnFkxkO-Zcy1rMcXqgXotEgCAnIVnk-_wz8jlSVA1fBjBbfvdfSxw2OJa377p63u7bDGOIB2ysF3YtL2EbCMfPNWSE$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/APFZS7EMWG76SOKMLRZXNLLWJOPEXANCNFSM6AAAAAASE6CMMM__;!!KwNVnqRv!CfnFkxkO-Zcy1rMcXqgXotEgCAnIVnk-_wz8jlSVA1fBjBbfvdfSxw2OJa377p63u7bDGOIB2ysF3YtL2EbCDRXq3fw$ . You are receiving this because you were mentioned.Message ID: @.***>
Judy Dickey | Graduate Research Assistant Department of Atmospheric Sciences | Texas A&M University 3150 TAMU | College Station, TX 77843-0000 @.***
I would suggest limiting extreme values with a winsorization:
df.column.clip(df.column.quantile(0.01), df.column.quantile(0.99))
And maybe a normalization of your data.
Following your example notebooks and trying out the plot function:
plot the contour
cop.plot_cdf([2], type="contour", Nsplit=100 ) cop.plot_pdf([2], type="contour", Nsplit=100, )
getting Type Error with any plot type I try ('contour', '3d'):
TypeError Traceback (most recent call last)