Announcement

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

  • Output the Equation of a Logistic Regression

    Hello,

    i have a short and simple question. Im running a logistic regression with 16 Variables and i want to create the equation of this regression model for my paper. Since its very costly to build it via Word or Excel i was wondering if there is any possibility to output the equation of my regression with Stata. I was checking out a lot of pages but i found nothing. So i would like to present my question to you. I appreciate every answer that could help me with my problem. Thank you in advance.

    Best regards
    Leo

  • #2
    Here's a general approach. You may want to modify the appearance of the coefficients by a different format than %3.2f.

    Code:
    sysuse auto, clear
    
    logistic foreign price mpg trunk
    
    local equation "log odds `e(depvar)' = "
    
    matrix b = e(b)
    local indvars: colnames b
    display `"`indvars'"'
    
    local equation `equation' `:display %3.2f =_b[_cons]'
    
    local indvars: subinstr local indvars "_cons" ""
    
    foreach i of local indvars {
        local equation `equation' " + `:display %3.2f =_b[`i']'*`i'"
    }
    
    display `"`equation'"'
    This approach has substantial aesthetic limitations if you have factor variables among your predictors. Revising the code to deal with that would be a fairly major undertaking, and unless you are cranking out a very large number of equations, it would be easier to just hand-edit the output.

    Comment


    • #3
      Hello Mr. Schechter,

      awesome! Thank you very much for your fast response. It worked out very well!

      Best regards
      Leo

      Comment


      • #4
        You may also wish to check the user-written - equation - for that matter.
        Best regards,

        Marcos

        Comment

        Working...
        X