In R I want to do some regression on multivariate response on all predictors, for univariate response, I know the formula is like
y~.,
this is to use all predictors to regress y, what if now I face 100 response, I can not
type 100 yi like
y1+y2+y3...+y4~x
,
so how to use all predictors to regress multivariate response?
In R, the multivariate formula is to use cbind()
for your Y
variable. Thus, the formula would be:
model <- lm(cbind(y1, y2, y3, y4)~x)
That's relatively easy if y
is a matrix with 100 columns. In that case you do it the same way. For example:
lm(y ~ x)
will do a linear regression of y onto the columns of x
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With