[R] Q about how to use Anova.mlm

John Fox jfox at mcmaster.ca
Fri Jan 30 03:23:23 CET 2009


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


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
> Behalf Of pgseye
> Sent: January-29-09 7:40 PM
> To: r-help at r-project.org
> Subject: [R] Q about how to use Anova.mlm
> 
> 
> 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
> --
> View this message in context: http://www.nabble.com/Q-about-how-to-use-
> Anova.mlm-tp21739443p21739443.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list