Search code examples
rregressionlogistic-regressionleast-squaresmle

Fit a Logit/Probit regression model in R using Maximum Likelihood


A simple question here:

I'd like to know if there is any function in R that can fit a logit/probit regression model using maximum likelihood method?

Currently, I'm using OLS method given by function glm (I hope it does use OLS method)... I read somewhere that probit/logit model with OLS method may have incidental parameter problem. So I'd like to try MLE method.

Thank you for your help in advance!


Solution

  • @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.