In R
, the lm
function allows you to fit multiple, separate linear models simultaneously - from the documentation for lm
:
If response is a matrix a linear model is fitted separately by least-squares to each column of the matrix.
But how can you fit multiple separate models simultaneously for a GLM, e.g. for logistic regression?
glm.fit
requires the response y
to be a vector. If you give it a matrix in the y
argument, then it just uses the first column of the y
matrix and builds a single GLM model.