Re: [R] Goodness of fit for gamma distributions

2009-01-29 Thread Dan31415

Ah yes, that does produce a nice plot. Can i just ask what exactly it is
showing. It seems to me to be a sort of Q-Q plot but with a different set of
axes. Is this correct, if so do the same interpretation rules apply for this
plot, i.e. departures from either end of the curve show poor fitting of the
extreme data.

thanks for your help Remko, its been very helpful.

Dann



Remko Duursma-2 wrote:
 
 It sounds like you just want to graph it though. For gammas, it's nice
 to graph the log of the density, because
 the tail is so thin and long, so you don't see much otherwise:
 
 mydata - rgamma(1, shape=1.1, rate=2.5)
 
 # now suppose you fit a gamma distribution, and get these estimated
 parameters:
 shapeest - 1.101
 rateest - 2.49
 
 h - hist(mydata, breaks=50, plot=FALSE)
 plot(h$mids, log(h$density))
 curve(log(dgamma(x, shape=shapeest, rate=rateest)), add=TRUE)
 
 
 #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 Wed, Jan 28, 2009 at 1:13 AM, Dan31415 d.m.mitch...@reading.ac.uk
 wrote:

 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(1, shape=1, rate=0.5)

 # comparison to gamma:
 gamsam - rgamma(1, 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.mitch...@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@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@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.

 __
 R-help@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@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-tp21668711p21725468.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https

Re: [R] Goodness of fit for gamma distributions

2009-01-27 Thread Dan31415

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(1, shape=1, rate=0.5)
 
 # comparison to gamma:
 gamsam - rgamma(1, 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.mitch...@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@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@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.

__
R-help@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] Goodness of fit for gamma distributions

2009-01-26 Thread Dan31415

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@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.