Announcement

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

  • P-trend in logistic regression with interaction term

    Hi all. The question I am asking below, I have also posted it here but it is not answered yet.
    I am using Stata to make my analysis. I know that to examine p-trend I can rerun the model by treating the categorical variable as continuous. But my model has also interaction term which made it difficult to for me interpret the p value. In short My original model is
    logistic y i.quintile i.x i.quintile#i.x
    So inorder to get the p-trend should I change the model to
    logistic y quintile x i.quintile#x
    Or
    logistic y quintile x c.quintile#x ?
    I have tested the model with continuous scores instead of quintiles and there was no important difference. So I have done the regression with the quintiles to understand the non linear relationship. Thnx

  • #2
    So inorder to get the p-trend should I change the model to
    logistic y quintile x i.quintile#x
    Or
    logistic y quintile x c.quintile#x ?
    Neither. These two models will both treat the "main" effect of x as a continuous variable, when it should be a discrete variable. The second one is closer in that it treats quintile properly. But fully representing what you want, and also simpler, is:
    Code:
    logistic y c.quintile##i.x
    The important thing to remember about factor variable notation is:

    A variable listed with no prefix (neither i. nor c.) is treated as continuous, except in an interaction, in which case it is treated as discrete. A syntax like -logistic y quintile x c.quintile#x- would result in the "main" effect of x being continuous while that interactions would be generated from a discrete version of x. This inconsistent handling results in a mis-specified model that is not valid as a description of anything.

    You will probably want to follow this up with some statistics generated by the -margins- command. If you are not familiar with it already, I suggest you start by reading the excellent Richard Williams' https://www3.nd.edu/~rwilliam/stats/Margins01.pdf, which is very clearly written and also contains numerous worked examples. After that, to learn about more advanced features, refer to the -margins- chapter of the PDF documentation.

    Comment


    • #3
      Thank you, Clyde, for your reply. I tried to edit the post/codes but Statalist did not allow me to edit it after submission. The original regression model was like:
      Code:
      logistic y i.quintile i.x i.quintile#i.x
      and for the p-trend I was thinking to treat the quintile as continuous..
      Code:
      logistic y quintile i.x c.quintile#i.x
      which is similar to your correction (the ## being saving much more time saving and clean).
      thank you one more time for the -margins- command suggestion. It helped me a lot

      Comment

      Working...
      X