Announcement

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

  • Formula for weighted covariance in Stata (correlate command)

    I have come across research papers where they compute the weighted covariance between two variables. For example covariance between X and Y in year t is weighted by the population size. When I look at the Stata code, the authors would use:

    Code:
    correlate X Y [aweight=w], covariance
    The stata correlate manual has a example with real data as well:

    Code:
    webuse census13
    correlate mrgrate dvcrate [aweight=pop], covariance
    I wanted to know what the formula for the weighted covariance is in Stata. I think the weighted covariance formula is:

    sum(w_t(x_it - xbar)(y_it = ybar)) where w_t = w/sum(w),

    and xbar, ybar are also weighted using w [so for example xbar = sum(w_t x_it)/sum(w_t)]. I have tested out some examples and this formula closely matches what is obtained from Stata. I wanted to ask whether this is what Stata implements or is it some variant?
    Last edited by Hammad Shaikh; 27 Jun 2018, 22:16.

  • #2
    Hammad: Have you looked at the "Methods and Formulas" section of the pdf documentation for correlate ? I think this will give you the information you are seeking.

    Comment


    • #3
      John, thanks for the reply. I just checked it, the formula for the weighted correlation is indeed there. I had missed this before, thanks I know what the weighted covariance formula is now. My initial guess was correct.

      Comment

      Working...
      X