tag:blogger.com,1999:blog-5952320191615496730.post264321263031093018..comments2018-04-23T12:02:37.246+01:00Comments on The Beginner Programmer: How to fit a copula model in R [heavily revised]. Part 2: fitting the copulaMichttp://www.blogger.com/profile/18151225177833588981noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-5952320191615496730.post-14915671026767035662018-04-19T00:00:18.370+01:002018-04-19T00:00:18.370+01:00how to estimate the Value at risk of a portfolio c...how to estimate the Value at risk of a portfolio composed of 2 assets using the copula approach and how to do the backtesting ? i need the R codes please Bilel Hamrounihttps://www.blogger.com/profile/02192257074310579275noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-59541138123162070832018-02-16T11:40:28.861+00:002018-02-16T11:40:28.861+00:00Hi, maybe this question on stackexchange can help ...Hi, maybe this question on stackexchange can help you, it seems to address your question: https://stats.stackexchange.com/questions/90283/how-to-find-conditional-probability-pxxy-y-using-copulasMichttps://www.blogger.com/profile/18151225177833588981noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-30270229236505811302018-02-15T01:52:16.786+00:002018-02-15T01:52:16.786+00:00Great two-piece article. I have a question though....Great two-piece article. I have a question though.<br />Based on a given copula and known marginals.. if I wanted to know what is the probability of y for a given x ? Or what is the ratio of the copula probabilty for given values of x and y compared to the independent case. The independent case would just be a multiplication of the respective marginal densities for x and y. Is there a command I could use in the Copula or VineCopula package? <br />Thanks for your help!Unknownhttps://www.blogger.com/profile/01736867206343214960noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-88045476667689526242017-05-21T20:59:34.150+01:002017-05-21T20:59:34.150+01:00Hi Ola, it seems that the problem is that in your ...Hi Ola, it seems that the problem is that in your example you're passing to the copula::mvdc function an object that is not of class "parCopula". The "mardia" argument is not a copula from the copula package but (probably) a numeric vector. More generally, since the "mardia" object seems to have been generated using the function copBasic::asCOP, I think that the packages copBasic and copula may not be compatible with each other. This means that if you build the Mardia copula with the copBasic package functions, it probably won't be accepted as an argument in most of the functions in the copula (and probably vinecopula too) package.<br /><br />My suggestion is to clearly define what your goal and steps are, then look for a suitable R package and stick to it. If you have specific questions on your project, you can try to ask on CrossValidated (https://stats.stackexchange.com/). People there are usually very competent in their subjects and nice, although I must say there's not that much on copulas there either.<br /><br />As a last suggestion, if you are doing this for work or study, I suggest you to get in contact with some good university professor/PhD that might be willing to help with the project (Masters student in stats might be interested in writing a thesis on an R implementation of the mardia copula and related functions/tests/applications). <br /><br />I wish you all the best.<br />MicMichttps://www.blogger.com/profile/18151225177833588981noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-45084741174197382842017-05-19T22:26:08.067+01:002017-05-19T22:26:08.067+01:00Hi Mic, thank you for your quick response. That...Hi Mic, thank you for your quick response. That's great that I have possibility to speak with you! Yes, you're right, I read documentation for "copula" and "VineCopula" many times and there is no mention about Mardia. I've tried to put formula for Mardia copula and then built bivariate distirbution with specified marginals in the fallowing way:<br />> df<-read.table("R_popr.txt", header = TRUE)<br />> xy<-df[,c("x","y")]<br />> m<-pobs(xy$x)<br />> mm<-pobs(xy$y)<br />fun<-function(u,v) 0.1*u*v+0.4*max(0,u+v-1)+0.5*min(u,v)<br />mardia<-asCOP(m,mm,fun)<br />mycdf<-mvdc(mardia, margins = c("exp","exp"), paramMargins = list(list(rate=2),list(rate=2))))<br /><br />but I got error:<br />Error in validObject(.Object) : <br /> invalid class “mvdc” object: invalid object for slot "copula" in class "mvdc": got class "numeric", should be or extend class "parCopula"<br />As we see, the two datasets have a similar structure. This is evidence that the proposed model is appropriate.<br /><br /><br />Could you please advise on above?<br /><br />Also, I tried to compare empirical copula with the theoretical one, but I encouner the problem. It is easy to use cdfcomp when argument ft is a list of "fitdist" objects - so for example in case of fitting copula without specified marginals, but it is no possible to compare distributions of object mvdc using cdfcomp. Do you know how the comparison of pdf's can be done for mvdc object? The same problem is with gofCopula.<br /><br />Sorry that I have so many questions to you :)<br /><br />Thank you,<br />OlaAleksandra Piórkowskahttps://www.blogger.com/profile/08619733351123134181noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-20548293067869236732017-05-15T15:46:36.106+01:002017-05-15T15:46:36.106+01:00Hi Ola! Glad to know you found it useful! As far a...Hi Ola! Glad to know you found it useful! As far as I know the best copula packages in R should be "copula" and "VineCopula". Both packages feature Archimedean copulas. In the documentation, however, there seems to be no mention about Mardia's. Maybe you can ask the developers if they plan to add that particular copula.Michttps://www.blogger.com/profile/18151225177833588981noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-8716602237236726562017-05-14T21:52:22.450+01:002017-05-14T21:52:22.450+01:00Hi Mic! It was really useful for me. Thanks for th...Hi Mic! It was really useful for me. Thanks for that! <br />I've started working with R 2 weeks ago and I am consider if there is Mardia copula also in some package?<br /><br />Thanks!<br />OlaAleksandra Piórkowskahttps://www.blogger.com/profile/08619733351123134181noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-72006116755644690532017-04-21T12:59:25.363+01:002017-04-21T12:59:25.363+01:00Hi Maarten! Thanks!Indeed they are quite challengi...Hi Maarten! Thanks!Indeed they are quite challenging! I'm a bit rusty when it comes to VaR, however, I believe that having the pdf, the cdf and being able to simulate observations should be enough to start. Having said this, you need to make some assumption about the distribution of the returns/indeces/phoenomena that you are trying to model, choose the copula, fit it, then get the multivariate distribution that in my code I called "my_dist". Once you're there, you can get the density using dMvdc, the cdf using pMvdc and simulate observations using rmvdc (for instance for a Monte Carlo VaR). Michttps://www.blogger.com/profile/18151225177833588981noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-21159344105357914532017-04-20T18:25:27.549+01:002017-04-20T18:25:27.549+01:00Hi Mic! Nice post! I still have a question though....Hi Mic! Nice post! I still have a question though..I'm also currently working on a project where I have to calculate VaR of different market indices for different periods after fitting several copulas. However, copulas have proven to be quite a challenge for an average master student. My code returns the same VaR for all the periods..so clearly I'm missing/overlooking something..can you tell me where (in your explanation) I should apply VaR? <br />Thanks!Maarten Vanzieleghemhttps://www.blogger.com/profile/08221048349567688861noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-36113949260210715432017-02-25T20:13:39.978+00:002017-02-25T20:13:39.978+00:00Thank you for reading!Thank you for reading!Michttps://www.blogger.com/profile/18151225177833588981noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-42224407397702342492017-02-22T17:47:09.713+00:002017-02-22T17:47:09.713+00:00Thank you very much.
I was looking for a beginner...Thank you very much. <br />I was looking for a beginner level data and example and I found that!!<br />Thanks again!javadhttps://www.blogger.com/profile/17838526293472461088noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-36491829110752948632017-01-25T11:03:29.785+00:002017-01-25T11:03:29.785+00:00Thanks Mic, keep coding!Thanks Mic, keep coding!Martzikos Nikolashttps://www.blogger.com/profile/04858172561260886021noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-71836835066562855522017-01-25T10:24:58.198+00:002017-01-25T10:24:58.198+00:00Hi, thanks for your comment! I guess it depends on...Hi, thanks for your comment! I guess it depends on what you'd like to do, the idea behind the correlation checks in the post is to show that the structure of the data is preserved through the copula.Michttps://www.blogger.com/profile/18151225177833588981noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-2938270234901190682017-01-23T09:53:52.992+00:002017-01-23T09:53:52.992+00:00Mic you have done nice work here, congrats!
I have...Mic you have done nice work here, congrats!<br />I have a question regarding copulas,<br />When we search for a type of correlation between two variables and we have almost fitted a BiCopula like you, it is necessary to continue with building of distribution and after search for " cor(mydata, method = "kendall") " ? Or after fitting of copula it is right to search for correlation? Martzikos Nikolashttps://www.blogger.com/profile/04858172561260886021noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-52806947315037670792016-12-15T17:47:55.107+00:002016-12-15T17:47:55.107+00:00Hi, at the moment I'm working on two R-related...Hi, at the moment I'm working on two R-related projects, I'm afraid I do not really have any spare time. However, if you need to hire an R developer to build a model for you, I should be free after march 2017. Please use the contact form in the "contact" page. Rates will vary upon the project required. If that is not the case, or if you need just a quick help, I suggest you to ask questions on Crossvalidated at https://stats.stackexchange.com/ where there are expert and polite people ready to answer your questions in depth.Michttps://www.blogger.com/profile/18151225177833588981noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-17269819382251800262016-12-14T15:38:05.303+00:002016-12-14T15:38:05.303+00:00Hi,
I'm trying to apply it for my own data (e....Hi,<br />I'm trying to apply it for my own data (e.g. discharge vrs. latent heat flux, ....). Using "Vinecopula" it was selected "234 = rotated Tawn type 2 copula (270 degrees)" . But, for fitting with the selected copula, it gives error...! <br />It would be great, if you have some time to have a look at my data. This is my email: "mohsen.soltani@kit.edu". please email me, and then I will send you the data + related explanation.<br />Thanks.<br />Climatologyhttps://www.blogger.com/profile/05636252784557804790noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-29531673780291432902016-12-13T17:33:59.902+00:002016-12-13T17:33:59.902+00:00Thanks for reading!Thanks for reading!Michttps://www.blogger.com/profile/18151225177833588981noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-23460279720881259042016-12-13T14:21:40.685+00:002016-12-13T14:21:40.685+00:00thank you! it was very helpful.thank you! it was very helpful.Climatologyhttps://www.blogger.com/profile/05636252784557804790noreply@blogger.comtag:blogger.com,1999:blog-5952320191615496730.post-24889396503748266472016-12-13T12:26:50.547+00:002016-12-13T12:26:50.547+00:00This is my first time i visit here. I found so man...This is my first time i visit here. I found so many entertaining stuff in your blog. Keep up the good work.<br /><a href="https://iconprocon.com/product-category/flow-meters/" rel="nofollow">Plastic Flow Meter</a>Deba Sheeshhttps://www.blogger.com/profile/10584770835348004943noreply@blogger.com