danielemarinazzo / KernelGrangerCausality

Code to evaluate nonlinear Granger causality using the kernel trick to reduce complexity
BSD 3-Clause "New" or "Revised" License
34 stars 14 forks source link

Unable to adjust the parameter "par" of the kernel function in the script testKGC_KCL.m #1

Closed zh-Wan-OutsideMap closed 1 year ago

zh-Wan-OutsideMap commented 1 year ago

Hello! When I run the script testKGC_KCL.m, it seems that the parameter "par" of the kernel function can only be set to 1 and 2, and any other value (e.g. 3) will give the program an error. So I would like to ask how to solve this problem.

danielemarinazzo commented 1 year ago

It's unsolvable. The data is not suited for higher parameters. With a more treatable feature space (longer time series, etc), then this could work.

On Fri, 24 Mar 2023 at 15:16, zh-Wan-OutsideMap @.***> wrote:

Hello! When I run the script testKGC_KCL.m, it seems that the parameter "par" of the kernel function can only be set to 1 and 2, and any other value (e.g. 3) will give the program an error. So I would like to ask how to solve this problem.

— Reply to this email directly, view it on GitHub https://github.com/danielemarinazzo/KernelGrangerCausality/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIQU7UVRDFDXETU5B7UJA3W5WUCPANCNFSM6AAAAAAWGT4H3U . You are receiving this because you are subscribed to this thread.Message ID: @.***>

zh-Wan-OutsideMap commented 1 year ago

Thank you so much for your reply! I would like to ask, in your code, the polynomial kernel function order can only be set to 1 or 2, that can only detect time series with quadratic relations, this code is not universal for general time series. How can I solve this? I am keen to implement a Granger causality test based on the Kernel method. Thank you!

------------------ 原始邮件 ------------------ 发件人: "danielemarinazzo/KernelGrangerCausality" @.>; 发送时间: 2023年3月24日(星期五) 晚上10:24 @.>; @.**@.>; 主题: Re: [danielemarinazzo/KernelGrangerCausality] Unable to adjust the parameter "par" of the kernel function in the script testKGC_KCL.m (Issue #1)

It's unsolvable. The data is not suited for higher parameters. With a more treatable feature space (longer time series, etc), then this could work.

On Fri, 24 Mar 2023 at 15:16, zh-Wan-OutsideMap @.***> wrote:

> Hello! When I run the script testKGC_KCL.m, it seems that the parameter > "par" of the kernel function can only be set to 1 and 2, and any other > value (e.g. 3) will give the program an error. So I would like to ask how > to solve this problem. > > — > Reply to this email directly, view it on GitHub > <https://github.com/danielemarinazzo/KernelGrangerCausality/issues/1&gt;, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/ABIQU7UVRDFDXETU5B7UJA3W5WUCPANCNFSM6AAAAAAWGT4H3U&gt; > . > You are receiving this because you are subscribed to this thread.Message > ID: @.***> >

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

danielemarinazzo commented 1 year ago

Thanks for spotting this, there was a missing assignment to a variable with higher number of features. Now it works with a higher polynomial order. This said, there's no universal setting, and for very short/noisy time series, or high model order, eventually you won't have enough features.

zh-Wan-OutsideMap commented 1 year ago

Thank you very much for your reply and sorry to bother you again. Your updated code can now set the parameter 'par' to 4, but setting it to 5 or greater causes the program to report an error. My understanding is that a polynomial kernel function of any order 'par' for any length of time series should be able to calculate the causality index, it is just that the accuracy of the causality index is related to the length of the time series and the 'par' set. I'm confused as to why the program would report an error if I set a larger 'par'. Maybe because I didn't understand your code in depth. Looking forward to your reply, thanks!

------------------ 原始邮件 ------------------ 发件人: "danielemarinazzo/KernelGrangerCausality" @.>; 发送时间: 2023年3月24日(星期五) 晚上11:33 @.>; @.**@.>; 主题: Re: [danielemarinazzo/KernelGrangerCausality] Unable to adjust the parameter "par" of the kernel function in the script testKGC_KCL.m (Issue #1)

Thanks for spotting this, there was a missing assignment to a variable with higher number of features. Now it works with a higher polynomial order. This said, there's no universal setting, and for very short/noisy time series, or high model order, eventually you won't have enough features.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

danielemarinazzo commented 1 year ago

You should specify which error you get. Also, it's normal to get an error when the space of features gets larger. KGC reduces the curse of dimensionality but does not work for any possible complexity. You can also try the gaussian kernel, but again, don't expect it to work for an arbitrary set of parameters for any dataset.

On Sat, 25 Mar 2023, 15:24 zh-Wan-OutsideMap, @.***> wrote:

Thank you very much for your reply and sorry to bother you again. Your updated code can now set the parameter 'par' to 4, but setting it to 5 or greater causes the program to report an error. My understanding is that a polynomial kernel function of any order 'par' for any length of time series should be able to calculate the causality index, it is just that the accuracy of the causality index is related to the length of the time series and the 'par' set. I'm confused as to why the program would report an error if I set a larger 'par'. Maybe because I didn't understand your code in depth. Looking forward to your reply, thanks!

------------------ 原始邮件 ------------------ 发件人: "danielemarinazzo/KernelGrangerCausality" @.>; 发送时间: 2023年3月24日(星期五) 晚上11:33 @.>; @.**@.>; 主题: Re: [danielemarinazzo/KernelGrangerCausality] Unable to adjust the parameter "par" of the kernel function in the script testKGC_KCL.m (Issue #1)

Thanks for spotting this, there was a missing assignment to a variable with higher number of features. Now it works with a higher polynomial order. This said, there's no universal setting, and for very short/noisy time series, or high model order, eventually you won't have enough features.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/danielemarinazzo/KernelGrangerCausality/issues/1#issuecomment-1483837019, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIQU7UDYWP2QKXLY6VOGHDW5353VANCNFSM6AAAAAAWGT4H3U . You are receiving this because you modified the open/close state.Message ID: @.*** com>

zh-Wan-OutsideMap commented 1 year ago

Thank you so much for your awesome work and advice, it's really helpful!

------------------ 原始邮件 ------------------ 发件人: "danielemarinazzo/KernelGrangerCausality" @.>; 发送时间: 2023年3月26日(星期天) 下午3:29 @.>; @.**@.>; 主题: Re: [danielemarinazzo/KernelGrangerCausality] Unable to adjust the parameter "par" of the kernel function in the script testKGC_KCL.m (Issue #1)

You should specify which error you get. Also, it's normal to get an error when the space of features gets larger. KGC reduces the curse of dimensionality but does not work for any possible complexity. You can also try the gaussian kernel, but again, don't expect it to work for an arbitrary set of parameters for any dataset.

On Sat, 25 Mar 2023, 15:24 zh-Wan-OutsideMap, @.***> wrote:

> Thank you very much for your reply and sorry to bother you again. Your > updated code can now set the parameter 'par' to 4, but setting it to 5 or > greater causes the program to report an error. My understanding is that a > polynomial kernel function of any order 'par' for any length of time series > should be able to calculate the causality index, it is just that the > accuracy of the causality index is related to the length of the time series > and the 'par' set. I'm confused as to why the program would report an error > if I set a larger 'par'. Maybe because I didn't understand your code in > depth. Looking forward to your reply, thanks! > > > > > > > ------------------&nbsp;原始邮件&nbsp;------------------ > 发件人: "danielemarinazzo/KernelGrangerCausality" @.&gt;; > 发送时间:&nbsp;2023年3月24日(星期五) 晚上11:33 > @.&gt;; > @.**@.&gt;; > 主题:&nbsp;Re: [danielemarinazzo/KernelGrangerCausality] Unable to adjust > the parameter "par" of the kernel function in the script testKGC_KCL.m > (Issue #1) > > > > > > > Thanks for spotting this, there was a missing assignment to a variable > with higher number of features. Now it works with a higher polynomial > order. This said, there's no universal setting, and for very short/noisy > time series, or high model order, eventually you won't have enough > features. > > — > Reply to this email directly, view it on GitHub, or unsubscribe. > You are receiving this because you authored the thread.Message ID: > @.&gt; > > — > Reply to this email directly, view it on GitHub > <https://github.com/danielemarinazzo/KernelGrangerCausality/issues/1#issuecomment-1483837019&gt;, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/ABIQU7UDYWP2QKXLY6VOGHDW5353VANCNFSM6AAAAAAWGT4H3U&gt; > . > You are receiving this because you modified the open/close state.Message > ID: @. > com> >

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>