Dear R-helpers,
I am trying to fit my data to a 4-parameter lognormal distribution (aka
Johnson Sb dist) with fitdist function from the library(fitdistrplus). So
far, I have learnt that with "mle" method it's not always possible
to
estimate the gamma and delta parameters even if the bounding estimates are
"known"/"guessed".
Therefore, I tried to fit it with the "mme" method giving:
#xi = xi
#lambda =l
#delta =d
#gamma = g
data1 <- rlnorm(10000,-2.79,0.598) ## the parameters have been estimated
for a 2-parms lognormal dist.
djohn <- function(x,xi,l,d,g) { ## probability density function of
Johnson SB distribution (source:
http://www.ntrand.com/johnson-sb-distribution/)
(d/(l*sqrt(2*pi)*((x-xi)/l)*(1-((x-xi)/l))))*exp(-0.5*(g +
d*log(((x-xi)/l)/(1-((x-xi)/l))))^2)
}
pjohn <- function(x,xi,l,d,g) {
pnorm(g + d*log(((x-xi)/l)/(1-((x-xi)/l))))
}
qjohn <- function(p,xi,l,d,g) {
qnorm(xi + (l*exp((qnorm(p) - g)/d))/(1 + exp((qnorm(p) - g)/d)))
}
library(moments)
memplog <- function(x,order) {
ifelse(order==1, mean(x), moment(x,order,central=TRUE))
}
fjsb <-
fitdist(c(data1),"john",method="mme",order=c(1,2),memp="memplog",start=list
(xi=0,l=max(data1),d=1,g=1))
But it results in:
> fjsb <-
fitdist(c(data1),"john",method="mme",order=c(1,2),memp="memplog",start=list
(xi=0,l=max(data1),d=1,g=1))
Error in mmedist(data, distname, start = start, fix.arg = fix.arg, ...) :
wrong dimension for the moment order to match.
And I just can't figure out where the mistake is. Thank you very much for
your help in advance.
Regards,
Tanya
[[alternative HTML version deleted]]