0
$\begingroup$

I evaluated a logistic regression using mnrfit function in Matlab. However, I am not sure if I did this correctly, because my graph does not looks like standard logistic regression. The image below represent my logistic regression, there are 11 logistic regression curves, which represent the same variable with different parameters. My questions are:

1) why my 11 curves are not crossing in 'response' equal to 0.5, but around 0.25?

2) why my curves are not symmetrical to 'response' 0.5, why all of them are below 'response' 0.5, any why it is not possible to get 'response' equal to 1?

3) why some of my curves (the gray ones) have the opposite trend than the other ones (some of them with the increase of the 'analyzed variable' value have descending trend? Is it possible?

enter image description here

$\endgroup$
  • $\begingroup$ I'm not familiar with MATLAB but mnrfit documentation suggests that it is for fitting multinomial logistic regression, not a 'standard logistic regression' as you name it. Perhaps a confusion there? $\endgroup$ – Oğuzhan Öğreden Jul 8 '16 at 8:32
  • $\begingroup$ Thank you for your answer, by standard logistic regression I meant only the shape of the curve which you can find on images with logistic regression in the internet, like e.g here upload.wikimedia.org/wikipedia/commons/thumb/8/88/… $\endgroup$ – user122618 Jul 8 '16 at 9:08
  • 1
    $\begingroup$ Your model, what you mean with 'representing the same variable with different parameters' (How did you get more than one estimate for the same model?), what those grey dots represent are not clear to me. I may be off the mark: Considering the outlıne of the dots, I guess the inflection point is not at .25. Did you try plotting a wider range for X axis, perhaps [-1, 3] here? (Check the difference between the plot in the question and the accepted answer here.) $\endgroup$ – Oğuzhan Öğreden Jul 8 '16 at 10:23
  • 1
    $\begingroup$ If there are 11 different predictors and if you are fitting 11 models to get parameter estimates, you must have a very specific reason to do so otherwise don't do it. If you have any reason, why would the difference be surprising? Different predictors may have different relationships to the outcome. If there are 11 different data sets, i.e. both different predictor and a different outcome, why would you plot them on top of each other? And again, why the difference would be surprising? I'll post an answer to describe what I think is going on with the plot. $\endgroup$ – Oğuzhan Öğreden Jul 8 '16 at 13:02
  • 1
    $\begingroup$ My logistic regression curves, are related each other, therefore I plotted them on one figure. However, it is difficult to explain this on my data, so I will use an example from here en.wikipedia.org/wiki/Logistic_regression (scroll to: Example: Probability of passing an exam versus hours of study). Let say that I add one additional factor (a cup of coffee) which may influence on the results of the exam. So I would like to check if the probability in passing of the exam will increase if I will add all students: 1 cup of coffee, 2 cups of coffee, and so on. Is it now more clear? $\endgroup$ – user122618 Jul 8 '16 at 13:33
3
$\begingroup$

So here is what I think is going on with the plot may be something similar to this. Let's assume that this is how the predictor and outcome is related to each other:Relationship

If we happen to have a certain portion of this data and model that portion, our predictor and expected probabilities will look like this:

A portion of the data

Since I'm still not able to understand your thinking about 11 different models part, I'll have to skip that.

Edit after the comment: x-axis labels give the impression that I've just plotted selectively. However I've selected a portion of the data and fit a new model. y-axis of the second plot is the predicted probabilities of this new model and x-axis is the predictor. and the A similar case could have occured in practice due to sampling. Below is the R code, based on the code here:

set.seed(666)
# Let's say this is the way nature works:
x1 = rnorm(500)          
z1 = 1 + 5*x1        
pr1 = 1/(1+exp(-z))  
y1 = rbinom(500,1,pr)
# Fit a model: 
df = data.frame(y=y1,x1=x1)
model1 <- glm( y~x1,data=df,family="binomial")
plot(x1,model1$fitted.values,xlim=c(-2,2),xlab = NULL,ylab = NULL)

# Now let's assume that our observation was limited to this:
x2 <- x1[order(pr)][100:250]
y2 <- y[order(pr)][100:250]

# With the data we 'collected', let's fit a new model:
model2 <- glm(y2 ~ x2, family='binomial')
plot(x2, model2$fitted.values,xlim=c(-2,2),xlab=NULL,ylab=NULL)
$\endgroup$
  • $\begingroup$ I did not select a portion of my data. The curves are generated for the whole analyzed data set. $\endgroup$ – user122618 Jul 8 '16 at 13:55
  • 1
    $\begingroup$ (+1) It might help to simply consider the logistic regression equation $\operatorname{E} Y =\frac{1}{1+\mathrm{e}^{-(\beta_0+\beta_1 x)}}$ - how do plots look for different values of $ \beta_0$ & $\beta_1$ (& of course over different ranges of $x$)? Whether or how or why estimates of $\beta_0$ & $\beta_1$ might differ between the 11 regressions - or even whether each estimates a common parameter - is I think unanswerable given the current state of the question. $\endgroup$ – Scortchi - Reinstate Monica Jul 8 '16 at 14:31
  • 1
    $\begingroup$ @user122618: You might not have selected a portion of your data but Nature will have. If the chance of banging your head in any given week is a logistic function of your height, & the tallest man in your sample turns out to be 6'7" with a estimated chance of "only" 0.4, why would you be surprised? $\endgroup$ – Scortchi - Reinstate Monica Jul 8 '16 at 15:00
  • $\begingroup$ So you mean, that my logistic regression could be fine? I had a doubt, because everywhere in the internet the graphs with logistic regression are always passing through 'response' 0.5 and are symmetrical to this value, but mine not. However, your explanation fit the data which I have and are logic for me. So in general you mean, that with my data it is not possible to have high or even medium probability in predicting the dependence of analyzed phenomenon? $\endgroup$ – user122618 Jul 8 '16 at 15:13
  • $\begingroup$ The curve you've fitted will be perfectly symmetrical with an inflection point at a predicted response of 0.5. The observed values of your predictor may be strewn along that curve any-old-how. When people want to illustrate the shape of the logistic function they of course pick a suitable range on the x-axis over which to do so. $\endgroup$ – Scortchi - Reinstate Monica Jul 8 '16 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.