Chapter 26 Logistic Regression Analysis
Logistic regression analysis can be useful to obtain a model to predict a dichotomous dependent variable (als known as a binary or logical variable) as a function of one or more predictor variables and estimate how well that dependent variable can be predicted using the predictor variables.
26.1.1 Example dataset
From this dataset, this example uses variables
gender_bi as dependent variable (the participant’s gender) and
xtcUseDosePref (the MDMA dose a participant prefers in milligrams) and
weight_other (a participants’ weight in kilograms) as predictors.
26.2 Input: jamovi
In the “Analyses” tab, click the “Regression” button and from the menu that appears, in th e“Logistic Regression” section, select “2 Outcomes (Binomial)” as shown in Figure 26.1.
In the box at the left, select the dependent variable and move it to the box labelled “Dependent variable” using the button labelled with the rightward-pointing arrow as shown in Figure 26.2.
In the box at the left, select any continuous predictors and move them to the box labelled “Covariates” using the button labelled with the rightward-pointing arrow as shown in Figure 26.3. If there are categorical predictors, move them to the box labelled “Factors”.
The results will immediately be shown in the right-hand “Results” panel. You can scroll down to specify additional analyses, for example, to request more details about the regression coeffictents you can open the “Model Coefficients” section as shown in Figure 26.4.
For example, to order the odds ratios and their confidence intervals, check the corresponding check boxes as shown in Figure 26.5.
26.3 Input: R
26.3.1 R: base R
In base R, the
glm (generalized linear model) function can be called with argument
family = binomial(link = "logit") to perform a logistic regression. The
summary function can then be used to show the most important results.
26.3.2 R: rosetta
rosetta package, the
logRegr function wraps base R’s
glm function to present output similar to that provided by other statistics programs in one command.
With multiple predictors, if
collinearity=TRUE, collinearity diagnostics are ordered. If there is only one predictor, you can request a visualisation of the raw data, the (binned) means, and the logistic curve by using
26.4 Input: SPSS
In SPSS, the
REGRESSION command is used (don’t forget the period at the end (
.), the command terminator):
LOGISTIC REGRESSION VARIABLES gender_bi /METHOD = ENTER xtcUseDosePref + weight_other .
26.5 Output: jamovi
26.6 Output: R
26.6.1 R: base R
Call: glm(formula = gender_bi ~ xtcUseDosePref + weight_other, family = binomial(link = "logit"), data = pp15) Deviance Residuals: Min 1Q Median 3Q Max -2.5760 -0.7852 0.3836 0.7113 1.6096 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -6.615057 1.805922 -3.663 0.000249 *** xtcUseDosePref 0.017874 0.004902 3.646 0.000266 *** weight_other 0.070162 0.024616 2.850 0.004369 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: 162.31 on 134 degrees of freedom Residual deviance: 121.02 on 132 degrees of freedom (694 observations deleted due to missingness) AIC: 127.02 Number of Fisher Scoring iterations: 6
26.6.2 R: rosetta
## Warning in rosetta::logRegr(gender_bi ~ xtcUseDosePref + weight_other, data = ## pp15, : You requested a plot, but for now plots are only available for logistic ## regression analyses with one predictor.
26.6.3 Logistic regression analysis
|Formula:||gender_bi ~ xtcUseDosePref + weight_other|
|Cox & Snell R-squared:||.26|
Test for significance:
(of full model)
|ChiSq = 41.29, p < .001|
22.214.171.124 Predictions by the null model (71.11% correct)
126.96.36.199 Predictions by the tested model (80% correct)
188.8.131.52 Regression coefficients
(log odds values, called ‘B’ in SPSS)
|95% conf. int.||estimate||se||z||p|
184.108.40.206 Regression coefficients as odds ratios
(ORs, called ‘Exp(B)’ in SPSS)
|95% conf. int.||Odds Ratio point estimate|
26.7 Output: SPSS
The SPSS output still has to be added.