Does anyone know how to approach R code for the MLE of a geom. distribution? thanks! [[alternative HTML version deleted]]
Bill.Venables at csiro.au
2008-Mar-16 05:07 UTC
[R] R code for the MLE of a geometric distribution
This is an imprecise question. There are actually two geometric distributions. See http://en.wikipedia.org/wiki/Geometric_distribution They are related, of course. One is defined as the minimum number of trials to achive one success in bernoulli trials. The other is the number of failures preceding the first success in bernoulli trials. The second is the more convenient for most applications. Let's assume this is your definition. If not, just subtract 1 from all your data. If you are talking about the maximum likelihood estimate of "the" parameter of a geometric distribution, it suggests you are dealing with a homogeneous sample. In this case you don't need much R code. There is a formula for the MLE which you can simply compute. (See, e.g. the above link). Anyone using R should be able to do that. If the situation is more complex and you are dealing with a generalized linear model where the data are geometric (in the second sense above) with the mean related to a linear function of predictors using a link function, then you have a much more interesting case. One way to do this is to use the fact that the geometric distribution is a special case of the negative binomial: require(MASS) modl <- glm(y ~ x1+x2+..., family = negative.binomial(theta = 1), ### i.e. the Geom. Dist. data = myData, ....) and all the paraphernalia of generalized linear modelling then apply. Bill Venables. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Kathy Maher Sent: Sunday, 16 March 2008 12:26 PM To: R-help at r-project.org Subject: [R] R code for the MLE of a geometric distribution Does anyone know how to approach R code for the MLE of a geom. distribution? thanks!