Announcement

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

  • How to figure out which group it is when I run a logit regression with i.group?

    So I run a logit regression with state fixed effect using i.state_group. In the Logit regression results, it shows 12.state and 23.state have very significant coefficients. I would like to find out which states these are, is there a way? Thank you!

  • #2
    If the variable is labeled, you would see this directly. If you have a string variable with state names, then encode it and use that instead.

    Code:
    encode state, g(state_id)
    logit ... i.state_id

    Comment


    • #3
      Only if the information is in your data set somewhere. Typically, people have value labels attached to variables like this. But if that were the case for you, Stata would have shown the names of the states instead of the numbers. So it seems you don't have a value label attached. Perhaps your data set has two variables, one called state which is numeric, and another variable that has the corresponding names. Let's say that variable is called state_name. Then you could run -levelsof state_name if inlist(state, 12, 23)- to get those.

      Comment


      • #4
        As a side note to answers from Andrew Musau and Clyde Schechter that make the key points, note also that labmask from the Stata Journal assigns the values of a string variable to be value labels of a corresponding numeric variable, subject to common-sense restrictions.

        Comment


        • #5
          Thank you Andrew Musau , it worked perfectly! And thanks to everyone else for your additional insight.

          I have a quick follow up question. What if I use the following code (my state variable is a string variable):

          egen state_group=group(state)

          logit ... i.state_group

          And the result shows that 12.state_group is significantly positive. Does that mean that I can look up the state by checking which observations are assigned the state_group of 12? That is, is the i.state_group value exactly same as the assigned state_group by egen?

          Comment


          • #6
            Originally posted by Nancy Embder View Post
            What if I use the following code (my state variable is a string variable):

            egen state_group=group(state)

            logit ... i.state_group

            And the result shows that 12.state_group is significantly positive. Does that mean that I can look up the state by checking which observations are assigned the state_group of 12?
            Correct. The -group()- function of egen and encode both sort the string variable alphabetically and assign integer values to each level of the variable, starting at 1. Therefore, 12.state_group is the 12th alphabetically sorted state. You can also assign value labels with egen's -group()- function:

            Code:
            egen state_group=group(state), label
            logit ... i.state_group

            Comment


            • #7
              Thank you Andrew Musau !

              Comment

              Working...
              X