MATLAB: Does MLE return a different result than LOGNFIT when estimating the parameters of a lognormal distribution

Statistics and Machine Learning Toolbox

I am trying to fit a lognormal distribution to some data using LOGNFIT. Performing a maximum likelihood estimation of the corresponding parameters using MLE yields different results. In particular, the second parameter (standard deviation) is different. The following code illustrates the problem:
x = [2 3 4 5];
p = lognfit(x)
q = mle(x,'distribution','logn')
Notice the difference in the second return parameter:
p =
1.1969 0.3956
q =
1.1969 0.3426
I would like to know why the maximum likelihood estimate of the second parameter is different.

Best Answer

It is common practice to compute sigma^2 as SSE/(n-1), which is known as the "unbiased estimator" or MVUE (minimum-variance unbiased estimator) and where SSE represents the sum of squared errors. That's also what NORMFIT returns, because that's what users are often looking for. MLE computes sigma^2 as SSE/n, which is the actual maximum likelihood estimator. The corresponding correction of the second parameter estimate is performed in mle.m as follows:
phat = [phat(1) phat(2).*sqrt((n-1)./n)]; % turn sigma into MLE
so as to return the maximum likelihood estimate of sigma (the second parameter), namely sqrt(SSE/n).