Announcement

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

  • #16
    Originally posted by Clyde Schechter View Post
    The variable x2_high was defined in #2 by -gen x2_high = (x2 > 0.5) if !missing(x2)-, and you were advised to change that to match whatever actual cutoff between high and non-high you intended. I see now that you chose to make the cut off 1 SD above the mean. So presumably you did something like this to create x2_high:
    Code:
    summ x2
    gen x2_high = (x2 > `r(mean)' + `r(sd)'
    That creates a variable that takes the values 1 when x2 is greater than mean + 1 SD, and 0 in all other observations (or missing if x2 is missing). Similarly for x2_low, but this time 1 when x2 is less than mean - SD, etc. So the code

    Code:
    replace x2_cat = 1 if x2_low == 1
    will set x2_cat = 1 in precisely those observations where x2 < mean - 1 SD.

    The code -replace x2_cat = 2 if x2_high == 2- was an error on my part. I meant to say
    Code:
    replace x2_cat = 2 if x2_high == 1
    so that x2_cat would, after that, be 1 when x2 is less than mean - 1SD, 2 when x2 is greater than mean + 1SD, and 0 for all other non-missing values of x2.


    That statement occurs just after the command which defines a value label named x2_cat (I chose that name deliberately to match the name of the variable I planned to use it with). -label values x2_cat x2_cat- then tells Stata to apply the label x2_cat to the variable x2_cat. That means that when the variable x2_cat is -list-ed or shown in the browser/editor, or when one of its values marks an indicator ("dummy") variable in a regression table, it will be shown as "medium", "low", or "high" instead of 0, 1, or 2, repsectively. That means you can read the output without having to remember what the 0, 1, and 2 codes stood for. This is a very useful thing to do with categorical variables, all the more so if the ordering of the underlying numbers 0, 1, and 2 does not correspond to a normal ordering of the words! It's not crucial to the calculations at all--and if it makes you uncomfortable you can skip it; but then you'll find the outputs harder to read because you'll have to constantly remind yourself that 0 = mid, 1 = low, and 2 = high.


    No, it means just the opposite. The ! operator in Stata is the logical not operator. So it sets x2_cat to 0 precisely when x2 is not missing. (And then, the next two lines of code change it to 1 or 2 if x2_low or x2_high is equal to 1.
    Thank you so much for your clarification and great help Clyde!!

    They are very helpful!

    Comment

    Working...
    X