Hi!
I have following data which is left truncated say at 10. I am trying to estimate
the parameters of the Truncated Lognormal distribution to this data as given
below.
(I have referred to R code appearing in an earlier post -
http://finzi.psych.upenn.edu/Rhelp10/2008-October/176136.html)
library(MASS)
x <- c(600.62,153.05,70.26,530.42,3440.29,97.45,174.51,168.47, 116.63,36.51,
219.77,
231.67,110.62,173.11,202.85,689.27,23.82,234.15,625.89,192.88,29.53,109.99,
80.53, 46.85,82.69,231.53,75.38,217.52,85.29,182.18)
ltlnorm <- function(x, meanlog, sdlog, log=FALSE)
{
dlnorm(x, meanlog, sdlog, log = FALSE) / plnorm(1, meanlog, sdlog, lower.tail =
TRUE, log.p = FALSE)
}
meanlog = mean(log(x))
sdlog = sd(log(x))
ltlnormfit <- fitdistr(x,ltlnorm, start=list(meanlog,sdlog))
I get following error -
Error in dlnorm(x, meanlog, sdlog, log = FALSE) : element 3 is empty;
the part of the args list of '.Internal' being evaluated was:
(x, meanlog, sdlog, log)
Please guide me as to
(1) How do I overcome this error;
(2) In the function, I have defined plnorm(1, meanlog, sdlog, lower.tail = TRUE,
log.p = FALSE). The usual syntax is plnorm(q, meanlog = some value, sdlog =
some value, lower.tail = TRUE, log.p = FALSE). I have taken q as 1. Should it be
the truncation point i.e. 10. and lastly
(3) I have defined meanlog and sdlog as mean(log(x)) and sd(log(x))
respectively. Am I write in doing so?
Please guide me. I have used this fitdistr for the first time.
Regards
Julia
************************************************
Only a man of Worth sees Worth in other men
************************************************
[[alternative HTML version deleted]]