My issue is with correctly specifying and interpreting interactions terms in a logistic regression. I have not found any threads that has addressed this. I hope my explanation of the issue is clear.
The data has two continuous independent variables (IV) called value and meters. There is no correlation between the two IVs. The two IVs are used to predict an outcome (yes=1, no=0). Here is the sample of the data where the IV have been normalized (min/max) not standardized:
#Sample of data
structure(list(outcome = c(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0),
value = c(0.368748949810643, 0.331407447619786, 0.229177168560239,
0.263652461643853, 0.398364289684232, 0.298408882340016,
0.337650419429472, 0.331407447619786, 0.298408882340016,
0.53519588455026, 0.131929634081714, 0.773617950805899, 0.279143562500808,
0.205788643736994, 0.386821900810423, 0.49966393940569, 0.300861478408107,
0.199409955148836, 0.28220688407202, 0.82296715653961, 0.140104954308685,
0.0167060891594608, 0.016857962697274, 0.0214141688316724,
0.0214141688316724, 0.0520926234699549, 0.0232366512854318,
0.180425762922176, 0.180425762922176, 0.0252110072770044,
0.0252110072770044, 0.0205029276047927, 0.0192879393022865,
0.0211104217560459, 0.0856566753266897, 0.0496626468649424,
0.0505738880918221, 0.0856566753266897, 0.0256666278904442,
0.0176173303863404, 0.0262741220416974, 0.0156429743947678,
0.0882288314139103, 0.0505738880918221, 0.0294634663357762,
0.0235403983610583, 0.0364270296121085, 0.174047074334018,
0.0906071063890289, 0.093877234479817, 0.106214535913245,
0.093877234479817, 0.174047074334018, 0.0362977755373738,
0.380608011167552, 0.0391833727558261, 0.0241478925123115,
0.0150354802435147, 0.0241478925123115, 0.0968953171248724,
0.0186804451510334, 0.0968953171248724, 0.0476882908733698,
0.0192879393022865, 0.111171429679321, 0.111171429679321,
0.0203510540669795, 0.0280966044954567, 0.0490551527136893,
0.0159467214703944, 0.111171429679321, 0.111171429679321,
0.0441951995036643, 0.0253628808148177, 0.119676347796864,
0.0399427404448925, 0.152177284888906, 0.175333152377629,
0.152177284888906, 0.122862460739075, 0, 0.0301097367094498,
0.322340274277147, 0, 0.322340274277147, 0.714161076427934,
0.776144867966963, 0.182170692931095, 0.150955833882663,
0.640583194385203, 0.0590788062093657, 0.080948595654478,
0.080948595654478, 0.0590788062093657, 0.329623741388447,
0.0747023924929233, 0.376743314332984, 0.736160119947781,
0.561059624904675, 0.151996329184278, 0.151996329184278,
0.228398412759962, 0.124348882598524, 0.0799048690009952,
0.775996225781018, 0.419403621699174, 0.229736192433466,
0.149766696395104, 0.389675184510192, 0.803792314552716,
0.526849302674267, 0.31728643995502, 0.225425569041064, 0.390864321997751,
0.149320769837269, 0.482130624167927, 0.146050641746481,
0.168198327452273, 0.578004834102395, 0.330515594504117,
0.39175617511342, 0.144266935515142, 0.395174945390153, 0.0969987203846601,
0.0825804283480037, 0.493873356857575, 0.304800496335647,
0.493873356857575, 0.129551359106596, 0.186629958509442,
0.117659984231003, 0.0510295087052619, 0.186629958509442,
0.500116328667261, 0.0739591815631988, 0.618732793051301,
0.280274535654736, 0.169338994661807, 0.169338994661807,
0.0984851422441092, 0.08035079555883, 0.0686080628691819,
0.105917251541355, 0.0977419313143847, 0.0977419313143847,
0.105917251541355, 0.0686080628691819, 0.426092520066695,
0.100566132847338, 0.359500820763375, 0.38476999237401, 0.116768131115333,
0.368865278477904, 0.0987824266159991, 0.440659454289296,
0.386405056419404, 0.171914382100896, 0.137726679333566,
0.0871883361122959, 0.397404578179327, 0.0934313079219822,
0.257532281205165, 0.0647433660346142, 0.169387464939832,
0.111862938979151, 0.0868910517404061, 0.0868910517404061,
0.284882443419029, 0.121673323251516, 0.238060154846382,
0.151104476068608, 0.0900125376452493, 0.151104476068608,
0.0900125376452493, 0.0934313079219822, 0.0536113588480877,
0.169387464939832, 0.0934313079219822, 0.293949616761668,
0.519885739397934, 0.293949616761668, 1, 0.29974666201352,
0.192278361575349, 0.904869000995256, 0.399188284410666,
0.212493698863857, 0.399188284410666, 0.212493698863857,
0.162103997828532, 0.105619967169465, 0.246086832887407,
0.162103997828532, 0.641475047500872, 0.0909043907609187,
0.146050641746481, 0.211007277004408, 0.211007277004408,
0.146050641746481, 0.0909043907609187), meters = c(0.0484629861982434,
0.187243831033041, 0.444123797574237, 0.402969468841489,
0.249874529485571, 0.201589293182769, 0.208030112923463,
0.0936323713927227, 0.124539941447093, 0.489115432873275,
0.737470723546633, 0.0249634044332915, 0.708071936428273,
0.621183605186115, 0.746340443329151, 0.683683605186115,
0.579360100376412, 0.478199498117942, 0.381038268506901,
0.231937473860309, 0.309859891258887, 0.0484368465077374,
0.388592639063153, 0.746340443329151, 1, 0.124289000418235,
0.444123797574237, 0.249874529485571, 0.182172731074864,
0.489115432873275, 0.68129443747386, 0.27258469259724, 0.821099958176495,
0.873640736093685, 0.818224592220828, 0.58202634880803, 0.689774153074028,
0.798044751150146, 0.122229192806357, 0.188153492262652,
0.0503973232956922, 0.240955667084902, 0.166771225428691,
0.0390004182350481, 0.708176495190297, 0.62107904642409,
0.731231702216646, 0.682951693851945, 0.579360100376412,
0.474356963613551, 0.44487139272271, 0.490276035131744, 0.658981597657884,
0.125470514429109, 0.174430154746968, 0.309859891258887,
0.0578209953994145, 0.428272689251359, 0.153805938937683,
0.0484368465077374, 0.388566499372647, 0.106780635717273,
0.161020493517357, 0.458995713090757, 0.305241896695943,
0.253798985780008, 0.521155897114178, 0.587812107904642,
0.126803638644918, 0.785105604349644, 0.772976787954831,
0.804448975324132, 0.643585319949812, 0.0888488080301129,
0.0245190296946884, 0.707810539523212, 0.68271643663739,
0.579360100376412, 0.658981597657884, 0.00595984943538269,
0.225533249686324, 0.334431200334588, 0.0484107068172313,
0.24017147636972, 0.130280217482225, 0.020310539523212, 0.721063362609787,
0.437134044332915, 0.252248013383522, 0.0705248849853618,
0.734159347553325, 0.680625261396905, 0.580719364282727,
0.64219991635299, 0.400564617314931, 0.486511919698871, 0.125941028858218,
0.115677017984107, 0.0879339188624007, 0.253816394813885,
0.280740276035132, 0.0514951902969469, 0.407831451275617,
0.244719782517775, 0.00627352572145546, 0.240798828941865,
0.403021748222501, 0.641468005018821, 0.579307820995399,
0.0271329987452949, 0.352833542450857, 0.371131325805102,
0.232590966122961, 0.169907988289419, 0.306043496445002,
0.439721873693015, 0.5193956503555, 0.0209117524048515, 0.915594939355918,
0.865066917607695, 0.541980342952739, 0.574498117942284,
0.265213299874529, 0.371340443329151, 0.233009201171058,
0.0144291091593476, 0.279642409033877, 0.0457967377666249,
0.239125888749477, 0.579464659138436, 0.60461104140527, 0.643820577164366,
0.486198243412798, 0.306775407779172, 0.402969468841489,
0.0230552070263488, 0.232852363028022, 0.0987557507319113,
0.168653283145128, 0.374921580928482, 0.307350480970305,
0.77258469259724, 0.742680886658302, 0.72150773734839, 0.624712463404433,
0.719730238393977, 0.685853199498118, 0.444322459222083,
0.522898368883312, 0, 0.135246758678377, 0.279642409033877,
0.779642409033877, 0.480133835215391, 0.216698034295274,
0.000365955667084908, 0.132214554579674, 0.277132998745295,
0.403021748222501, 0.582340025094103, 0.643820577164366,
0.773055207026349, 0.812996654119615, 0.0432873274780427,
0.857120451693852, 0.874947720618988, 0.781890422417399,
0.563101212881639, 0.594730238393977, 0.299822250104559,
0.339293182768716, 0.41159556670849, 0.268768297783354, 0.325805102467587,
0.156263069845253, 0.240276035131744, 0.00026139690506065,
0.119615223755751, 0.122072354663321, 0.0486721037222919,
0.145075282308657, 0.133364700961941, 0.197354663320786,
0.338927227101631, 0.394134253450439, 0.428115851108323,
0.476787954830615, 0.518925135926391, 0.563937682977834,
0.696152237557507, 0.724121706398996, 0.769500209117524,
0.787954830614806, 0.00595984943538269, 0.559807611877875,
0.515108741112505, 0.486198243412798, 0.393245503973233,
0.424822250104559, 0.476787954830615)), row.names = c(NA,
200L), class = "data.frame")
Separately, they are considered as main effects. When modelled separately, both have p-values < 0.05:
#IV = meters
model <- glm(outcome ~ meters, data = df, family= binomial)
summary(model)
#output
Call:
glm(formula = outcome ~ meters, family = binomial, data = df)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.94020 -0.24794 -0.02802 -0.00336 2.59098
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.7219 0.5013 3.435 0.000594 ***
meters -18.5005 3.6270 -5.101 0.000000338 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 169.084 on 199 degrees of freedom
Residual deviance: 77.371 on 198 degrees of freedom
AIC: 81.371
Number of Fisher Scoring iterations: 8
#IV: value
model <- glm(outcome ~ value, data = df, family= binomial)
summary(model)
#Output
Call:
glm(formula = outcome ~ value, family = binomial, data = df)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.4279 -0.5485 -0.4605 -0.4091 2.2572
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -2.5176 0.3282 -7.672 0.000000000000017 ***
value 3.0895 0.8801 3.511 0.000447 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 169.08 on 199 degrees of freedom
Residual deviance: 156.89 on 198 degrees of freedom
AIC: 160.89
Number of Fisher Scoring iterations: 4
The coefficients in both cases are correct in terms of the direction of change, where value is positive and meters is negative. Meaning, that meters represents "proximity" and value represents "exposure".
With that being said, together they actually have a conditional relationship, where the effect of value on the outcome (yes/no) is conditional to value's relationship with meters. In other words, the closer someone is in proximity (meters) to the exposure level (values), the more it will influence the outcome.
I have tried specifying this relationship:
model <- glm(outcome ~ value + meters + value*meters, data = df, family= binomial)
summary(model)
#output
Call:
glm(formula = outcome ~ value + meters + value * meters, family = binomial,
data = df)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.01741 -0.24157 -0.03552 -0.00525 2.43956
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.1481 0.7867 1.459 0.14448
value 1.9520 2.2231 0.878 0.37990
meters -14.7932 5.3112 -2.785 0.00535 **
value:meters -14.1441 18.6979 -0.756 0.44938
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 169.084 on 199 degrees of freedom
Residual deviance: 76.527 on 196 degrees of freedom
AIC: 84.527
Number of Fisher Scoring iterations: 8
However, I am not sure if my interpretation of this is correct. Value is no longer significant but meters still is and the interaction term is also not significant. My interpretation is that:
- When Value < 0, it will have less influence on the outcome but when Meters < 0, it will have influence on the outcome
- When Value > 0, it will have more influence on the outcome, but when Meters > 0, it will have less influence on the outcome
If this interpretation is correct, it is not what I am hoping to model. What I actually want to say, is:
- When Value > 0 and Meters < 0, it will have an influence on the outcome
- When Value < 0 and Meters > 0, it will have less influence on the outcome
Any help and clear explanation (in simple terms) would be immensely appreciated.
meters
is the distance from the ligth source ? What isvalue
? What is theoutcome
? $\endgroup$