[R-lang] MANCOVA in R

Roger Levy rlevy at ling.ucsd.edu
Thu May 15 10:10:41 PDT 2008


Bruno Estigarribia wrote:
> Hello,
> 
> I posted this to the general R list but got no replies. I am not sure this
> is appropriate for r-lang: the data ARE linguistic but the question is
> general. Apologies if this is inappropriate.
> 
> I have subjects in 4 groups: X1, X2, X3, X4. There are 33 subjects in 
> group X1, 35 in X2, 31 in X3, and 46 in group X4. I have 7 continuous 
> response variables (actually integers, they are frequencies of functional
> morphemes, approximately normal) measured 
> for each subject: Y1 to Y7, and two continuous covariates C1, C2 (they 
> are both integers).
> I want to perform all pairwise comparisons for each response variable 
> between groups. I have searched for a way to do a MANCOVA in R to no 
> avail. I am familiar with summary.manova, and with Venables & Ripley 
> "Modern Applied Statistics With S" and Everitt's "An R and S-Plus 
> Companion to Multivariate Analysis". However, I am neither a 
> statistician nor a programmer so I am finding it hard to figure this 
> out. Can summary.manova be adapted to use covariates? What is the impact 
> of the unbalanced design? Can I adjust for multiple comparisons?
> Thank you

Hi Bruno,

I'm by no means an expert on MAN(C)OVA but here are my two cents:

(1) it seems to me that manova(), like aov(), just works perfectly fine 
if you give it continuous covariates instead of factors in a formula. 
For example, try the following code:

# generate random data
library(mvtnorm)
subj <- factor(rep(c("a","b","c","d","e","f","g","h","i","j"),10))
x <- rnorm(100)
beta1 <- 1
beta2 <- -0.7
b1 <- rnorm(10,sd=5)
b2 <- rnorm(10,sd=2)
mu <- cbind(x * beta1  + b1[subj],x * beta2 + b2[subj])
Y <- t(apply(mu, 1, function(x) rmvnorm(1, x, matrix(c(6,3,3,4),2,2))))
# fit the model & get results
fit <- manova(Y ~ x)
summary.manova(fit)
summary.aov(fit)

(2) unfortunately, manova() doesn't support multistratum analysis, so 
you cannot specify an Error() term in manova().  I don't know of any 
workaround for this -- does anyone else?

(3) I'm not sure I properly understood what you meant by "perform all 
pairwise comparisons for each response variable between groups", so if I 
misunderstood your question, please let me know!

Hope this helps.

Roger


-- 

Roger Levy                      Email: rlevy at ling.ucsd.edu
Assistant Professor             Phone: 858-534-7219
Department of Linguistics       Fax:   858-534-4789
UC San Diego                    Web:   http://ling.ucsd.edu/~rlevy



More information about the R-lang mailing list