Pages

Saturday 14 February 2015

CopulaClass a Python class for using copulas: a fitting example

As I have already said in my previous post Copulalib is really user-friendly, it is difficult to write something easier, however I thought I might give it a try.

This class is built around Copulalib and since it is to be used with 2-dimensional copulas, it implements plots for data visualization and some other functions such as:
-showAvailableCopulas() a method to show visually what copulas are included in the package
-generateCopula() a method to generate the copula
-printCorrelation() this method prints out Spearman’s rho, Kendall’s tau and the fitted parameter
-getSimulatedData() this method retrieves your simulated data from the copula assuming your original data is normally distributed. It would be nice to implement some tool which could figure out the most likely distribution of your data and then use it to get the simulated observations. Perhaps in the future I’ll do it.

Furthermore, the class does not mind if you feed in python lists of numpy arrays as it turns x and y in numpy arrays. Be careful however that it does not check if your lists/arrays are of the same length.

Anyway, as for the result of the testing script below, the fitting of the Frank copula to the data seems to have been successful, our simulated data seems to fit the real quite nicely:

frank_copula_fitted

Originally our data was (very) approximately normally distributed, with some sort of positive correlation as you can clearly see from the plots below

data

Here below you can see 1000 simulated pseudo-observations from the Frank copula

pseudo_observations

Below you can find the code I used to generate this simple model:

And here are the correlation details

9 comments:

  1. Enroll in this cloud computing course and ace all Cloud Certification examinations.Transform yourself into a consummate Cloud Solutions Architect.
    360DigiTMG is providing with certification course at Hyderabad.

    ReplyDelete
  2. I feel very grateful that I read this. It is very helpful and very informative and I really learned a lot from it.

    Data Science Certification in Bangalore

    ReplyDelete
  3. This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post!
    Best Data Science Courses in Hyderabad

    ReplyDelete
  4. This post is extremely easy to peruse and acknowledge without forgetting about any subtleties. Incredible work!
    data scientist hyderabad

    ReplyDelete
  5. "Thank you very much for your information.
    From,
    "data science courses

    ReplyDelete
  6. If you're interested in getting a job in Python, look at the advanced Python training offered at Hyderabad from AI Patasala. Python Training in Hyderabad by trained experts at AI Patasala training center is the best option.
    Best Python Courses

    ReplyDelete
  7. May God bless you with all of the wonderful desires of your heart and bless you to keep the many blessings that you already have. Best Birthday Wishes For Girlfriend

    ReplyDelete