Announcement

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

  • How can I use pweight by hand?

    Dear statalists:
    I want to use a mirco sampling data in R,but the package used in R is systemfit which doesn't support sampling weight(in stata,we can use option pweight),so I need to make some transformation to data in advance,. My question is how to transform constants in stata.
    In stata,if we want to use mirco sampling data for OLS,we can use this code:
    Code:
    reg y x [pweight = weight]
    
    *If we don't have constant,this order will be:
    
    reg y x [pweight = weight],nocons
    
    *and we can do it by hand,the next three codes are equal to "reg y x [pweight = weight],nocons"
    
    replace y = y*((weight)^0.5)
    replace x = x*((weight)^0.5)
    reg y x,noncons
    But the constant can't be omitted in regression, I wonder if you can tell how to use pweight by hand with constant in stata.
    Many thanks

  • #2
    This should do it:

    Code:
    gen ystar = y*sqrt(weight)
    gen xstar = x*sqrt(weight)
    one onestar = sqrt(weight)
    reg ystar onestar xstar, nocons vce(robust)

    Comment


    • #3
      Originally posted by Jeff Wooldridge View Post
      This should do it:

      Code:
      gen ystar = y*sqrt(weight)
      gen xstar = x*sqrt(weight)
      one onestar = sqrt(weight)
      reg ystar onestar xstar, nocons vce(robust)
      many thanks!

      Comment

      Working...
      X