Help with logistic regression code glm() in R Studio vs SPSS

Hello, I am currently trying to learn how to run a logistic regression with three main effects and two interaction terms in R studio for a study while comparing my results to my mentor’s results in SPSS. However, we seem to be getting different results for some the main effects, but the same results for the interaction terms. I think that I am writing the glm() code wrong, but I am brand new to R and not sure how to fix it. Please know I have spent HOURS trying to figure this out… and could really use your help!

For this study, we are researching how gender (moderator: Gend) moderates the effect of people’s endorsement of sexual scripts (first predictor: sexualscriptendorsementsmean) and attitudes towards casual sex (second predictor: casualsexscore) on their desire to engage in consensual non-monogamy (outcome: desire.yes_no).
We also want to run a second model with the same moderator and predictors, but with actual engagement as the outcome (second outcome: engagement.yes_no).

I attached my R studio syntax and output.
We have the exact same Beta, std error, and wald z-stat for the main effect of gender and the two interaction terms, but our main effects of casual sex attitudes and sexual script endorsement are different. The same thing happens for our second model with the outcome of engagement, to a greater extent as my output shows results for the main effects of casual sex and sexual scripts that are not significant but they are significant for the SPSS output.

Here is the SPSS Output for reference:
SPSS_output_desire to engage outcome

And SPSS syntax

@NinaDours a common issue with comparing results between software packages is that they use different default contrasts for categorical variables. In the SPSS results it appears that Gender is coded as -0.5 and 0.5, a
"sum to zero" contrast. The default contrast in R for a categorical variable is a "Treatment contrast", which would code gender as 0 and 1. You can change the contrast pretty easily, something like:

test <- data.frame(Gender = factor(sample(c("man","woman"), size = 10, replace = TRUE)))
#>    Gender
#> 1     man
#> 2     man
#> 3   woman
#> 4   woman
#> 5   woman
#> 6     man
#> 7     man
#> 8     man
#> 9     man
#> 10    man
#>       woman
#> man       0
#> woman     1
contrasts(test$Gender) <- c(-0.5, 0.5)
#>       [,1]
#> man   -0.5
#> woman  0.5

Created on 2021-07-21 by the reprex package (v2.0.0)

Then rerun the glm and see if that gives you answers closer to the results you're expecting.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.