Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fitting an inverse gaussian distribution to data in R

Tags:

r

gaussian

mle

Im trying to use the fitdist function in R to fit data to three different distributions by maximum likelihood to compare them. Lognormal and Weibull work fine, but I am struggling with Inverse Gaussian. I need to specify starting values, however when I do I get an error message.

fw<-fitdist(claims,"weibull") WORKS
fln<-fitdist(claims,"lnorm") WORKS
fig<-fitdist(claims,"invgauss",start=list(mu=0,lambda=1)) DOES NOT WORK

Error: 'The pinvgauss function should return a zero-length vector when input has length zero and not raise an error'

What is wrong with my code?

like image 817
sam Avatar asked Oct 14 '25 18:10

sam


1 Answers

I was working with a similar issue and found the issue was with how I labeled my start values. The actuar library I was working with required the labels "mean" and "shape" on the values. The following code provided me a solution:

library(actuar)
library(fitdistrplus)
fig <- fitdist(claims, "invgauss", start = list(mean = 5, shape = 1))
like image 180
James Whittier Avatar answered Oct 17 '25 08:10

James Whittier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!