[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: Re: st: -mean- over id, save to a new dta, then variance matrix

Subject   Re: Re: st: -mean- over id, save to a new dta, then variance matrix
Date   Mon, 22 Oct 2007 14:04:00 +0200

I am trying to translate a S-PLUS command: var(x). The description of the command is: 'var', 'cov' and 'cor' compute the variance of 'x' and the covariance or correlation of 'x' and 'y' if these are vectors.  If 'x' and 'y' are matrices then the covariances (or correlations) between the columns of 'x' and the columns of 'y' are computed. 
Below you find the result of this command when applied to a modified auto dataset (i.e. after -drop make rep78 foreign-).


P.S. -collapse- reduces my dataset to just one column: is there any way to keep the column v1 with the panel identifier from the original dataset?

At 02.33 19/10/2007 -0400, "Austin Nichols" wrote:
>The first part is
> collapse v2-v17, by(v1)
>but I don't understand what you mean by "I would like to calculate the
>variance matrix for such new dta and saving it in one more new dta."
>On 10/18/07, <> wrote:
>> I have one dta of 17 columns and 354 rows. The first column, named id, contains the panel identifier (an integer from 1 to 63). I would like to produce a new dta file with 17 columns (keeping the original names) and 63 rows, containing the id variable, and the mean of the remaining 16 columns calculated by the id variable.
>> I know that I can have such means by -mean- and -tabstat-, but how can easily export the results in a new dataset? Next, I would like to calculate the variance matrix for such new dta and saving it in one more new dta.
>> How can I do? 

*   For searches and help try:

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