1
$\begingroup$

Given some real-valued empirical data (time series), I could convert it to a histogram to have an (non-parametric) empirical distribution of the data, but histograms are blocky and jagged.

Instead, I would like to identify the best-fitting parametric distribution from the scipy or scipy.stats libraries of distribution functions, so that I can artificially generate a parametric distribution that closely fits the empirical distribution of my real data and is continuous.

If the empirical data are monthly returns of empirical AAPL stock returns, for example, I know that the parametric Johnson-SU distribution resembles, and can mimic, stock return distributions because of its customizable skew. However, the Johnson SU distribution in scipy requires four input parameters to be calibrated. How can I search for the best parameter settings of this parametric distribution from scipy that fits to the empirical distribution of my sample of AAPL returns?

$\endgroup$
5
  • 1
    $\begingroup$ Maximum likelihood estimation and method of moments estimation are common ways of doing that. $\endgroup$ – Richard Hardy Dec 20 '20 at 11:51
  • $\begingroup$ they say maximum likelihood estimation, is superior to the method of moments. and i saw afterwards that scipy has MLE built-in which also makes it more convenient. Matching the Johnson parameters, on the other hand, to the target levels of skewness, kurtosis, etc might involve method of moments though, with some help from known closed-form solutions that were derived to show this particular distribution's moments being functions of its parameters. $\endgroup$ – develarist Dec 20 '20 at 13:19
  • $\begingroup$ I am especially interested in how MLE and method of moments compare in the presence of small-sample size. Furthermore, I still am rebuffed by proponents of parametric fitting and those who support empirical fitting of data, especially when it comes to small-sample size. there doesn't seem to be much consensus $\endgroup$ – develarist Dec 20 '20 at 13:20
  • $\begingroup$ The current answer below applies to finding the best distribution "family" (use the KS test), but as we both agree here, hope you could put MLE up as an official answer for me to mark, plus your insight on MLE applied to the small-sample setting versus empirical modeling $\endgroup$ – develarist Dec 20 '20 at 13:23
  • $\begingroup$ What exactly do you mean by parametric fitting, empirical fitting and empirical modeling? Could you explain the differences between them? $\endgroup$ – Richard Hardy Dec 20 '20 at 14:04
2
$\begingroup$

First of all, if you want to find the best distribution that fits your data you just iteratively fit your data to the longlist of distributions. Scipy supports most of them. After fitting, you can either use KS-test to find which distribution fitted best or you can use fit error to decide. This solution does what you want, also other solutions in that post are very good approaches to your problem.

Also, if you are sure about your distribution's being Johnson-SU distribution, to find the parameters, use Scipy's fit function, which will return you the parameters that best represent your data.

a, b, loc, scale = scipy.stats.johnsonsu.fit(data)
$\endgroup$
7
  • $\begingroup$ What exactly is the algorithm behind how scipy pin-points the best fitting combination of parameters for a specific distribution family? Is it doing a grid search, greedy search? $\endgroup$ – develarist Nov 3 '20 at 11:50
  • 1
    $\begingroup$ It uses MLE. Have a look at this docs.scipy.org/doc/scipy/reference/generated/…. $\endgroup$ – Shahriyar Mammadli Nov 3 '20 at 11:58
  • $\begingroup$ Is KS-test the gold standard (e.g. for non-normal bell-shaped curves), or are there better goodness of fit measures you know of? $\endgroup$ – develarist Nov 3 '20 at 12:46
  • 1
    $\begingroup$ KS-test is used to see whether the sample comes from the "estimated" or "expected" population. Thus, you can also use it for comparing two sets of samples to see whether they come from the same specific distribution. This is totally, different from the estimation of parameters, as I mentioned above, scipy does the estimation of parameters by MLE. However, KS-tests usage in your specific case is for grading or scoring which of the distributions fits your data best. If you are sure, that your distribution is Johnson-SU distribution then forget about KS-test, just fit the distribution using... $\endgroup$ – Shahriyar Mammadli Nov 3 '20 at 16:14
  • 1
    $\begingroup$ scipy, and get your parameters for the distribution. Also, if you think your data follows another distribution, again using scipy fit that specific distribution and obtain the parameters. Again, KS-test is required for you if you are not sure about your distribution, and after fitting all possible distributions you can utilize from KS-test or sum of squared errors to choose the best one. $\endgroup$ – Shahriyar Mammadli Nov 3 '20 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.