8

I'm trying to perform logistic regression to do classification using MATLAB. There seem to be two different methods in MATLAB's statistics toolbox to build a generalized linear model 'glmfit' and 'fitglm'. I can't figure out what the difference is between the two. Is one preferable over the other?

Here are the links for the function descriptions.

http://uk.mathworks.com/help/stats/glmfit.html http://uk.mathworks.com/help/stats/fitglm.html

Physman
  • 83
  • 1
  • 3

2 Answers2

7

The difference is what the functions output. glmfit just outputs a vector of the regression coefficients (and some other stuff if you ask for it). fitglm outputs a regression object that packs all sorts of information and functionality inside (See the docs on GeneralizedLinearModel class). I would assume the fitglm is intended to replace glmfit.

Dan
  • 45,079
  • 17
  • 88
  • 157
4

In addition to Dan's answer, I would like to add the following.

The function fitglm, like newer functions from the statistics toolbox, accepts more flexible inputs than glmfit. For example, you can use a table as the data source, specifyy a formula of the form Y ~ X1 + X2 + ..., and use categorical variables.

As a side note, the function lassoglm uses (depends on) glmfit.

Alex
  • 15,186
  • 15
  • 73
  • 127