You measured wage as a continuous outcome and want to know whether the slope of experience_years on wage is different for the two gender groups — a binary-by-continuous moderation (a "does the experience effect depend on gender?" test). In MCPower terms the model is wage ~ gender * experience_years, where * expands to gender + experience_years + gender:experience_years; the gender:experience_years term is the moderation you actually care about.

Variations

  • Swap the binary gender for a 3-level factor (e.g. sector with public / private / nonprofit): write wage ~ sector * experience_years and set sector=factor. The interaction then spans one slope-difference per non-reference level.
  • Make experience_years the moderator of a binary union membership instead — same gender * experience_years shape, just relabelled; the interpretation flips to "does the union wage premium grow with experience?".
  • Probe a stronger or weaker moderation by moving the gender:experience_years effect between the small / medium / large benchmarks (0.10 / 0.25 / 0.40) to bracket the sample size you'd need.
  • Add a nuisance covariate you must adjust for (e.g. + tenure) without letting it interact — keep gender * experience_years and append + tenure as a main effect only.
  • Same design, other fields:
    • Clinical: blood_pressure ~ treatment * baseline_bp — does the baseline slope on blood pressure differ between treatment arms?
    • Ecology: plant_biomass ~ habitat * rainfall — does habitat moderate the rainfall slope on plant biomass?

Not this setup?

If you'd rather have…

Copy-paste setup

from mcpower import MCPower

# Does the slope of `experience_years` on the outcome differ between the two
# `gender` groups? `gender * experience_years` expands to gender +
# experience_years + gender:experience_years, so the interaction term carries
# the moderation. gender is binary; experience_years is continuous.
model = MCPower("wage = gender * experience_years")
model.set_effects("gender=0.5, experience_years=0.25, gender:experience_years=0.2")
model.set_variable_type("gender=binary")

# Power for the interaction term — moderation is the question, so target it.
model.find_power(sample_size=300, target_test="gender:experience_years")
suppressMessages(library(mcpower))

# Does the slope of `experience_years` on the outcome differ between the two
# `gender` groups? `gender * experience_years` expands to gender +
# experience_years + gender:experience_years, so the interaction term carries
# the moderation. gender is binary; experience_years is continuous.
model <- MCPower$new("wage ~ gender * experience_years")
model$set_effects("gender=0.5, experience_years=0.25, gender:experience_years=0.2")
model$set_variable_type("gender=binary")

# Power for the interaction term — moderation is the question, so target it.
invisible(model$find_power(sample_size = 300, target_test = "gender:experience_years"))

The headline number is the power for gender:experience_years. Interaction terms are expensive — detecting a moderation needs a markedly larger sample than either main effect, so expect the interaction row to trail gender and experience_years. Drop target_test to "all" to see all three terms side by side, or switch to find_sample_size(...) to find the N that lands the interaction at 80% power.