I'm working with some data that has historically been modeled by Weibull and lognormal distributions. I have used the maximum likelihood estimation method to estimate parameters of both distributions which would describe my data. Now, I wish to determine which model is more apprproprite, i.e. has a better fit. I'd like to use the likelihood ratio to do this, and have been looking at the functions negloglike() and lratiotest() (which is from the econometrics toolbox) for doing this.
Currently I have calculated the negative log likelihood for both fit models via the negloglike() funciton and have also tried to use these values as the unrestricted and restricted model parameters with the lratiotest() function. Due to my naivity in this field and the lack of similar examples I am unsure if I'm using these tools correctly. The stripped-down code is provided below. For the momement, I'm using randomly generated data to prove-out the code. I expect, as the data is generated from a Weibull distribution, that I should reject the null hypothesis (that the restricted Wiebull fitted distr. is more appropriate) and accept the alternative (that the unrestricted lognormal fitted distr. is more appropriate). I've noticed that, even when the MLE parameters for the estimated Weibull distribution are very close to the population parameters, I still reject the null. I believe the correct degrees of freed om for the test is 2, but I may be wrong there too.
Thanks ahead of time for any assistance!
scl = 125e3; shp = 2.5;, n = 100;x = wblrnd(scl, shp, n, 1);wblPD = fitdist(x, 'weibull');lnPD = fitdist(x, 'lognormal');wblPms = mle(x, 'distribution', 'weibull');lnPms = mle(x, 'distribution', 'lognormal');rLogL = negloglik(wblPD)uLogL = negloglik(lnPD)dof = 2;[h, pValue] = lratiotest(uLogL, rLogL, dof)
Best Answer