Re: [R] R code for the MLE of a geometric distribution

From: <Bill.Venables_at_csiro.au>
Date: Sun, 16 Mar 2008 15:07:16 +1000

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!



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 Sun 16 Mar 2008 - 05:13: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 Sun 16 Mar 2008 - 09:30:22 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