Announcement

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

  • Predictions using gologit2 - issues applying coeffcients to validation dataset

    I'm new to Stata, so apologies in advance if this is a basic question. I am having some issues applying coefficients from my gologit2 model from my data, to a test dataset. I'm wondering whether I'm approaching this wrong!?
    • Dataset split into two - development and test datasets
    • Outcome variable is severity of a disease of interest (mild, moderate, severe)
    • GOLOGIT2 used due to issues with the proportional odds assumption being violated in OLOGIT
    • Stepwise ran using GOLOGIT2 (without autofit as read somewhere that SW and autofit should not be run together)
    • Final model run but with autofit.
    • When I try to apply coeefficients from this regression to my test dataset it does not work.I have tried the following options:
    1. I applied estimation results to test data and tried to use predict.
      • Code:
        • Use develop.dta
        • Gologit2 y i.x1 x2 x3, autofit
        • drop _all
        • use test.dta
        • predict p1 p2 p3
      • Issue is that dummy variables created in the development data that are not present in the test data
    2. After fitting the model on the development data, merge in test data in and run the predict command - Issue is that it wont predict for the merged data – probably due to a similar issue to the one above
    3. I pulled in the development and test data into one big dataset and tried to use if with gologit2 (i.e. to run the model on half of my data if var ==1 ), then appy coefficients to all.Message came up saying that I could not use if with gologit2.
    Many thanks for your help!

  • #2
    Welcome to Statalist.

    You are only showing some of the commands and none of the output, so it is a little hard to assess. First off make sure you have the most current version of gologit2:

    Code:
    . which gologit2
    c:\ado\plus\g\gologit2.ado
    *! version 3.2.5 17may2019 Richard Williams, [email protected]
    gologit2 does support the if qualifier so I do not know why you would get an error unless you typed the syntax wrong.

    This to me sounds like what you want to do and it works fine for me:

    Code:
    webuse nhanes2f, clear
    gologit2 health height weight i.female if black == 1, auto
    predict p1 p2 p3 p4 p5 if black == 1
    predict q1 q2 q3 q4 q5 if black == 0
    sum p1-p5 q1-q5
    Or, more like the example you show,

    Code:
    webuse nhanes2f, clear
    keep if black == 1
    gologit2 health height weight i.female, auto
    predict p1 p2 p3 p4 p5
    sum p1-p5
    drop _all
    webuse nhanes2f
    keep if black == 0
    predict q1 q2 q3 q4 q5
    sum q1-q5
    So, make sure gologit2 is up to date and that your different data sets have the exact same variable names. If problems persist, show both your commands and output, using code tags. Read the list FAQ, especially pt 12 on asking Qs effectively.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    Stata Version: 17.0 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      thank you so much for this, it worked!

      Comment

      Working...
      X