# Compare two Weibull distributions

I want to compare two Weibull distributions fitted to two different datasets. Both datasets have a distribution that resembles the Weibull so the idea was to compare the fitted Weibull distributions to conclude whether the difference in the distribution of the two datasets is statistically significant. To this end I found a post by Ben Bolker on the R help mailing list that describes how to do this in R, that states the following:

(1) Fit a single model to the combined (pooled data) (e.g. with MASS::fitdistr()); (2) fit separate models to the individual datasets; (3) compare the log-likelihood of the pooled model to the sum of the log-likelihoods of the separate models.

According to the likelihood ratio test, the p-value of the differences is:

pchisq(2*(logLik_sum-logLik_pooled),df=2,lower.tail=FALSE)

(2 df because the separate models have a total of 4 parameters, 2 greater than the pooled model)

This is the original post: http://r.789695.n4.nabble.com/Comparison-of-two-weibull-distributions-td4679632.html

My question is, what is the null hypothesis in this likelihood ratio test? I get a P-value=0.4258827 and I don't know whether this means that the 2 Weibull distributions come from the same distribution or not. Please someone clarify this.

• Note that the pooled model is a special case of the two separate models - when the scale and shape parameters of each are respectively equal. – Scortchi - Reinstate Monica May 11 '17 at 18:19

My question is, what is the null hypothesis in this likelihood ratio test?

Under the null for that particular test as described, all the parameters are the same (which is why you were fitting a single Weibull to all the data under that case) -- under the shape-scale parameterization

$$f(x;\lambda,\theta) =\frac{\theta}{\lambda}\left(\frac{x}{\lambda}\right)^{\theta-1}e^{-(x/\lambda)^{\theta}} \: \mathbb{I}_{x\geq0}\,,\quad \theta,\lambda>0$$

the null would be that both the shape and scale parameters ($\theta$ and $\lambda$ respectively) are the same, which you might write as:

$$H_0: \theta_1=\theta_2\, , \: \lambda_1=\lambda_2$$

It's your null and alternative hypotheses that determine the likelihood ratio test that you do, not the other way around. If that's not the null you wanted to test you have to set the test up differently. The test takes the ratio of likelihoods under the null and alternative (and asymptotically, minus twice its log will be chi-squared distributed under fairly broad conditions).

I get a P-value=0.4258827 and I don't know whether this means that the 2 Weibull distributions come from the same distribution or not.

Note that you don't state a significance level anywhere. You shouldn't even do the calculations for a test until you have picked one, and until you're clear what your rejection rule will be.

(If you're asking here how to interpret a p-value or what a p-value greater than your significance level - assuming it is - means, we have many discussions on that topic which can be searched for. There's little value in repeating what's been said very well on the basic mechanics of how hypothesis tests work. Start with Wikipedia on statistical hypothesis testing under "An alternative process", and there's some discussion here and here for example. Since explanations of what to do are easy to find I assume your actual issue is somewhat different.)

If you understand that you don't reject (presuming your significance level is lower than your p-value here), but are asking about how to interpret the non-rejection, note that failure to reject the null does not mean that the two distributions are the same (as your question suggests).

It means there's no clear indication that they're different above what you'd be able to explain as due to random variation. Which is to say that the data are reasonably consistent with them having come from the same Weibull. This is not at all the same as being able to assert that they actually do.

It may in that situation be reasonable to act as if they're all drawn from the same distribution, but we don't know it to be so.

• So the answer in a few words: The null hypothesis is that both samples are drawn from a single Weibull distribution (i.e., the two distributions are the same); a large P value fails to provide support against the null hypothesis. – user1783988 May 16 '17 at 0:10
• Yes, though it's a slightly awkward way to phrase it. A large p-value would indicate that the deviation in the two sample estimates of the parameters is not inconsistent with the population parameter estimates being the same and there just being random variation. – Glen_b May 16 '17 at 5:35