[R] manova() with a data frame

Chuck Cleland ccleland at optonline.net
Sun Feb 15 20:55:19 CET 2004


   The details section of the help for lm() suggests the response 
should either be a numeric vector or a matrix.  And the help for 
aov() says:

"Fit an analysis of variance model by a call to 'lm' for each 
stratum."

hope this helps,

Chuck Cleland

Michael Friendly wrote:
> I'm trying to learn to use manova(), and don't understand why none of 
> the following work:
> 
>  > data(iris)
>  > fit <- manova(~ Species, data=iris)
> Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
>        incompatible dimensions
>  > fit <- manova(iris[,1:4] ~ Species, data=iris)
> Error in model.frame(formula, rownames, variables, varnames, extras, 
> extranames,  :
>        invalid variable type
>  >
>  > YY <- iris[,1:4]
>  > species <- iris[,5]
>  > fit <- manova(YY ~ species)
> Error in model.frame(formula, rownames, variables, varnames, extras, 
> extranames,  :
>        invalid variable type
> 
> It does work if I coerce YY to a matrix:
> 
>  > fit <- manova(as.matrix(YY) ~ species)
> 
> But, ?manova gives no details, and just points to ?aov which says
> 
>     aov(formula, data = NULL, projections = FALSE, qr = TRUE,
>         contrasts = NULL, ...)
> 
> Arguments:
> 
> formula: A formula specifying the model.
> 
>    data: A data frame in which the variables specified in the formula
>          will be found. If missing, the variables are searched for in
>          the standard way.
>   ...
> 
> If this is not a bug, perhaps the documentation needs to be  clearer.  
> The only example for
> manova() is found in  ?summary.manova.  (It would also help if 
> model.frame returned
> something to indicate which variable had an invalid type.)

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894




More information about the R-help mailing list