Hello,

This is a partial repost of a question I asked here: https://www.statalist.org/forums/for...s-error-anyway. In my original post, the title only contained a reference to one of my two questions. Because that question was more related to technical Stata syntax, it did not attract attention from those who are more interested in statistics. It was suggested by another member in the comments section that I repost just the more statistical part of the question to gain appropriate attention. I apologize if this goes against any rules. I will be happy to remove it if so.


I'm new to using the anova command (it is not common in my field). A reviewer for a journal submission asked me to use ANOVA as a robustness test to my main specification. It likely will not go in the final version of the paper, but I need to run it correctly in order to appease the reviewer. My question is essentially whether I am correctly translating from the xtreg environment to the anova environment.


I have unbalanced panel data resulting from a lab experiment. Subjects are indexed by the variable SubjectID. Each subject participated in exactly 1 session, which are indexed by SessionID, meaning subjects are nested within sessions. Each subject plays the game multiple times, though not all subjects play it the same amount of times. The repetitions are indexed by Period. Thus, I use xtset SubjectID Period at the beginning of my code (both for my standard analysis and for the ANOVA analysis).

Essentially, we care about the marginal impact along one treatment dimension, “N” vs “D”. (I’ll limit the treatments used in the regression here to show a minimum working example. I can easily extrapolate from any answers received here.) The minimum working example of our main regression specification is
Code:
xtreg LiqPerc1_2_B TreatD if Agent==1 & TreatAV==1, re cluster(SessionID)
The independent variable TreatD is a dummy variable that equals one for observations in treatment D and zero for all others (that is, those in treatment N). Because there is also a constant, the coefficient estimate on TreatD tells us the marginal impact of switching from treatment N to treatment D, which is exactly what we’re examining. We use subject-level random effects and cluster our error terms at the session-level, as is standard in the literature. (We also tested for time trends, etc. and found nothing.)


My question is then how to translate that specification from the xtreg environment into its analogous anova environment. I’ve spent a lot of time reading through textbooks, Stata’s ANOVA help text, the examples provided in Stata’s r.pdf file, and various online forums, but I’m still struggling with this adaptation. I think I’ve correctly adapted it using the following specification, but I’m unsure:
Code:
anova LiqPerc1_2_B TreatD / Period SubjectID|SessionID if Agent==1 & TreatAV==1, repeated(SubjectID SessionID) bse(Period) grouping(SessionID)

I would greatly appreciate any help you can offer. Thank you!

Best,
Matt