Re: [R] three par. fitting with fitdistr

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Wed 13 Jul 2005 - 02:13:33 EST

>>>>> "Carsten" == Carsten Steinhoff <carsten.steinhoff@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 !



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 13 02:17:31 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:34 EST