@Maju116's comment is correct. glm()
doesn't use ordinary least squares, it uses iteratively reweighted least squares; as the linked Wikipedia article says
IRLS is used to find the maximum likelihood estimates of a generalized linear model
The default link for the binomial family is logit, so either glm(...,family=binomial)
or glm(...,family=binomial(link="logit"))
will fit logistic (logit) regression. glm(...,family=binomial(link="probit"))
will fit probit regression.
If you are currently using glm(...)
without an explicit family
argument, then you are assuming Gaussian errors, which does mean that you'll get the same answers as ordinary least squares (lm()
) (which are the maximum likelihood estimates for a data set with Gaussian (normally) distributed errors). For clarity and efficiency, it's generally best to use lm()
rather than glm()
with the default family when you want to do OLS.