Error in fitdistr package for using fitdist in for loop

370 views Asked by At

I am running the below code, i.e to save the AIC values for negative binomial distribution in a vector.

max_nbinom_aic <-data.frame(NBINOM_AIC=numeric(0))
 for(i in 1:336) {
     a <- max_samples[,i]
     d <- fitdist(a,distr ="nbinom") 
 max_nbinom_aic <- rbind(max_nbinom_aic,d$aic)
}

I am getting the following error message:

Error in fitdist(a, distr = "nbinom") : the function mle failed to estimate the parameters, with the error code 100 In addition: Warning messages: 1: In sqrt(diag(varcovar)) : NaNs produced 2: In sqrt(1/diag(V)) : NaNs produced 3: In cov2cor(varcovar) : diag(.) had 0 or NA entries; non-finite result is doubtful

Also the output only contains 62 values, whereas I am expecting 336 values as I have 336 sets of distribution.

0

There are 0 answers