[R] Goodness of fit for gamma distributions

Dan31415 d.m.mitchell at reading.ac.uk
Tue Jan 27 15:13:29 CET 2009


Thanks for that Remko, but im slightly confused because isnt this testing the
goodness of fit of 2 slightly different gamma distributions, not of how well
a gamma distribution is representing the data.

e.g.

data.vec<-as.vector(data)

(do some mle to find the parameters of a gamma distribution for data.vec)

xrarea<-seq(-2,9,0.05)
yrarea<-dgamma(xrarea,shape=7.9862,rate=2.6621)

so now yrarea is the gamma distribution and i want to compare it with
data.vec to see how well it fits.

regards,
Dann


Remko Duursma-2 wrote:
> 
> Hi Dann,
> 
> there is probably a better way to do this, but this works anyway:
> 
> # your data
> gamdat <- rgamma(10000, shape=1, rate=0.5)
> 
> # comparison to gamma:
> gamsam <- rgamma(10000, shape=1, rate=0.6)
> 
> qqplot(gamsam,gamdat)
> abline(0,1)
> 
> 
> greetings
> Remko
> 
> 
> -------------------------------------------------
> Remko Duursma
> Post-Doctoral Fellow
> 
> Centre for Plant and Food Science
> University of Western Sydney
> Hawkesbury Campus
> Richmond NSW 2753
> 
> Dept of Biological Science
> Macquarie University
> North Ryde NSW 2109
> Australia
> 
> Mobile: +61 (0)422 096908
> 
> 
> 
> On Tue, Jan 27, 2009 at 3:38 AM, Dan31415 <d.m.mitchell at reading.ac.uk>
> wrote:
>>
>> I'm looking for goodness of fit tests for gamma distributions with large
>> data
>> sizes. I have a matrix with around 10,000 data values in it and i have
>> fitted a gamma distribution over a histogram of the data.
>>
>> The problem is testing how well that distribution fits. Chi-squared seems
>> to
>> be used more for discrete distributions and kolmogorov-smirnov seems that
>> large sample sizes make it had to evaluate the D statistic. Also i
>> haven't
>> found a qq plot for gamma, although i think this might be an appropriate
>> test.
>>
>> in summary
>> -is there a gamma goodness of fit test that doesnt depend on the sample
>> size?
>> -is there a way of using qqplot for gamma distributions, if so how would
>> you
>> calculate it from a matrix of data values?
>>
>> regards,
>> Dann
>> --
>> View this message in context:
>> http://www.nabble.com/Goodness-of-fit-for-gamma-distributions-tp21668711p21668711.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/Goodness-of-fit-for-gamma-distributions-tp21668711p21686095.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list