[R] multivariate regression using R

Peter Dalgaard p.dalgaard at biostat.ku.dk
Fri Jul 8 00:35:10 CEST 2005

"Lusk, Jeffrey J" <jjlusk at purdue.edu> writes:

> Does anyone know if there is a way to run multivariate linear regression
> in R?  I tried using the lm function (e.g., lm(dv1, dv2~iv1+iv2+iv3),
> but got error messages.  Is my syntax wrong, or do I need a particular
> package?

You need a matrix response: lm(cbind(dv1,dv2)~iv1+iv2+iv3) should do.
There is an anova() method for comparing the resulting "mlm" objects.

And yes, your syntax is wrong: you're calling lm with 2 arguments, dv1
and dv2~iv1+iv2+iv3.

   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907

More information about the R-help mailing list