If you have visited this page before and wish to skip the preamble, click here to go directly to the calculator. |
X: | gestational age of the infant (in weeks) at the time of birth [column (i)]; and
| Y: | whether the infant was breast feeding at the time of release from hospital ["no" coded as "0" and entered in column (ii); "yes" coded as "1" and entered in column (iii)] | |
(v) | the observed probability of Y=1 for each level of X, calculated as the ratio of the number of instances of Y=1 to the total number of instances of Y for that level;
| (vi) | the odds for each level of X, calculated as the ratio of the number of Y=1 entries to the number of Y=0 entries for each level, or alternatively as | |
observed probability (1 - observed probability) |
and
| (vii) | the natural logarithm of the odds for each level of X, designated as "log odds." | |
i | ii | iii | iv | v | vi | viiX | Instances of Y | Coded as Total | ii+iii Y as | Observed Probability Y as | Odds Y as | Log Odds 0 | 1 | 28 | 29 30 31 32 33 4 | 3 2 2 4 1 2 | 2 7 7 16 14 6 | 5 9 9 20 15 .3333 | .4000 .7778 .7778 .8000 .9333 .5000 | .6667 3.5000 3.5000 4.0000 14.0000 -.6931 | -.4055 1.2528 1.2528 1.3863 2.6391 |
A. Ordinary Linear Regression![]() | B. Logistic Regression![]() |
X | Observed Probability | Log Odds | Weight | C. Weighted Linear Regression of C. Observed Log Odds on X ![]() 28 | 29 30 31 32 33 .3333 | .4000 .7778 .7778 .8000 .9333 -.6931 | -.4055 1.2528 1.2528 1.3863 2.6391 6 | 5 9 9 20 15 For each level of X, the weighting factor is the number of observations for that level. |
Intercept=-17.2086 is the point on the Y-axis (log odds) crossed by the regression line when X=0. | Slope=.5934 is the rate at which the predicted log odds increases (or, in some cases, decreases) with each successive unit of X. Within the context of logistic regression, you will usually find the slope of the log odds regression line referred to as the "constant." The exponent of the slope exp(.5934) = 1.81 describes the proportionate rate at which the predicted odds changes with each successive unit of X. In the present example, the predicted odds for X=29 is 1.81 times as large as the one for X=28; the one for X=30 is 1.81 times as large as the one for X=29; and so on. |
log[odds] = -17.2086+(.5934x31) = 1.1868 |
odds = exp(log[odds]) = exp(1.1868)=3.2766 |
probability = odds/(1+odds)=3.2766/(1+3.2766) = .7662 |
![]() | ![]() |
X | Instances of Y Coded as | Enter the values of X into the designated cells. beginning with the top-most cell. Then, for each level of X, enter the number of instances coded as 0 and 1. When all values have been entered, click the «Calculate 1» button. Note that all entries in the "0" and "1" cells associated with an entered value of X must be positive integers greater than zero. If a zero is entered into any of these cells, it will be replaced by "1" and the adjacent cell will be incremented by 1. For an illustration of data entry, click here to enter the data described in the introductory example. 0 | 1 | |
intercept: | slope: | exp(slope): | R2: | |
X | Probabilities | OddsObserved | Predicted | Observed | Predicted | |
X | Predicted |
To calculate the predicted probability and odds for any particular value of X, enter X into the designated cell, then click the «Calculate 2» Button. Probability | Odds | |
Home | Click this link only if you did not arrive here via the VassarStats main page. |