7
$\begingroup$

If I have calculated the sample mean, variance, skew and kurtosis of a set of data, how would I go about fitting a probability distribution to match these moments (i.e. choosing a probability distribution and optimizing its parameters to fit the sample moments). Are there any packages in R/MATLAB/etc. that are capable of this?

For context, I believe I can calculate these moments for a portfolio's return distribution, but I actually need a whole probability density function for the portfolio's returns in order to perform additional analysis.

$\endgroup$

5 Answers 5

2
$\begingroup$

I asked an almost identical question on the Cross Validated site here. I think my accepted answer, given by Whuber, might be what you are looking for.

$\endgroup$
4
$\begingroup$

You should be able to do this with the fitdistr function in the MASS package. You will certainly be able to hold the mean and variance constant, but I'm less sure about skewness and kurtosis (they would need to be arguments to the density function).

The actuar package may also be useful, as it contains additional density functions.

$\endgroup$
2
$\begingroup$

If you have a formula giving you the moments as a function of the parameters of the distribution, you can use gmm, in the gmm package: there is a detailed example for the Gaussian distribution in the documentation.

(Of course, in this case, you are only solving a system of equations, and could probably do it by hand: the generalized method of moments (GMM) is typically used when there are more moments than parameters.)

$\endgroup$
2
$\begingroup$

Often, we are interested to check if our data is close to normal, then you can use the Jarque-Bera test, where skewness and kurthosis are directly deployed. Look up Matlab implementation.

If you are not constrained to use the moments, you can calculate histogram and use Komogorov-Smirnov test, which can test similarity to any distribution, not necessarily normal. Look up Matlab implementation.

$\endgroup$
1
$\begingroup$

It may never have been done, but it seems to me that the Cornish-Fisher expansion for moments up to 4 could be used to trace a density function from a tabulation of the percentiles of the normal distribution, for instance:

$$ w_{\alpha}\cong z_{\alpha}+\frac{1}{6}\left(z_{\alpha}^{2}-1\right)AS+\frac{1}{24}\left(z_{\alpha}^{3}-3z_{\alpha}\right)EKUR-\frac{1}{36}\left(2z_{\alpha}^{3}-5z_{\alpha}\right)AS^{2} $$ where $w_{\alpha}$ is the revised percentile, $z_{\alpha}$ is the percentile for the standard normal distribution, AS is the skewness coefficient and EKUR is the excess kurtosis coefficient (from a kurtosis coefficient of 3 for a normal distribution).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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