0

This dataset has the results of an experiment repeated three times. How do I fit a regression to a 3 column matrix Y for these three columns of data in R if these columns were named y1, y2, y3 in the dataframe I'm using? I'm struggling to understand how (or if) lm/glm can do this. Thanks!

enter image description here

1 Answers1

1

The method is to use cbind in conjunction with lm as follows:

# say your data is called `df`
multivariateModel = lm(cbind(y1, y2, y3) ~ ., data = df)

Now to properly compute a MANOVA for the model taking into account the multivariate distributions of the response variables you need the car package:

car::Manova(multivariateModel)

This will compute the correct "Type II Sum of Squares"

Dij
  • 1,318
  • 1
  • 7
  • 13