Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • lrtest command in multilevel modelling

    Hi all
    I have a question regarding an error message after running a likelihood ratio test (LRT). We are building multilevel models and testing each model with the previous with the intention to retain the most parsimonious model. We are using the lrtest command to assess the model fit. I think the issue is with the code but any advice is greatly appreciated. Below are the details.

    We have a standardized continuous dependent variable (weight) and a binary (0,1) independent variable (smoke) - these are our level 1 variables. The level 2 variable is geographic region (geo).
    We have three models and we would like to test Model1 vs Model2 and Model2 vs Model3.

    Model1. Null model
    Code:
    mixed weight || geo:
    Model2. Random intercept
    Code:
     mixed weight i.smoke|| geo:
    Model3. Random coefficient
    Code:
    mixed weight i.smoke|| geo: R.smoke
    We tested Model1 vs Model2 using the lrtest command and a result was output (code below).
    Code:
    mixed weight || geo:, nolog
    est store null
    
    mixed weight i.smoke|| geo:, nolog
    est store ri_smoke
    lrtest ri_smoke null
    However, when we tested Model2 vs Model3 (code below) we get the following error message.

    df(unrestricted) = df(restricted) = 4


    Code:
    mixed weight i.smoke|| geo: R.smoke, nolog
    est store rc_smoke
    lrtest rc_smoke ri_smoke
    The mixed command delivers an output, but the lrtest command is producing the error message. I appreciate for nesting to occur the df needs to be larger in Model3. However as we have added an extra parameter into the model (random coefficient) my understanding is the df for Model3 is larger than Model2 and Model 2 is thus nested in Model 3. This makes me think it might be the code for the binary IV. Any advice is greatly appreciated!


    I am using Stata 16.

    Thanks in advance for your time.
    Jen
    Last edited by Jen Walker; 11 Feb 2021, 23:09.

  • #2
    If you're looking to test a random geographic region × smoking interaction term (in the presence of a corresponding fixed-effects main-effects-of-smoking term), then maybe try something like the following.
    Code:
    mixed weight i.smoke || geo: || smoke:, nogroup nolrtest nolog
    estimates store Interaction
    
    mixed weight i.smoke || geo:, nolrtest nolog
    lrtest Interaction

    Comment

    Working...
    X