dbaranger / InteractionPoweR

InteractionPoweR: Power analysis for interactions via simulation in R
GNU General Public License v3.0
19 stars 1 forks source link

moderator with class imbalance #3

Closed PhilipSpechler closed 2 years ago

PhilipSpechler commented 2 years ago

Hello, first off, thank you for sharing this excellent program! I want to see if I have power to test if the relationship between a continuous predictor (X1) and continuous outcome (Y) is moderated by a binary indicator variable (X2; any drug exposure). However, there is a high class imbalance on X2. For example, 600 exposure "cases" (coded 1) and 9,000 "controls" (coded 0). I am using the power_interaction function while setting k.x2=2 and N=9,600, but is it possible (or necessary?) to somehow adjust for that "zero-inflated" moderator? The function assures me I have plenty of power (presumably given the large overall N), but the imbalanced moderator and small inter-variable correlations makes me somewhat skeptical. I would appreciate any thoughts.

dbaranger commented 2 years ago

Hi! Very glad you're finding the package useful! For the class imbalance - you can set the skew of x2 using the skew.x2 flag in the interaction_power() function. So in your case, that would be skew.x2 = InteractionPoweR::binary.p2skew(p = c(600/9600))

If you want to use something different than a standard OLS regression to test your moderation, you can use the generate_interaction() function to simulate the data, and then apply your own analysis. (You would need to loop at least 1,000 times and then aggregate).

Let me know if that answers your question!