2 min read

fitdistrplus

Warning in .check.version(config): Your configuration is compatible with version 0.8 of the ProjectTemplate package.
  Please run ProjectTemplate::migrate.project() to migrate to the installed version 0.8.2.

I’ve modified the helper functions to separate out the creation of the censored data frame from the fitting, and to allow setting the origin. Note that setting zero = 7 only looks at the runway, and allows use of non-truncated distributions when the distribution only has support for non-negative values.

For example:

library(fitdistrplus)
temp <- filter(disperseLer, ID == "100_0")
cens_data <- cens_dispersal_data(temp, 7)
p1 <- fitdistcens(cens_data, "lnorm")
summary(p1)
Fitting of the distribution ' lnorm ' By maximum likelihood on censored data 
Parameters
         estimate Std. Error
meanlog 0.6041551 0.09963495
sdlog   0.7210309 0.08006517
Loglikelihood:  -102.8429   AIC:  209.6857   BIC:  213.8066 
Correlation matrix:
           meanlog      sdlog
meanlog  1.0000000 -0.1424193
sdlog   -0.1424193  1.0000000
plot(p1)

p2 <- fitdistcens(cens_data, "exp")
summary(p2)
Fitting of the distribution ' exp ' By maximum likelihood on censored data 
Parameters
      estimate Std. Error
rate 0.4364277 0.05776133
Loglikelihood:  -106.5479   AIC:  215.0957   BIC:  217.1562 
plot(p2)

I’ve just found that the rmutil package adds a lot of distributions, some of which may be useful (not 2DT though). However, starting values of the parameters need to be set. Furthermore, there appears to be a bug in fitdistcens: comparing with fitdist, it appears that the line

    arg_startfix <- checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg, 
        argddistname)

needs to be replaced by

    hasnodefaultval <- sapply(formals(ddistname), is.name)
    arg_startfix <- checkparamlist(arg_startfix$start.arg, arg_startfix$fix.arg, 
        argddistname, hasnodefaultval)

I can hack that, but need to send a bug report (unfortunately the code is on R-forge and not very user-friendly).