Announcement

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

  • How to incorporate number of credits as weights?

    Hi,

    I want to regress variable "pass" which is equal to 1 if the course was passed on variable "roommate" which is a dummy equal to 1 if the individual has a roommate.
    I would like to weigh each pass observation by the number of credits each course has. How should I do this? Would it suffice to use [aw=credits] in the regression? Would it be the same case if I have an instrument and I want to use ivregress 2sls?

    My data looks like the sample below:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float id str1 course_code float(pass credits roommate)
    1 "A" 1   5 1
    1 "B" 1   5 1
    1 "C" 1   4 1
    1 "D" 0   2 1
    1 "E" 1   2 1
    1 "F" 1   2 1
    2 "A" 1   5 0
    2 "B" 0   5 0
    2 "G" 0   5 0
    2 "H" 1   5 0
    3 "N" 1 7.5 1
    3 "M" 1 7.5 1
    3 "O" 1 7.5 1
    3 "B" 1   5 1
    4 "Y" 0  15 1
    4 "Z" 0 2.5 1
    5 "Q" 1   5 1
    6 "R" 1 7.5 0
    6 "T" 1 7.5 0
    7 "B" 1   5 0
    7 "C" 1 2.5 0
    7 "D" 1   3 0
    end
    Thanks!

  • #2
    Can anyone help with this please?

    Comment


    • #3
      aw=credits would do it.

      Comment


      • #4
        Originally posted by George Ford View Post
        aw=credits would do it.
        Thanks! Would it give me the same results if I manually take the weighted average of the variable pass for each individual?

        Best

        Comment


        • #5
          Code:
          reg pass roommate 
          tabstat pass, by(roommate) save
          di r(Stat2)[1,1] - r(Stat1)[1,1]
          
          
          reg pass roommate [aw=credits]
          tabstat pass [aw=credits], by(roommate) save
          di r(Stat2)[1,1] - r(Stat1)[1,1]

          Comment

          Working...
          X