Hi,
I have data which resembles the following:
Here, I have a group ID variable, and a variable of interest, v1. Essentially, I wish to perform the Runs Test (https://www.stata.com/manuals/rttest.pdf) on Stata, to test whether or not the sequence of v1 are serially independent, within group. As far as I could tell from the documentation, I am unable to combine that -runtest- command by group. Ideally, I would simply do something like:
which would be similar to how t-tests for different groups could be done. Unfortunately, the runtest does not seem to have this functionality. Is there an elegant way to do it? The brute-force method would be to do the test one group at a time, and store the results in either a separate dataset (or separate variable), by preserving, dropping all other groups, testing and then restoring.
Any insight on this is much appreciated!
Best,
CS
I have data which resembles the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(group v1) 1 1 1 0 1 1 1 0 1 1 2 1 2 0 2 1 2 1 2 1 end
Code:
by group: runtest v1
Any insight on this is much appreciated!
Best,
CS
Comment