[R] How to determine the pdf of a gamma distribution using the estimated parameters?
Ben Bolker
bbolker at gmail.com
Fri Jul 12 19:45:18 CEST 2013
On 13-07-12 01:38 PM, Kaptue Tchuente, Armel wrote:
> Sorry not to be more precise in my previous message.
> My question is how to use dgamma with the obtained shape and scale
parameters in order to approximate the observed pdf since the
results of dgamma (seq(4,28,4), shape,rate) are very different from
the observed pdf [pdf obs_pdf<-c(0.600, 0.175, 0.100, 0.025, 0.050,
0.025, 0.025)]?
You need to compute the integral of the relevant sections of the
CDF. What I've done here is not exactly the same as your classes
((1-4),(5-8),(9-12),...), you'll need to sort that out (what happens
to values between 4 and 5? If your data are discrete, then the
Gamma distribution isn't a perfect match -- it might be a reasonable
approximation, but you'll have to figure out for yourself how
you want to make the correspondence between your discrete data
and a continuous distribution ... maybe your ranges should be (0.5-4.5),
(4.5-8.5), ... ?)
This looks _reasonably_ close ...
obs_pdf<-c(0.600, 0.175, 0.100, 0.025, 0.050, 0.025, 0.025)
pred_pdf <- diff(pgamma(seq(0,28,4),shape=0.8276,rate=0.1448))
plot(obs_pdf,pred_pdf)
abline(a=0,b=1)
> Armel
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Ben Bolker
> Sent: Friday, July 12, 2013 11:58 AM
> To: r-help at stat.math.ethz.ch
> Subject: Re: [R] How to determine the pdf of a gamma distribution using the estimated parameters?
>
> Kaptue Tchuente, Armel <armel.kaptue <at> sdstate.edu> writes:
>
>>
>
> [snip]
>
>> With th bar histogram (number of occurrences)
>> hist<-c(24,7,4,1,2,1,1) of seven equally spaces classes ]1-4], ]5-8],
>> ]9-12], ]13-16], ]17-20], ]21-24], ]25-28], I obtained shape=0.8276
>> and rate=0.1448.
>>
>> I would like to know how to build the continuous pdf of a this gamma
>> distribution knowing these two estimated parameters such that I will
>> be able to predict the pdf of any positive value.
>
> Are you talking about dgamma(x,shape=0.8276,rate=0.1448),
> where x is the value you are trying to predict for? dgamma gives probability density, pgamma gives cumulative density/distribution function.
>
More information about the R-help
mailing list