Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: covariance


From   Christopher F Baum <[email protected]>
To   [email protected]
Subject   st: Re: covariance
Date   Wed, 25 Aug 2004 07:19:36 -0400

On Aug 25, 2004, at 2:33 AM, Amadou wrote:

I have an income variable grouped into 5 categories (Q1 Q2 Q3 Q4 Q5) ie from
poorest to
richest and I want to compute its covariance with the following vector:

| 0.1 |
| 0.3 |
| 0.5 |
X = | 0.7 |
| 0.9 |

. input q tgt

             q        tgt
  1. 0.05 0.1
  2. 0.21 0.3
  3. 0.37 0.5
  4. 0.56 0.7
  5. 0.78 0.9
  6. end

. corr q tgt,cov
(obs=5)

             |        q      tgt
-------------+------------------
           q |   .08233
         tgt |    .0905       .1

. return lis

scalars:
                 r(N) =  5
            r(cov_12) =  .0904999940395357
             r(Var_2) =  .0999999925494196
             r(Var_1) =  .0823299950939419

Kit

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index