# Predictions Logistic Regression model using fitglm

64 views (last 30 days)

Show older comments

I created a logistic regression model with four continuous variables as input, using the function fitglm for binary classification. The functions 'predict' and 'feval' say in their documentation that they are only for linear regression models, but when I apply them on my model they do work. I am unsure how to interpret the output. My questions are:

- Is the output of both predict and feval the probability that the sample belongs to the positive class?
- Is there a different function for model evaluation that is a better fit for my model?

My code:

mdl = fitglm(data,modelspec,'Distribution','binomial');

out = predict(mdl,testdata);

##### 0 Comments

### Accepted Answer

the cyclist
on 18 Oct 2021

I have a couple of comments, before answering your specific questions.

First, you might benefit by reading up a little bit on generalized linear models (e.g. on this wikipedia page). You seem to think your model is not linear, but it is. A logistic regression is a linear model -- because you use a linking function to make it so.

In particular, the word "linear" in linear regression refers to the coefficients, not the terms themselves. For example, fitting a model of the form

y = alpha + beta1*x + beta2*x.^2

would be a linear regression. It's linear in alpha and beta (not in x).

Fitting the model

y = a * exp(b*x)

is a non-linear model, because it is not linear in b.

Second, by virtue of the fact that you used fitglm, you have fit a linear model. Whether that was the most appropriate model for your data is impossible to know, without seeing your data. (That is basically the answer to your second question.)

The answer to your first question is in this section of the documentation for predict. I'm pretty sure that when you say "positive", you mean the same as "success" in the documentation, so the answer to your question is yes.

##### 3 Comments

Ive J
on 30 Oct 2021

### More Answers (0)

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!