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

From |
nicola.baldini2@unibo.it |

To |
statalist@hsphsun2.harvard.edu |

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-). ,price,mpg,headroom,trunk,length,turn,displacement,gear.ratio price,28360.29156,4017.557201,134067.0459,-422.1304035,28360.29156,4017.557201,134067.0459,-422.1304035 mpg,-102.513884,-18.305072,-374.92521,1.626616,-102.513884,-18.305072,-374.92521,1.626616 headroom,9.725565,1.579785,36.86505,-0.1458571,9.725565,1.579785,36.86505,-0.1458571 trunk,69.202518,11.310626,239.087,-0.992773,69.202518,11.310626,239.087,-0.992773 weight,16370.92188,2931.725287,63873.45057,-269.2507495,16370.92188,2931.725287,63873.45057,-269.2507495 length,495.789893,84.660866,1707.76009,-7.0751459,495.789893,84.660866,1707.76009,-7.0751459 turn,84.660866,19.354313,313.83191,-1.3575823,84.660866,19.354313,313.83191,-1.3575823 displacement,1707.760089,313.831914,8434.07479,-34.7333827,1707.760089,313.831914,8434.07479,-34.7333827 gear.ratio,-7.075146,-1.357582,-34.73338,0.2081979,-7.075146,-1.357582,-34.73338,0.2081979 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, nicola.baldini2@unibo.it <nicola.baldini2@unibo.it> 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: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**Re: st: Hausman Taylor Estimation in an Unbalanced panel** - Next by Date:
**Re: st: how to create dummy for unique values across variables** - Previous by thread:
**Re: st: -mean- over id, save to a new dta, then variance matrix** - Next by thread:
**st: Re: SUR and unbalanced panel data** - Index(es):

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