tunsmart / interactionR

An R package for full reporting of effect modification and interaction
GNU General Public License v3.0
19 stars 6 forks source link

Extension to non-binary exposures #2

Closed jeffbone closed 2 years ago

jeffbone commented 3 years ago

Hi there,

Thanks for the nice package! Really saves some time normally spent manipulating output.

Any plans or current functions to extend the calculations to non-binary exposures? I have a 5 level factor and would love to be able to be able to quickly get the RERI across each level.

Thanks again, Jeff

fengxiuming commented 2 years ago

I have the same question as before

tunsmart commented 2 years ago

Hello, @jeffbone @fengxiuming sorry I was away for a while. Unfortunately, there is no plan to extend the package to handle exposures with more than two levels. Exposures could have an arbitrary number of levels and it would be unnecessarily complicated to make the functions respond to that.

Importantly, this is not necessary since the data for the arbitrary level of exposures could be validly reduced to a series of binary exposure comparisons without any loss of information. Vanderweele and Knol states this better than I do (see Tyler J. VanderWeele and Mirjam J. Knol: A Tutorial on Interaction DOI 10.1515/em-2013-0005):

"For categorical exposures, to obtain estimates and confidence intervals for additive interaction one can restrict attention to two specific levels of each of the two variables and calculate measures of additive interaction using the code for binary exposures above. It is possible to proceed in this manner for each possible comparison of two levels of each of the two exposures. For example, if there were two categorical variables, A and B, and A had three levels (A1, A2, and A3) and B had four levels (B1, B2, B3, and B4), then one could assess additive interaction comparing A = A1 and A = A2 and B = B1 and B = B4 by ignoring the observations with A = A3 and also ignoring those with B = B2 or B = B3 and then using the code for binary exposures above. Suppose the name of the dataset with the categorical variables was mycatdata. We could then use the following SAS code: data mydata; set mycatdata; if A = ‘A1’ then g = 0; if A = ‘A2’ then g = 1; if B = ‘B1’ then e = 0; if B = ‘B4’ then e = 1; if A = ‘A1’ or A = ‘A2’; if B = ‘B1’ or B = ‘B4’; run; The code deletes the observations with A = A3 and those with B = B2 or B = B3 and creates a new dataset only with values of A which are A1 or A2 and with values of B which are B1 or B4. The code for additive interaction for binary exposures can then be used directly. We could similarly proceed with any other comparison. We could compare (A1,A2) and (B1,B2); or (A1,A2) and (B1,B3); or (A1,A3) and (B1,B2); and so on."

I hope that helps.

jeffbone commented 2 years ago

Thanks for your response. What you propose is a reasonable solution; although I think the ability to automate that within the package would be fantastic. I understand not wanting to spend the time on it though.

Thanks again for the package and response.

Take care, Jeff

fengxiuming commented 2 years ago

As the tunsmart commented [on 21 Nov 2021](https://github.com/epi zen/interactionR/issues/2#issuecomment-974696015) "For categorical exposures, It is possible to proceed in this manner for each possible comparison of two levels of each of the two exposures. For example, if there were two categorical variables, A and B, and A had three levels (A1, A2, and A3) and B had four levels (B1, B2, B3, and B4), then one could assess additive interaction comparing A = A1 and A = A2 and B = B1 and B = B4 by ignoring the observations with A = A3 and also ignoring those with B = B2 or B = B3 and then using the code for binary exposures above.

I still have a question about the addictive interaction about the categorical variables (>2). How could I compute a P value for the overall addictive interaction? I have read some paper which show the overall addictive interaction, such as "Genetic Factors, Adherence to Healthy Lifestyle Behavior, and Risk of Invasive Breast Cancer Among Women in the UK Biobank", and "Association of Lifestyle and Genetic Risk With Incidence of Dementia". As menthod in manuscript, The additive interaction between the modified HLI and the PRS in association with invasive breast cancer risk was assessed by testing whether the estimated joint effect (ie, relative risk) of the two exposures was greater than the sum of the individual effect estimates for the modified HLI and the PRS. The additive interaction was assessed as to whether the estimated joint effects of the HLS and PRS were greater than the sum of the individual effect estimates for these 2 variables. I do not quit understand how to compute a P value for the overall addictive interaction.