You measured a continuous outcome well_being and two continuous predictors, income and social_support. The question is not just whether each one matters on its own, but whether the slope of income changes across levels of social_support — a continuous-by-continuous interaction. As an MCPower formula that is well_being ~ income * social_support, where * expands to both main effects plus their product term (income + social_support + income:social_support). The test that carries the moderation hypothesis is the interaction coefficient income:social_support.

Variations

  • Test the whole model, not just the interaction. Swap target_test="income:social_support" for target_test="all" to get power for each main effect, the interaction, and the omnibus test in one run.
  • Weaker or stronger moderation. The interaction effect is the uncertain one — re-run with income:social_support=0.10 (small) or income:social_support=0.25 (medium) to see how quickly the required sample size moves.
  • Correlated predictors. Real moderators are rarely independent of the variable they moderate. Add set_correlations("corr(income, social_support)=0.3") to see how collinearity erodes power for the product term.
  • Find the N instead of the power. Replace the find_power call with find_sample_size(target_test="income:social_support", from_size=100, to_size=600, by=25) to sweep for the smallest sample that reaches 80% power on the interaction.
  • Same design, other fields:
    • Clinical: blood_pressure ~ dose * baseline_bp — does a drug's blood-pressure effect depend on the patient's baseline level?
    • Ecology: growth_rate ~ temperature * moisture — does the temperature effect on growth rate depend on soil moisture?

Not this setup?

If you'd rather have…

Copy-paste setup

from mcpower import MCPower

# Continuous-by-continuous moderation: does the effect of income on well_being depend on social_support?
# '*' expands to the two main effects plus their interaction (income + social_support + income:social_support).
model = MCPower("well_being = income * social_support")

# Standardised effects. Main effects are moderate; the interaction (the test of
# interest) is smaller, as moderation effects usually are.
model.set_effects("income=0.30, social_support=0.25, income:social_support=0.15")

# Power for the interaction term at N=200.
model.find_power(sample_size=200, target_test="income:social_support")
suppressMessages(library(mcpower))

# Continuous-by-continuous moderation: does the effect of income on well_being depend on social_support?
# '*' expands to the two main effects plus their interaction (income + social_support + income:social_support).
model <- MCPower$new("well_being ~ income * social_support")

# Standardised effects. Main effects are moderate; the interaction (the test of
# interest) is smaller, as moderation effects usually are.
model$set_effects("income=0.30, social_support=0.25, income:social_support=0.15")

# Power for the interaction term at N=200.
invisible(model$find_power(sample_size = 200, target_test = "income:social_support"))