# Logistic regression - overview

This page offers structured overviews of one or more selected methods. Add additional methods for comparisons by clicking on the dropdown button in the right-hand column. To practice with a specific method click the button at the bottom row of the table

Logistic regression
Spearman's rho
Two way ANOVA
Independent variablesIndependent variableIndependent variables
One or more quantitative of interval or ratio level and/or one or more categorical with independent groups, transformed into code variablesOne of ordinal levelTwo categorical, the first with $I$ independent groups and the second with $J$ independent groups ($I \geqslant 2$, $J \geqslant 2$)
Dependent variableDependent variableDependent variable
One categorical with 2 independent groupsOne of ordinal levelOne quantitative of interval or ratio level
Null hypothesisNull hypothesisNull hypothesis
Model chi-squared test for the complete regression model:
• $\beta_1 = \beta_2 = \ldots = \beta_K = 0$
Wald test for individual regression coefficient $\beta_k$:
• $\beta_k = 0$
or in terms of odds ratio:
• $e^{\beta_k} = 1$
Likelihood ratio chi-squared test for individual regression coefficient $\beta_k$:
• $\beta_k = 0$
or in terms of odds ratio:
• $e^{\beta_k} = 1$
in the regression equation $\ln \big(\frac{\pi_{y = 1}}{1 - \pi_{y = 1}} \big) = \beta_0 + \beta_1 \times x_1 + \beta_2 \times x_2 + \ldots + \beta_K \times x_K$
$\rho_s = 0$
$\rho_s$ is the unknown Spearman correlation in the population.

In words:
there is no monotonic relationship between the two variables in the population
ANOVA $F$ tests:
• For main and interaction effects together (model): no main effects and interaction effect
• For independent variable A: no main effect for A
• For independent variable B: no main effect for B
• For the interaction term: no interaction effect between A and B
We could also perform $t$ tests for specific contrasts and multiple comparisons, just like we did with one way ANOVA. However, this is more advanced stuff.
Alternative hypothesisAlternative hypothesisAlternative hypothesis
Model chi-squared test for the complete regression model:
• not all population regression coefficients are 0
Wald test for individual $\beta_k$:
• $\beta_k \neq 0$
or in terms of odds ratio:
• $e^{\beta_k} \neq 1$
If defined as Wald $= \dfrac{b_k}{SE_{b_k}}$ (see 'Test statistic'), also one sided alternatives can be tested:
• right sided: $\beta_k > 0$
• left sided: $\beta_k < 0$
Likelihood ratio chi-squared test for individual $\beta_k$:
• $\beta_k \neq 0$
or in terms of odds ratio:
• $e^{\beta_k} \neq 1$
Two sided: $\rho_s \neq 0$
Right sided: $\rho_s > 0$
Left sided: $\rho_s < 0$
ANOVA $F$ tests:
• For main and interaction effects together (model): there is a main effect for A, and/or for B, and/or an interaction effect
• For independent variable A: there is a main effect for A
• For independent variable B: there is a main effect for B
• For the interaction term: there is an interaction effect between A and B
AssumptionsAssumptionsAssumptions
• In the population, the relationship between the independent variables and the log odds $\ln (\frac{\pi_{y=1}}{1 - \pi_{y=1}})$ is linear
• The residuals are independent of one another
• Variables are measured without error
Also pay attention to:
• Multicollinearity
• Outliers
Sample of pairs is a simple random sample from the population of pairs. That is, pairs are independent of one another

Note: this assumption is only important for the significance test, not for the correlation coefficient itself. The correlation coefficient itself just measures the strength of the monotonic relationship between two variables.
• Within each of the $I \times J$ populations, the scores on the dependent variable are normally distributed
• The standard deviation of the scores on the dependent variable is the same in each of the $I \times J$ populations
• For each of the $I \times J$ groups, the sample is an independent and simple random sample from the population defined by that group. That is, within and between groups, observations are independent of one another
• Equal sample sizes for each group make the interpretation of the ANOVA output easier (unequal sample sizes result in overlap in the sum of squares; this is advanced stuff)
Test statisticTest statisticTest statistic
Model chi-squared test for the complete regression model:
• $X^2 = D_{null} - D_K = \mbox{null deviance} - \mbox{model deviance}$
$D_{null}$, the null deviance, is conceptually similar to the total variance of the dependent variable in OLS regression analysis. $D_K$, the model deviance, is conceptually similar to the residual variance in OLS regression analysis.
Wald test for individual $\beta_k$:
The wald statistic can be defined in two ways:
• Wald $= \dfrac{b_k^2}{SE^2_{b_k}}$
• Wald $= \dfrac{b_k}{SE_{b_k}}$
SPSS uses the first definition

Likelihood ratio chi-squared test for individual $\beta_k$:
• $X^2 = D_{K-1} - D_K$
$D_{K-1}$ is the model deviance, where independent variable $k$ is excluded from the model. $D_{K}$ is the model deviance, where independent variable $k$ is included in the model.
$t = \dfrac{r_s \times \sqrt{N - 2}}{\sqrt{1 - r_s^2}}$
where $r_s$ is the sample Spearman correlation and $N$ is the sample size. The sample Spearman correlation $r_s$ is equal to the Pearson correlation applied to the rank scores.
For main and interaction effects together (model):
• $F = \dfrac{\mbox{mean square model}}{\mbox{mean square error}}$
For independent variable A:
• $F = \dfrac{\mbox{mean square A}}{\mbox{mean square error}}$
For independent variable B:
• $F = \dfrac{\mbox{mean square B}}{\mbox{mean square error}}$
For the interaction term:
• $F = \dfrac{\mbox{mean square interaction}}{\mbox{mean square error}}$
Note: mean square error is also known as mean square residual or mean square within
n.a.n.a.Pooled standard deviation
--\begin{aligned} s_p &= \sqrt{\dfrac{\sum\nolimits_{subjects} (\mbox{subject's score} - \mbox{its group mean})^2}{N - (I \times J)}}\\ &= \sqrt{\dfrac{\mbox{sum of squares error}}{\mbox{degrees of freedom error}}}\\ &= \sqrt{\mbox{mean square error}} \end{aligned}
Sampling distribution of $X^2$ and of the Wald statistic if H0 were trueSampling distribution of $t$ if H0 were trueSampling distribution of $F$ if H0 were true
Sampling distribution of $X^2$, as computed in the model chi-squared test for the complete model:
• chi-squared distribution with $K$ (number of independent variables) degrees of freedom
Sampling distribution of the Wald statistic:
• If defined as Wald $= \dfrac{b_k^2}{SE^2_{b_k}}$: approximately a chi-squared distribution with 1 degree of freedom
• If defined as Wald $= \dfrac{b_k}{SE_{b_k}}$: approximately a standard normal distribution
Sampling distribution of $X^2$, as computed in the likelihood ratio chi-squared test for individual $\beta_k$:
• chi-squared distribution with 1 degree of freedom
Approximately a $t$ distribution with $N - 2$ degrees of freedomFor main and interaction effects together (model):
• $F$ distribution with $(I - 1) + (J - 1) + (I - 1) \times (J - 1)$ (df model, numerator) and $N - (I \times J)$ (df error, denominator) degrees of freedom
For independent variable A:
• $F$ distribution with $I - 1$ (df A, numerator) and $N - (I \times J)$ (df error, denominator) degrees of freedom
For independent variable B:
• $F$ distribution with $J - 1$ (df B, numerator) and $N - (I \times J)$ (df error, denominator) degrees of freedom
For the interaction term:
• $F$ distribution with $(I - 1) \times (J - 1)$ (df interaction, numerator) and $N - (I \times J)$ (df error, denominator) degrees of freedom
Here $N$ is the total sample size
Significant?Significant?Significant?
For the model chi-squared test for the complete regression model and likelihood ratio chi-squared test for individual $\beta_k$:
• Check if $X^2$ observed in sample is equal to or larger than critical value $X^{2*}$ or
• Find $p$ value corresponding to observed $X^2$ and check if it is equal to or smaller than $\alpha$
For the Wald test:
• If defined as Wald $= \dfrac{b_k^2}{SE^2_{b_k}}$: same procedure as for the chi-squared tests. Wald can be interpret as $X^2$
• If defined as Wald $= \dfrac{b_k}{SE_{b_k}}$: same procedure as for any $z$ test. Wald can be interpreted as $z$.
Two sided:
Right sided:
Left sided:
• Check if $F$ observed in sample is equal to or larger than critical value $F^*$ or
• Find $p$ value corresponding to observed $F$ and check if it is equal to or smaller than $\alpha$
Wald-type approximate $C\%$ confidence interval for $\beta_k$n.a.n.a.
$b_k \pm z^* \times SE_{b_k}$
where $z^*$ is the value under the normal curve with the area $C / 100$ between $-z^*$ and $z^*$ (e.g. $z^*$ = 1.96 for a 95% confidence interval)
--
Goodness of fit measure $R^2_L$n.a.Effect size
$R^2_L = \dfrac{D_{null} - D_K}{D_{null}}$
There are several other goodness of fit measures in logistic regression. In logistic regression, there is no single agreed upon measure of goodness of fit.
-
• Proportion variance explained $R^2$:
Proportion variance of the dependent variable $y$ explained by the independent variables and the interaction effect together:
\begin{align} R^2 &= \dfrac{\mbox{sum of squares model}}{\mbox{sum of squares total}} \end{align} $R^2$ is the proportion variance explained in the sample. It is a positively biased estimate of the proportion variance explained in the population.

• Proportion variance explained $\eta^2$:
Proportion variance of the dependent variable $y$ explained by an independent variable or interaction effect:
\begin{align} \eta^2_A &= \dfrac{\mbox{sum of squares A}}{\mbox{sum of squares total}}\\ \\ \eta^2_B &= \dfrac{\mbox{sum of squares B}}{\mbox{sum of squares total}}\\ \\ \eta^2_{int} &= \dfrac{\mbox{sum of squares int}}{\mbox{sum of squares total}} \end{align} $\eta^2$ is the proportion variance explained in the sample. It is a positively biased estimate of the proportion variance explained in the population.

• Proportion variance explained $\omega^2$:
Corrects for the positive bias in $\eta^2$ and is equal to:
\begin{align} \omega^2_A &= \dfrac{\mbox{sum of squares A} - \mbox{degrees of freedom A} \times \mbox{mean square error}}{\mbox{sum of squares total} + \mbox{mean square error}}\\ \\ \omega^2_B &= \dfrac{\mbox{sum of squares B} - \mbox{degrees of freedom B} \times \mbox{mean square error}}{\mbox{sum of squares total} + \mbox{mean square error}}\\ \\ \omega^2_{int} &= \dfrac{\mbox{sum of squares int} - \mbox{degrees of freedom int} \times \mbox{mean square error}}{\mbox{sum of squares total} + \mbox{mean square error}}\\ \end{align} $\omega^2$ is a better estimate of the explained variance in the population than $\eta^2$. Only for balanced designs (equal sample sizes).

• Proportion variance explained $\eta^2_{partial}$: \begin{align} \eta^2_{partial\,A} &= \frac{\mbox{sum of squares A}}{\mbox{sum of squares A} + \mbox{sum of squares error}}\\ \\ \eta^2_{partial\,B} &= \frac{\mbox{sum of squares B}}{\mbox{sum of squares B} + \mbox{sum of squares error}}\\ \\ \eta^2_{partial\,int} &= \frac{\mbox{sum of squares int}}{\mbox{sum of squares int} + \mbox{sum of squares error}} \end{align}
n.a.n.a.ANOVA table
--
n.a.n.a.Equivalent to
--OLS regression with two, categorical independent variables and the interaction term, transformed into $(I - 1)$ + $(J - 1)$ + $(I - 1) \times (J - 1)$ code variables.
Example contextExample contextExample context
Can body mass index, stress level, and gender predict whether people get diagnosed with diabetes?Is there a monotonic relationship between physical health and mental health?Is the average mental health score different between people from a low, moderate, and high economic class? And is the average mental health score different between men and women? And is there an interaction effect between economic class and gender?
SPSSSPSSSPSS
Analyze > Regression > Binary Logistic...
• Put your dependent variable in the box below Dependent and your independent (predictor) variables in the box below Covariate(s)
Analyze > Correlate > Bivariate...
• Put your two variables in the box below Variables
• Under Correlation Coefficients, select Spearman
Analyze > General Linear Model > Univariate...
• Put your dependent (quantitative) variable in the box below Dependent Variable and your two independent (grouping) variables in the box below Fixed Factor(s)
JamoviJamoviJamovi
Regression > 2 Outcomes - Binomial
• Put your dependent variable in the box below Dependent Variable and your independent variables of interval/ratio level in the box below Covariates
• If you also have code (dummy) variables as independent variables, you can put these in the box below Covariates as well
• Instead of transforming your categorical independent variable(s) into code variables, you can also put the untransformed categorical independent variables in the box below Factors. Jamovi will then make the code variables for you 'behind the scenes'
Regression > Correlation Matrix
• Put your two variables in the white box at the right
• Under Correlation Coefficients, select Spearman
• Under Hypothesis, select your alternative hypothesis
ANOVA > ANOVA
• Put your dependent (quantitative) variable in the box below Dependent Variable and your two independent (grouping) variables in the box below Fixed Factors
Practice questionsPractice questionsPractice questions