Announcement

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

  • Logistic Regression with Categorical Independent Variables using Stepwise Method

    Dear Statalist,

    I have some categorical variables, for example bmi_cat (BMI category) : 1=low, 2=normal, 3=high. I have the dependent variable dep_var as 0, 1.

    I want to run the logistic regression of dep_var on bmi_cat where bmi_cat = 1 will be the reference category, and I want to use stepwise method.

    I am getting an error after running this

    sw, pe(0.2): logistic dep_var i.bmi_cat

    The error is

    factor variables and time-series operators not allowed
    r(101);

    Is there any other way?

    Thank you in advance.

  • #2
    You will increase your chances of useful answer by following the FAQ on asking questions – provide Stata code in code delimiters, readable Stata output, and sample data using dataex area

    You can always create your dummies using xi as a command – look at the documentation.

    Comment


    • #3
      Shoummo:
      as as aside to Phil's helpful reply, I would recommend you to consider Frank Harrel's enlightening comments on the downsides of stepwise regression (https://www.stata.com/support/faqs/s...sion-problems/).
      Kind regards,
      Carlo
      (Stata 18.0 SE)

      Comment


      • #4
        As of the Oct 16, 2019 update of Stata 16:

        4. nestreg now supports factor-variables notation. The old behavior (that is, not allowing factor-variables notation) is preserved under version control.

        5. stepwise now supports factor-variables notation. The old behavior (that is, not allowing factor-variables notation) is preserved under version control.
        However this does not change the fact that stepwise regression is still the work of the devil. ;-)
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

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

        Comment

        Working...
        X