rfitdistrplus

Fitting truncnorm distribution with distrplus causes fatal error (R crashes)


Here's the code that crashes R for me without any useful error messages. Any ideas? I'm going crazy over here. Thanks,

library(fitdistrplus)
library(truncnorm)
set.seed(0)
x = rtruncnorm(n=30, a=0, b=Inf, mean=1, sd=0.45)
my_fit = fitdist(x, "truncnorm", method='mle', fix.arg=list(a=0, b=Inf), 
                 start=list(mean=mean(x), sd=sd(x)))

Solution

  • Once Ben Bolker identified that truncnorm - not fitdist - is the issue, I decided to simply use a different library. The following code executes just fine for me:

    library(fitdistrplus)
    library(extraDistr)
    set.seed(0)
    x = rtnorm(n=30, a=0, b=Inf, mean=1, sd=0.45)
    my_fit = fitdist(x, "tnorm", method='mle', fix.arg=list(a=0, b=Inf), 
                     start=list(mean=mean(x), sd=sd(x)))