[R] three par. fitting with fitdistr
Martin Maechler
maechler at stat.math.ethz.ch
Tue Jul 12 18:13:33 CEST 2005
>>>>> "Carsten" == Carsten Steinhoff <carsten.steinhoff at stud.uni-goettingen.de>
>>>>> on Tue, 12 Jul 2005 17:49:34 +0200 writes:
Carsten> Hello,
Carsten> I want to fit a tree parameter distribution to
Carsten> given data. I tried it with sample data using the
Carsten> "fitdistr" function.
Carsten> Here my workflow that didn't had any result:
Carsten> I started with the generalized gamma distr, which is:
Carsten> r*dgamma(x^r,shape,rate)
Carsten> The R-function is:
Carsten> ggamma = function (x,r,shape,rate) r*dgamma(x^r,shape,rate=rate)
Carsten> For the first step I assumed r = 1 and I generated
Carsten> random numbers with the "standard" Gamma distr.
Carsten> rn=rgamma(1000,10,5)
Carsten> In the last step I want to reconstruct the parameters from the dataset:
Carsten> library(MASS)
Carsten> fitdistr(rn, ggamma, list(r=1,shape=10,rate=5))
Carsten> But there is an error: Error in fitdistr(rn, ggamma, list(r = 1, shape = 10,
Carsten> rate = 5)) : optimization failed
Carsten> although I should have a nearly model-made dataset.
Carsten> Where is the problem and how could it be solved?
ggamma() is not a density.
You need to provide the correct multiplication factor (a
function of 'r' at least) in the definition of ggamma() such
that it *does* integrate to 1.
Martin
Carsten> Carsten
Carsten> [[alternative HTML version deleted]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
please read the posting guide and learn how to not produce
the above !
More information about the R-help
mailing list