Announcement

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

  • how to add polynomial term to logistic regression model

    Dear Statalist members,
    I want to include a polynomial term in my logistic regression as the lowess graph for one of the variables looks like shown on the graph.

    However, when I try to use the fp command to find the best-fitting polynomial term, Stata returns “< invalid name” all the time. I tried with different spacing and everything but nothing seems to work. Does anyone have an idea, what could be the problem?

    What would be another way to add the best-fitting polynomial term to my model?

    Thank you very much for your help!
    Attached Files

  • #2
    Hi Janina
    What code are you using for your logistic regression model?
    Usually once the interaction term is significant you can stop adding orders. You can also test model fit between each model.

    For example:
    Code:
    logit y c.x##c.x //second-order polynomial (quadratic)
    logit y c.x##c.x##c.x //third-order polynomial (cubic)
    logit y c.x##c.x##c.x##c.x //fourth-order polynomial 
    logit y c.x##c.x##c.x##c.x##c.x //fifth-order polynomial (quadratic)
    Hope that helps
    /Peta

    Comment


    • #3
      Hello Peta,

      thanks a lot! That helps a lot! Only the second-order polynomial is significant in my model.

      I was running this code before:

      fp <debt>: logit pb<debt>

      However, I only got back:

      < invalid name
      r(198);

      Please allow me one more question.

      I ran different models with the y c.x##c.x term and tried to get a table with the result overview typing

      esttab m31 m32 m33 m34 m35 m36 m37 m38 m39 m40 using 17.2.end4.rtf, b(3) pr2 eform

      However, I got the message
      debt#c: operator invalid
      r(198);

      Do you know why that could be? Is ist because of the #?

      Thanks again for your help!

      Janina

      Comment


      • #4
        Hi Janina
        Glad that helped!
        Without having a sample of your data and the exact code I can not be sure what the issue is.
        A quick search found this same error: http://www.stata.com/statalist/archi.../msg00316.html
        /Peta

        Comment


        • #5
          Dear Peta,

          thanks a lot! That helped again! I just had to update the program.

          Thank you!

          Janina

          Comment

          Working...
          X