[R] gamma parameters fitted

From: KOITA Lassana - STAC/ACE <lassana.koita_at_aviation-civile.gouv.fr>
Date: Fri, 16 May 2008 10:31:55 +0200


Hi R-users,
I'm fitting gamma parameters (shape and rate ) by two methods (by direct and and fitdistr of MASS library). I have realized the following code which gives me two results. However, I find that those two outcomes are significantly different. Is there any explanation to this case? Many thanks in advance for your help

> param <- function(y)
+
+ {
+ library(MASS)
+
+ b <- subset(tab[!is.na(tab$DVTDR) & (tab$DVTDR > 0),], IDAV<= y )
+
+ z <- b$DVTDR
+
+ m <- mean(z)
+
+ v <- var(z)
+
+ para1 <- list(shape = m^2/v, rate = m/v)
+
+ para2 <- fitdistr(z, "gamma")
+
+ return(list(para1,para2))
+
+ }

>
> param("321")

[[1]]
[[1]]$shape
[1] 1.603642

[[1]]$rate
[1] 1.286430

[[2]]

     shape rate
  1.81991260 1.45992004
 (0.02503046) (0.02309113)

##

Lassana KOITA

E-mail: Lassana.Koita_at_aviation-civile.gouv.fr http://www.stac.aviation-civile.gouv.fr/

        [[alternative HTML version deleted]]



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. Received on Fri 16 May 2008 - 08:37:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 16 May 2008 - 09:30:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive