I know about lm(y~. , data)
but I'm wondering about the opposite direction
If I want to put multiple y to lm function, how should I do that? Using for? loop?
My desired result is getting each p-value and beta value of Y. There is just one X.
lm
supports a matrix on the LHS of the formula:
f <- as.formula(sprintf("cbind(%s) ~ Species",
paste(names(iris)[names(iris) != "Species"], collapse = ", ")))
#cbind(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width) ~ Species
summary(lm(f, data = iris))