Skip to content

Q about how to use Anova.mlm

6 messages · John Fox, pgseye

#
Hi,

Am newish to stats and R, so I certainly appreciate any help. Basically I
have 50 inidividuals whom I have 6 photos each of their optic nerve head. I
want to check that the orientation of the nerve head is consistent, ie the 6
replicates show minimal or preferably no rotation differences. I'll draw an
arbitrary line between some blood vessels (same reference in each set of
replicates) and determine an angle of deviation from the vertical and that
angle will be my dependent variable.

Subject	  Replicate	  Angle of Deviation
1		       1		       x
1		       2		       x
1		       3		       x
1		       4		       x
1		       5		       x
1		       6		       x
2		       1		       x
2		       2		       x
2		       3		       x
2		       4		       x
2		       5		       x
2		       6		       x
etc            

I'm wanting to test for Sphericity (because I've read that you should - is
this routine in a repeated measures ANOVA?) and can see that Anova.mlm in
the CAR package offers this in addition to the alternative Greenhouse and
Feldt tests.

I just don't really know how to perform the test - can someone give me some
help.

Thank you.

Paul

Dept of Ophthalmology
Uni Melbourne, Australia
#
Dear Paul,

First, to fit a multivariate linear model to your data, you'll have to
rearrange the data from "long" format (with one observation per replicate)
to "wide" format (with one observation per subject). If your data are in the
data frame Data, then you'd do something like:

Wide <- reshape(Data, v.names="Angle", idvar="Subject", timevar="Replicate",
direction="wide")

Then, with the data in wide format, fit a multivariate linear model with
just a constant:

mod <- lm(cbind(Angle.1, Angle.2, Angle.3, Angle.4, Angle.5, Angle.6) ~ 1,
data=DavisThin)

Finally, use Anova() to get the tests:

idata <- data.frame(Replicate=c("Angle.1", "Angle.2", "Angle.3", "Angle.4",
"Angle.5", "Angle.6"))
summary(Anova(mod, idata=idata, idesign=~Replicate))

If I understand correctly what you want, this should give it to you.

As well, since your design has no between-subject factors and only a single
within-subject factor, you could also use anova() [i.e., anova.mlm()] to get
the same results.

I hope this helps,
 John

------------------------------
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
web: socserv.mcmaster.ca/jfox
On
I
6
an
some
http://www.R-project.org/posting-guide.html
#
Dear Paul,

I noticed a typo in my response and some poor formatting in the email
message; please see below:
On
the
timevar="Replicate",
The data argument should be data=Wide (I adapted the code from an example I
already had and neglected to change the argument).
"Angle.4",
Note that this is indeed two separate commands; they were apparently run
together by my mailer.

Regards,
 John
single
get
I
head.
the
that
is
in
and
http://www.R-project.org/posting-guide.html
#
Thanks a lot for that John - really helpful. I generated some random numbers
and seem to be able to get it to work, so that's great.

One thing - it's come up with a 'Type III' test and given me a few warnings.
What's the difference between Type II and Type III tests (if there's some
basic guide you can point me to).

Thank you again.

Best,

Paul
#
Dear Paul,
On
numbers
warnings.
The default for Anova() is "type-II" tests, but the computational approach
taken doesn't provide a test for the intercept, which is the only
between-subject term in the model; thus, a "type-III" test is substituted.
In a model with only an intercept, there is no distinction between the two
"types" of tests.

More generally, types II and III tests address different hypotheses in
models in which some terms are marginal to others. There's a brief
explanation in my R and S-PLUS Companion to Applied Regression (Wiley,
2002), which is the book associated with the car package in which Anova()
resides. There's a more complete discussion in my Applied Regression
Analysis and Generalized Linear Models, Second Edition (Sage, 2008). Neither
book, BTW, discusses repeated-measures models.

I hope this helps,
 John
http://www.R-project.org/posting-guide.html