Announcement

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

  • Creating a variable containing the proportions of a binary variable

    Hi all,

    I am working with a binary variable "CareHome" that defines whether a patient lives in a nursing home or not (1=yes 0=no). In order to create a dummy variable that contains the proportion of patients living in a nursing home I have used this Code:
    Code:
    by Hosptial_Code, sort: egen pc_CareHome=mean(100*CareHome)
    However now if I tabulate the variable pc_CareHome it contains valuse >1 and I am wondering why because I supposed that pc_CareHome would now only contain values between 0 and 1 showing me the proportions?

    Thanks in advance

  • #2
    The variable you created wouldn't usually be called a dummy variable, at least not in literature I read. A dummy variable has two distinct values, by convention usually 0 and 1, although there are sometimes reasons for other coding such as -1 and 1. A dummy variable is in terminology you used a binary variable too.

    A really good if simple reason for using 0 and 1 is that means then make sense as proportions (probabilities, if you will). So if I have 1 1 1 1 1 1 1 0 0 0 then the mean is 0.7 and has an immediate interpretation as the proportion of 1s in the sample.

    Although usage can be sloppy, to me -- in this context -- a proportion is bounded by 0 and 1, and a percent(age) is bounded by 0 and 100, and your variable is a percent(age).

    There is a simple but good mathematical case that e.g. in 42% the % is just notation for /100 so 42% = 42/100 = 0.42 so on this line of argument a proportion and a percentage are one and the same and the difference is just one of display format. However, in most software I know percents are not supported as just being the same numbers but with a different display format. Certainly Stata has no such display format. I am told that MS Excel does support this, but I don't know more than that.

    In short, there is no problem in seeing results of more than 1 here and it is exactly what you expect if the proportion in care homes is ever more than 0.01 or equivalently the percentage is ever more than 1%,

    Other way round, if you need or want to see a proportion as result you must omit multiplication by 100.

    (A proportional change or percent change can easily exceed 1 or 100, as with a change from 100 to 500 which might be reported as a 400% increase.)

    Comment


    • #3
      Got it, thanks!

      Comment

      Working...
      X