Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Specifying a repeated measures analysis in anova and xtmixed

From   Joseph Coveney <>
To   Statalist <>
Subject   Re: st: Specifying a repeated measures analysis in anova and xtmixed
Date   Tue, 02 Aug 2005 14:35:13 +0900

David Pieczkiewicz asked about setting up a mixed model with -anova-
and -xtmixed-.  There are two random effects (reader and case, which are
crossed) and one fixed effect (modality).  The dataset is balanced as to
representation at each level of fixed and random effects.

First excerpt:

"1) Using the anova command, I believe this is an appropriate
statement to examine the influence of modality on decision time:

anova lntime case modality reader modality*reader modality*case
reader*case, repeated(modality reader)"

If reader is random, then I doubt that you want to include it in
the -repeated()- option.  It's a little tricky specifying the error terms
when setting up -anova- with mixed models.  Take a look at Chapter 7
("Multifactor Experiments Having Repeated Measures on the Same Elements") of
B. J. Winer, D. R. Brown and K. M. Michels, _Statistical Principles in
Experimental Design_ Third Edition.  (New York:  McGraw-Hill, 1991).  I'm
not sure if it has exactly your design, but it might be a start.  One of the
SAS books-by-users might be helpful, here, too, e.g., R. C. Littel, G. A.
Milliken, W. W. Stroup & R. D. Wolfinger, _SAS System for Mixed Models_
(Cary:  SAS Institute, 1996); R. C. Littel, W. W. Stroup & R. J. Freund,
_SAS for Linear Models_ (2002).  Diehl Hall might have copies of them on the
monograph shelves.  If not, try thumbing though some issues of
_Investigative Radiology_ in the periodicals; the study design sounds 
exactly like
something that it'd have a tutorial on.

Second excerpt:

"2) If I wanted to analyze this as a mixed model, what is an
appropriate way to use xtmixed? I consider case and reader to be
random effects, as both are drawn from larger populations of possible
cases and readers. Likewise, I consider modality to be a fixed
factor, as there are only N modalities of interest in any particular
phase of my study. As such, I came up with the following as a rough
guess of how to express it:

xtmixed lntime modality || case: || reader:"

There's an example of syntax with crossed random effects in the help file
for -xtmixed-.  With a fixed effect in addition, I think that the syntax
would look more like that in the do-file below.

Joseph Coveney

set more off
set seed `=date("2005-08-02", "ymd")'
tempfile tmpfil0
set obs 20
generate byte patient_nr = _n
generate float patient_effect = invnorm(uniform())
save `tmpfil0', replace
set obs 20
generate byte physician_nr = _n
generate float physician_effect = invnorm(uniform())
cross using `tmpfil0'
erase `tmpfil0'
forvalues i = 1/3 {
    generate float log_latency`i' = `i' / 40 + ///
      physician_effect + 2 * patient_effect + ///
      invnorm(uniform()) / 3
reshape long log_latency, i(patient_nr physician_nr) ///
xi: xtmixed log_latency i.display_method || ///
  _all: R.patient_nr || _all: R.physician_nr, nolrtest variance

*   For searches and help try:

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