1
$\begingroup$

I made a histogram of my data, and the fitting line, but from some reason the fitting line doesn't fit to my graph. How can I make it fit to it?

How can I check if my data distribution is exponential?

I ran this code in R:

 x<-tazpits$time_b_arraival_m 
 summary(x)    
 Min. 0.0000 
 1st Qu. 0.2200
 Median  0.5550
 Mean 0.9802
 3rd Qu. 1.2400
 Max. 6.2500

 h<-hist(x,breaks=104,main="hisogram of time between arrival", 
          ylab = "frenqency of arriving", xlab = "time in min", 
          col = "yellow")
 xfit<-seq(0,6.25,length=104)
 yfit<-dexp(xfit,1/0.9802)
 lines(xfit,yfit)

enter image description here

$\endgroup$
2
$\begingroup$
  1. There are two problem with your histogram;

    • the first is that your bins are far too narrow (you appear to have as many bins as observations, try having no more than 20 for that number of observations

    • the second is that you're comparing counts with density. You need your histogram to be scaled to integrate to 1 as well (use freq=FALSE)

  2. You should not use an ordinary Kolmogorov-Smirnov test while estimating parameters (as you did here). If you want the same form of test statistic, you could use a Lilliefors test for the exponential distribution -- though there are other alternatives.

$\endgroup$
  • $\begingroup$ What do you mean with "You should not use an ordinary Kolmogorov-Smirnov test while estimating parameters"? What parameter is being estimated here? Thank you. $\endgroup$ – stats.and.r Apr 22 at 17:26
  • $\begingroup$ The Kolmogorov-Smirnov is a test for a completely specified distribution, but when OP said it was exponential, they didn't specify which one. You see in the code where the OP computed the sample mean and then used it to draw an exponential density? That was estimating the mean of the exponential. If you use that value in a KS test, it makes the cdf of the resulting values closer to an exponential cdf than a random sample from an exponential would be (whose sample mean would differ from the specified mean) . This has a strong impact on the significance level ... ctd $\endgroup$ – Glen_b Apr 23 at 1:47
  • $\begingroup$ ctd... specifically, you'll reject much less than you ask to when the null is true (and so reduce power when it's false). It's easy to see the effect on significance level by simulation from the null. We need a test that deals with these issues. There are many tests for general exponentiality; I merely mentioned the one that is based on a Kolmogorov-Smirnov (but it may not be the best possible choice) $\endgroup$ – Glen_b Apr 23 at 1:51

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.