Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Alvarez,Sergio" <[email protected]> |

To |
<[email protected]> |

Subject |
Re: st: tabstatmat question |

Date |
Fri, 02 Sep 2011 13:14:40 -0400 |

Hi Austin,

WAVE ZONE 1 2 ... 1 mean(1,1) mean(1,2) 2 mean(2,1) mean(2,2) ...

gen meancatch = matrix[zone,wave]

egen byv=group(zone wave), lab tabstat num_typ3, stat(mean) by(byv) save tabstatmat TABLE And this created the matrix with the values, and looks like this: TABLE[414,1] num_typ3 1†1:mean 1.9822335 1†2:mean 2.6614173 1†3:mean 2.7150396 1†4:mean 3.3340782 1†5:mean 2.8161094 1†6:mean 1.1767857 2†1:mean 1.5857143 2†2:mean 2.1863208 2†3:mean 2.542777 2†4:mean 1.8849432 2†5:mean 1.7281553 2†6:mean 1.4927536 3†1:mean 1.875 ..... There's 85 sites with 6 waves a piece.

I really appreciate the help. Sergio On Fri, 2 Sep 2011 12:45:05 -0400, Austin Nichols wrote:

Sergio <[email protected]>: Did you read my response?Look at the matrix; there is one column, so your references to rowandcolumn make no sense.You could make another matrix with values of byv corresponding tozoneand wave, noting that you must have these be integers counting from 1 up for row and column numbers to correspond to what you seem to want. But why? What would be the point of this?On Fri, Sep 2, 2011 at 12:35 PM, Alvarez,Sergio <[email protected]>wrote:Sorry about ambiguity.So I used the mean by group code to create the matrix that wouldstore themean values for each group, using: egen byv=group(zone wave), lab tabstat num_typ3, stat(mean) by(byv) save tabstatmat TABLEwhich gives me a matrix, or rather a vector, with all the values Ineed.The first few lines of the matrix in the output screen look likethis:TABLE[414,1] num_typ3 1†1:mean 1.9822335 1†2:mean 2.6614173 1†3:mean 2.7150396 1†4:mean 3.3340782 1†5:mean 2.8161094 1†6:mean 1.1767857 2†1:mean 1.5857143 2†2:mean 2.1863208 2†3:mean 2.542777 2†4:mean 1.8849432Now what I want to do is use -gen- or -egen- to create a variablethat wouldlook up the zone and wave of the corresponding observation from thematrixand insert the correct value in there. So I tried: gen meancatch = TABLE[zone,wave]and this gives the correct values for all observations with wave =1, butcreates missing values on the rest of the observations. I alsotried:gen meancatch = TABLE[byv,num_typ3]and this gives me the correct value in some of the observations, butmostlymissing values in the others.So I must be doing something wrong, but can't figure out what. Iguess thequestion is how to call the row and column numbers from the TABLEmatrix?Thanks again, Sergio On Fri, 2 Sep 2011 12:08:31 -0400, Austin Nichols wrote:Sergio <[email protected]> :Now I have no idea what you are trying to do. For the mean bygroup,egen mby=mean(num_typ3), by(zone wave)but you are referring to (probably) nonexistent row and columnnumbersof a matrix in your example.On Fri, Sep 2, 2011 at 10:42 AM, Alvarez,Sergio <[email protected]>wrote:Thanks Austin and Nick for your help. I used what Austinsuggested(whichis what Nick also suggested) and it worked. However, when I try tocreatethe variable that contains the mean by group it works for some observations, but missing values are created for most of them. I tried both: gen meancatch = TABLE[zone,wave] and gen meancatch = TABLE[byv,num_typ3] For the first line of code, it creates the correct value for allobservations where wave = 1, but not for any others. The secondlinecreates missing values at random (as far as I can tell). I'd appreciate any tips.** * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

-- Sergio Alvarez Food and Resource Economics University of Florida * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: tabstatmat question***From:*Nick Cox <[email protected]>

**Re: st: tabstatmat question***From:*Austin Nichols <[email protected]>

**References**:**st: tabstatmat question***From:*"Alvarez,Sergio" <[email protected]>

**Re: st: tabstatmat question***From:*Austin Nichols <[email protected]>

**Re: st: tabstatmat question***From:*"Alvarez,Sergio" <[email protected]>

**Re: st: tabstatmat question***From:*Austin Nichols <[email protected]>

**Re: st: tabstatmat question***From:*"Alvarez,Sergio" <[email protected]>

**Re: st: tabstatmat question***From:*Austin Nichols <[email protected]>

- Prev by Date:
**Re: st: RE: Joint one-sided t** - Next by Date:
**Re: st: Package -ghansen- now available in SSC** - Previous by thread:
**Re: st: tabstatmat question** - Next by thread:
**Re: st: tabstatmat question** - Index(es):