Skip to main content
added 19 characters in body
Source Link
eithompson
  • 376
  • 1
  • 10

The coefficients you see in the glm() output are those in the following formulation:

$\log(\frac{p}{1-p}) = \beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2$

These coefficients do not correspond to probabilities of class membership: they are partial derivatives with respect toof the log-odds (logit) of your response variable being 1 with respect to your regressors. You can rearrange the above to give:

$\hat{p} = \frac{\exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}{1 + \exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}$

To see that this works, let's plug in CYL1=1 and SS1=0. Don't forget the intercept.

$\hat{p} = \frac{\exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)}{1 + \exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)} = 0.1$$\hat{p} = \frac{\exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)}{1 + \exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)} = \frac{\exp(-2.9 + 0.75)}{1 + \exp(-2.9 + 0.75)} = 0.1$

This gives us the bottom-right value in your table. Doing this for all four possibilities should give you the values in the table.

If you want to use predict() to predict the probabilities of future data, supply the type = "response" argument in order to have the output in this probability form. Otherwise, you will be given predicted log odds values.

The coefficients you see in the glm() output are those in the following formulation:

$\log(\frac{p}{1-p}) = \beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2$

These coefficients do not correspond to probabilities of class membership: they are partial derivatives with respect to the log-odds (logit) of your response variable being 1. You can rearrange the above to give:

$\hat{p} = \frac{\exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}{1 + \exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}$

To see that this works, let's plug in CYL1=1 and SS1=0. Don't forget the intercept.

$\hat{p} = \frac{\exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)}{1 + \exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)} = 0.1$

Doing this for all four possibilities should give you the values in the table.

If you want to use predict() to predict the probabilities of future data, supply the type = "response" argument in order to have the output in this probability form. Otherwise, you will be given predicted log odds values.

The coefficients you see in the glm() output are those in the following formulation:

$\log(\frac{p}{1-p}) = \beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2$

These coefficients do not correspond to probabilities of class membership: they are partial derivatives of the log-odds (logit) of your response variable being 1 with respect to your regressors. You can rearrange the above to give:

$\hat{p} = \frac{\exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}{1 + \exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}$

To see that this works, let's plug in CYL1=1 and SS1=0. Don't forget the intercept.

$\hat{p} = \frac{\exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)}{1 + \exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)} = \frac{\exp(-2.9 + 0.75)}{1 + \exp(-2.9 + 0.75)} = 0.1$

This gives us the bottom-right value in your table. Doing this for all four possibilities should give you the values in the table.

If you want to use predict() to predict the probabilities of future data, supply the type = "response" argument in order to have the output in this probability form. Otherwise, you will be given predicted log odds values.

Source Link
eithompson
  • 376
  • 1
  • 10

The coefficients you see in the glm() output are those in the following formulation:

$\log(\frac{p}{1-p}) = \beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2$

These coefficients do not correspond to probabilities of class membership: they are partial derivatives with respect to the log-odds (logit) of your response variable being 1. You can rearrange the above to give:

$\hat{p} = \frac{\exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}{1 + \exp(\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_3x_1x_2)}$

To see that this works, let's plug in CYL1=1 and SS1=0. Don't forget the intercept.

$\hat{p} = \frac{\exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)}{1 + \exp(-2.9 + 0.75*1 + 1.2*0 - .39*1*0)} = 0.1$

Doing this for all four possibilities should give you the values in the table.

If you want to use predict() to predict the probabilities of future data, supply the type = "response" argument in order to have the output in this probability form. Otherwise, you will be given predicted log odds values.