Binary Logistic Regression



Multiple linear regression is a statistical technique used to predict a continuous dependent variable from multiple independent variables.

The general equation for multiple linear regression, when we have k number of independent variables, is

Y = β0 + β1*X1 + β2*X2 + ......βk*Xk

Where,
Y = Dependent variable (continuous)
β0 = intercept or constant. It is the value of Y, when all X (independent) variables are 0.
β1 = regression coefficient for independent variable 1.
X1 = Value of first independent variable.
β2 = regression coefficient for independent variable 2.
X2 = Value of second independent variable.



However, when dependent variable is not continuous, but binary (a categorical variable having only two possible values: 0 or 1), Binary Logistic Regression (BLR) is the technique to predict the dependent (outcome) variable. The difference in regression equations in MLR and BLR is given below.

MLR:      Y = β0 + β1*X1 + β2*X2 + ......βk*Xk

BLR:     LN(P/(1-P)) = β0 + β1*X1 + β2*X2 + ......βk*Xk

Please note the difference in the formula, with respect to the left side of the equation. In MLR the continuous variable can be directly estimated using the MLR regression equation.

In BLR, the left side is LN(P/(1-P)),

Here P = Probability of event, hence (1 - P) = Probability of no event.

P/(1-P) is ratio of probability of event to non-event. It is also called "odds" of the event. LN stands for "Natural Logarithm".

So, LN(P/(1-P)) = Log Odds, also called as logit.

So, BLR gives the logit for given set of independent variables. From logit, we can easily calculate probability of event. If this probability is equal to or more than 0.5 (or any specified cut-off value), the prediction of event is made. If this probability is less the cut-off value, then prediction of no-event is made.

A question may arise here, why we can not use P in the left side of the BLR equation. Why we need to use logit? The answer is that there are only two possible values for dependent variable (0 or 1). Also P, being probability, must have a value between 0 and 1. However, right side  of equation may give a value less than 0 or more than 1. Such probability values are invalid and impossible to interpret. We want something which can take any value, and can be converted to valid probabiity value, between 0 and 1. This requirement is fulfilled by log odds, which can take any value, and which can be converted back into valid probability value.

Example: Dependent variable is DM (1 for presence of diabetes and 0 for its absence). There are only two independent variables. RBSL_1 (Random BSL) and SBP_1 (systolic BP). N=237

You can copy the data from excel file (along with heading row) and paste into the textbox. Automatically the data is shown in the tabular format. You need not to create dummy variables for categorical independent variables. These will be automatically calculated by the software. Alphabetically, first category is treated as reference category, and for other categories, dummy variables are created.

You can click on "Select dependent and independent variables", to open a popup, wherein you can select a dependent and independent varibles. After filling all the required input, you can click on "Run BLR" to get the output.


Results and their interpretations

There are self-explanatory descriptive tables, showing the mean, SD of continuous independent variables, and number of categories in categorical independent variables and also number of events and non-events in dependent variables,

BLR output has following tables.


Omnibus test of model Coefficients
Model Chi-squaredegree of freedomp
Enter: All IDV Simultaneously173.855120

Above table shows the Omnibus test of model coefficients. If the p value is significant, it means that the given predictors can predict the outcome significantly better than than the null model (without any predictors). Under null model, every outcome is predicted as Yes, if probablity of "Yes" in given dataset is more than probablity of "No". It simply means, every outcome is predicted as "Yes", if "Yes" (1) are more in number than "No" (0).  Needless to say that under Null model, every outcome will be prdicted as "No", if number of "No" are more than number of "Yes" in the dataset.
So, if p is significant, it means adding predictors in the model can significantly improve the prediction of outcome variable.
Model Summary
Model: Enter - 2 Log Likelihood Cox & Snell R SquareNagelkerke R SquareMcFadden R Square
Enter: All IDV Simultaneously153.98320.51980.69380.5303

These psuedo R squared values can be considered as equivalent to R squared value in linear regression. These psuedo R squared values tell us about the approximate variance in outcome that can be explained by the given predictors. 
Independent variables in the equation and coefficients
IDV Coefficients (β) Standard ErrorWald df p Adjusted OR (Exp(B)) Confidence Interval*
LB of Exp(β) UB of Exp(β)
Constant-14.66052.952524.655310000.0001
RBSL_10.06950.009751.3288101.0721.05181.0926
SBP_10.01310.01640.644610.42211.01320.98121.0463
* (100 - Significance level)% Confidence interval
Above table gives the beta coefficients, their standard errors and significance for each of the coefficient. Significant p value for a coefficient means the coefficient is significantly different than 0. The table also gives te adjusted Odds Ratio and their confidence intervals for each of the predictor.
Here, Adj. OR = eβ
Below is the equation for the "logit". Logit = LN (Odds of Yes) = LN (P/(1-P)). LN = Log to base e. P= Probability of presence of the characteristic (1). Please note that (P/(1-P)) gives us the odds.
LN [P/(1-P)] = -14.6605 + 0.0695 * RBSL_1 + 0.0131 * SBP_1
Probability of presence of a characteristic (P) is given by following formula.
P = eLogit / (1 + eLogit)
Hosmer Lemeshow test of Goodness of fit.
Chi-square df p
22.074280.0048

Hosmer Lemeshow test compares the observed and expected probabilities in subgroups of the observations. Based on these observed and predicted probabilities Chi-square statistics is calculated using formula (O - E)2/E. Please note here that we want the observed and predicted probabilities to be equal to say that the model predicts the outcome correctly. So, we want O and E to be close to each other, and very small chi-square value. If chi-square is non-significant, our LR model is good.Otherwise, with significant p value, we can say that there is significant difference between observed and predicted observations.Hence, with significant p, model should be discarded.
Because of different number of observations in subgroups, the calculated chi-square value by different softwares can be slightly different. This is a major drawback of this test.
In above table, p is significant
-----------------------
Hosmer Lemeshow contigency table.
SubGroup Number of Observations in the SubGroup event = 0event = 1
Observed Expected Observed Expected
1242423.829800.1702
2242423.326500.6735
3242422.108201.8918
4241419.6185104.3815
5241615.58688.414
6241010.80531413.1947
724137.01521116.9848
82402.43182421.5682
92400.25442423.7456
102100.02432120.9757


Classification Table
Predicted Total Percentage Correct
1 0
Observed 1 931911283.0357
0 2010512584
Total 11312423783.5443

Above table shows the comparison between predicted outcomes by the model (based on cutoff of probability) and actual observed outcome in the data. It also calculates the overall correctness of the model.