[R-SIG-Finance] Checking fit of data against student t distribution

Matthew Clegg matthewcleggphd at gmail.com
Tue Feb 17 18:38:44 CET 2009


The Kolmogorov-Smirnov test is a great approach, but
unfortunately it is not always appropriate:

> X <- rt(250, df=5)  # Your data goes here
> ks.test(X, pt, df=5)

If the parameters have been estimated from the data, then
ks.test can give inflated p-values.  With financial data, it is common
to estimate the mean and the scale parameter (and possibly the
degrees of freedom) from the data, so the Kolmogorov-Smirnov test
may not be the best choice.

One possible workaround is to use bootstrapping.  Here is
a paper that describes that approach:

Stute, Winfried, Wenceslao Gonzáles Manteiga, and Manuel Presedo Quindmil,
1992, "Bootstrap based goodness-of-fit tests," Metrika, Vol. 40, No.
1, pp. 243-256

I have found that this can be computationally expensive, but
for your case -- fitting a t-distribution to 250 data points -- it's
certainly feasible.

Another traditional approach is to use the chi-square test of
goodness of fit.  This is described in many statistics textbooks,
for example, DeGroot and Schervish, 3rd ed., pp. 536-541.
Here is some sample R code showing how you might do this:

> library(fGarch)
> X <- rstd(250, mean=0.05, sd=0.10, nu=5)  # Replace X with your data
> theta <- stdFit(X)
> ncells <- 20
> quantiles <- qstd((1:(ncells-1))/ncells, mean=theta$par[1], sd=theta$par[2], nu=theta$par[3])
> quantiles <- c(-Inf, quantiles, Inf)
> obs <- table(cut(X, quantiles))
> exp <- length(X) / ncells
> p.chisq <- 1 - pchisq(sum((obs-exp)^2/exp), df=ncells-1-3)
> p.chisq

Note that the degrees of freedom used in the call to pchisq is
reduced by the number of parameters estimated.  Also, the
number of cells used for the test is somewhat arbitrary, but 20
seems to be a common value.

I'm sure you can easily code this up as an R function, if someone
hasn't done it already.

Perhaps one of the statisticians on the list can offer further guidance.

I hope this helps!

Matthew Clegg

On Tue, Feb 17, 2009 at 10:14 AM, Reena Bansal
<Reena.Bansal at moorecap.com> wrote:
> Hi All -
>
> I want to check how well a given data (sample size = 250) fits Normality
> and Student t-distribution with given degrees of freedom, say 5. For
> normality test I use Jarque Bera. I am trying to find test for checking
> my data against Student-t distribution. Any suggestions?
>
> Thanks,
> Reena
>
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>

-- 
Matt Clegg
matthewcleggphd at gmail.com



More information about the R-SIG-Finance mailing list