Fizboy
Fizboy

Reputation: 1

Fitting a Poisson dist and MLE

I am trying to find the MLE estimate for lambda, the dataset is column1= date and time(Y-m-d hour:min:sec)- distributed by a Poisson. column2=money in a certain account. I kept getting an error message because it said the dataframe didn't have numerical values so I checked the classes:

[1] "POSIXct" "POSIXt" 
[1] "numeric"

so I used the following command:

as.numeric(Capped_data_M$Date_Time - ISOdate(2019,01,01, hour=0, min=0, sec=0)

This made the dates into values like 6.556666

I then attempted

Poifit <- fitdist(dateandtime,"poisson", method = "mle")

But I get this error message saying the distribution is not defined. Where did I go wrong?

Upvotes: 0

Views: 605

Answers (1)

the-mad-statter
the-mad-statter

Reputation: 8861

From the fitdist() documentation in the fitdistrplus package, the distr argument should be:

A character string "name" naming a distribution for which the corresponding density function dname, the corresponding distribution function pname and the corresponding quantile function qname must be defined, or directly the density function.

In other words, you should change your "poisson" to "pois"

library(fitdistrplus)

dateandtime <- rpois(100, lambda = 1.3)

fitdist(dateandtime, "pois", "mle")
#> Fitting of the distribution ' pois ' by maximum likelihood 
#> Parameters:
#>        estimate Std. Error
#> lambda     1.25  0.1118033

Created on 2021-04-19 by the reprex package (v1.0.0)

Upvotes: 0

Related Questions