Statalist


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

st: RE: ttest, signrank, ranksum with for each?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: ttest, signrank, ranksum with for each?
Date   Mon, 15 Dec 2008 14:40:21 -0000

The tests you mention are all based on an assumption of independent observations. Even though you are looking at differences, the question still remains whether that is consistent with your ideas about data generating process(es)? 

Nick 
[email protected] 

René Geppert

I have data for 2 groups. For the first group I have 6 quarters of 
observations, for the second group I have 2 quarters. 1. Q 2007 - 2. Q 
2008, and 1. Q 2008 - 2. Q 2008 respecively.
Data are in long format, like this.
Company - Year - Quarter - Variable1 - Group
abc corp - 2007 - 1 - 0.4 - 1
abc corp - 2007 - 2 - 0.1 - 1
abc corp - 2007 - 3 - 0.05 - 1
abc corp - 2007 - 4 - 0.11 - 1
abc corp - 2008 - 1 - 0.70 - 1
abc corp - 2008 - 2 - 0.0 - 1
def corp - 2008 - 1 - 0.1 - 0
def corp - 2008 - 2 - 0.8 - 0
ghi corp...and so on

I now want to perform difference in means and difference in medians tests 
for 'Variable1' for both, changes from quarter to quarter within each 
group (0 and 1) and differences among the groups within one quarter.
Similarly, I want to test for difference in medians using signrank for 
differences within one group across quarters and within one quarter 
across groups using ranksum.
So: What I basically want to examine is, have there been any significant 
changes in variable 1 between the quarters and between the groups?

Because multiple observations exist for 'Quarter', I cannot simply do a 
command like:
. ttest Variable1, by(Group) cuz this captures all the quarters at once
I tried nested if-criteria which doesn't work.
So I presume this might be possible using a for each command, anyone got 
an idea?


*
*   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/



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