0

Referring to the subject:

Fitting a lognormal distribution to truncated data in R

I am trying to estimate parameters of a truncated lognormal distribution:

library(fitdistrplus)
library(truncdist)


D <- rlnorm(1000,meanlog = -0.75, sdlog = 1.5)
# Censor data #
min <- 0.10
max <- 20
Dt <- D[D > min]
Dt <- Dt[Dt <= max]

#fitt <- fitdist(Dt, "lognormal", lower = min, upper = max)

dtruncated_log_normal <- function(x, meanlog, sdlog) 
  dtrunc(x, "lnorm", a=.10, b=20, meanlog=meanlog, sdlog=sdlog)
ptruncated_log_normal <- function(x, meanlog, sdlog) 
  ptrunc(x, "lnorm", a=.10, b=20, meanlog=meanlog, sdlog=sdlog)

fitdist(Dt, "truncated_log_normal", start = c(meanlog=0, sdlog=1))

But I get the below error:

Error in manageparam(start.arg = start, fix.arg = fix.arg, obs = data,  : 
  Wrong type of argument for start

Where is the problem? It is about the initial values. But I can't solve it.

I will be very glad for any help.

Thanks a lot.

oercim
  • 1,808
  • 2
  • 17
  • 34
  • Well, according to the documentation `fitdist` expects start to be a named list and you are passing in a named vector. Does using `start = list(meanlog=0, sdlog=1)` work, or at least give a different error message? – MrFlick Mar 26 '19 at 17:16
  • @MrFlick, thanks a lot. It worked. If you answer, I will submit it. Thanks a gain. – oercim Mar 26 '19 at 17:18

0 Answers0