[R] Fitting Distribution to Data

reezwan you reez88 at yahoo.com
Mon Nov 30 23:40:08 CET 2009


Hello everyone:
I tried to fit a Beta distribution on a right-skewed dataset using:

fitdistr(temp,densfun="beta",start=list(shape1=3,shape2=2))


To assess the fit, I proceeded as follows:

Using distribution parameters from the sample resulting from fitdistr() function, I generated 1000 samples as:

t <- rbeta(1000,3.0176976,6.0976797)

qqplot(temp, t)

It seems to be reasonable fit except in the tail.

I tried ks.test as:

ks.test(temp,"pbeta", 3.0176976,6.0976797)

One-sample Kolmogorov-Smirnov test

data:  temp
D = 0.044, p-value < 2.2e-16
alternative hypothesis: two-sided

But, when I tried:
ks.test(t,temp)

	Two-sample Kolmogorov-Smirnov test

data:  t and temp
D = 0.0486, p-value = 0.02729
alternative hypothesis: two-sided 

Would you please comment on my methodology? I suspect something is wrong. ks.test results are confusing. I used sample parameters (resulting from fitdistr()) to simulate data from assumed distribution, and then plotted simulated data against my original data using qqplot...

I will appreciate any suggestions in this regard.

Thanks
Reez




      __________________________________________________________________
[[elided Yahoo spam]]




More information about the R-help mailing list