How to write an R formula for a multidimensional answer?

In R, I want to do some regression of a multivariate answer to all predictors, for a one-dimensional answer, I know that the formula is similar to

y~., this is to use all predictors for regression y, that if now I am faced with 100 answers, I can’t type 100 yi like y1+y2+y3...+y4~x since I use all predictors for regression of a multidimensional response ?

+8
r regression
source share
2 answers

In R, a multidimensional formula should use cbind() for your variable Y Thus, the formula will be:

 model <- lm(cbind(y1, y2, y3, y4)~x) 
+10
source share

This is relatively easy if y is a 100-column matrix. In this case, you are doing the same. For example:

 lm(y ~ x) 

will perform linear regression of y on the x columns.

+1
source share

All Articles