6
$\begingroup$

I have some difficulties with understanding the output of the KS test in R. Suppose I want to test whether my data follows a exponential distribution with rate 1/117.5 with a significance level $\alpha = 0.05$. I have the following hypothesis:

$H_0$: The data follow the exponential distribution

$H_a$: The data do not follow the exponential distribution

I have the following code in R:

x <- rexp(10000, rate = 1/120)
ks.test(x, "pexp", rate = 1/117.5)

and get the output:

    One-sample Kolmogorov-Smirnov test

data:  x
D = 0.0132, p-value = 0.06224
alternative hypothesis: two-sided

So, since P > $\alpha$, I can not reject the null? and hence assume my date follows a exponential distribution with rate 1/117.5?

I'm a little lost with the meaning of the P value and the significance level $\alpha$.

$\endgroup$
  • $\begingroup$ (1) When the exponential rate parameter is estimated from the data, that should be taken into account when considering the distribution of the KS test statistic - see here. (2) You seem to have the right idea about p-values & significance levels. $\endgroup$ – Scortchi - Reinstate Monica Mar 20 '15 at 9:57
  • $\begingroup$ (3) The considerations here apply to exponentiality testing too. $\endgroup$ – Scortchi - Reinstate Monica Mar 20 '15 at 13:03
4
$\begingroup$

So, since P > α, I can not reject the null?

That's correct, you wouldn't reject the null with that test. The Kolmogorov-Smirnov can detect scale shifts, but not nearly as efficiently as something specifically designed to pick them up.

and hence assume my date follows a exponential distribution with rate 1/117.5?

Failure to reject the null doesn't mean the null is actually the case. You can't distinguish it from an exponential with mean 117.5 but that doesn't mean it's exponential or that its mean is 117.5. Many other rate parameters would be consistent with the data, and many distributions other than the exponential would, as well.

If you have a strong a priori reason to think it should take the null value and be exponential, it may in some situations make sense to act as if the null were true, but generally speaking it probably isn't. It helps to keep that it mind.

| cite | improve this answer | |
$\endgroup$
-3
$\begingroup$

if you want exponential distribution , I think try to transform exponential to normal, with ln your data

I think you should change your data

  1. ln your data

    ln(data)

  2. run your code with

    ks.test(x, "pnorm",mean=0,sd=1)

| cite | improve this answer | |
$\endgroup$
  • 3
    $\begingroup$ (-1) The log of an exponentially distributed random variable is not normally distributed. $\endgroup$ – Scortchi - Reinstate Monica Mar 20 '15 at 9:53

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.