As we mentioned earlier, the log likelihood of the fitted model is used to compare to other models, to identify if the reduced model fits significantly better than the full model. In order to compare models, in Stata we can use the ‘estimates store’ and ‘lrtest’ commands. We will re-run the same models we have just completed in the previous logistic regression examples. Each model is estimated and stored using the command ‘est store’ under an arbitrary name; in this example we are labelling them M0 to M3. You can use the ‘quietly’ command in front of the ‘logistic’ command to run the models in the background (i.e. Stata stores the output rather than writing it out at the time the command is run). It is possible to include code comments or annotations (text that explains the code you are running) in the Stata command window by starting the comment line with an asterisk (‘*’).
We will then use the ‘lrtest’ command to test whether the log likelihoods for each model are significantly different to each other.
In the output above, the log-likelihood test for M1 v M0 is the same result as the first model we ran in this set of ‘logit’ examples. This is because we are comparing the empty model (M0) with M1 which has only one predictor variable: general ability (chi-square = 42.48, p=<.001). In the second comparison above (M2 v M1), we can see that the addition of sex and family background variables to the model marginally improves the fit (chi-square = 20.79, p=<.01), while adding a single predictor (‘BMI at age 11’) in M3 makes a notable further improvement to the model fit (chi-square = 526.14, p=<.001). The final test M0 v M3 compares the original model with no explanatory variables and our final model; unsurprisingly given the other results, this again shows that adding all the predictors improves the fit over the empty model (chi-square = 589.41, p=<.001).
The Learning Hub is a resource for students and educators
tel | +44 (0)20 7331 5102 |
---|---|
closer@ucl.ac.uk |
Sign up for our email newsletters to get the latest from CLOSER
Sign up