I am have conducted some logistic regressions in R comparing an estimate of ancestry with some other variables. My advisor has asked me to do power analyses on these. I do not have the greatest background in statistics, and I need some help.

Each regression is fairly simple, it is just a logistic regression testing association with one variable in a subset of my data.

I have come across some calculators such as this https://rdrr.io/cran/WebPower/man/wp.logistic.html or https://webpower.psychstat.org/models/reg02/ and this https://www.dartmouth.edu/~eugened/power-samplesize.php

but I am very lost. How exactly do I calculate p0 and p1 or a minimum detectable odds ratio?

My ancestry values make up my x-axis (and range from 0 to 1), but none of my ancestry data points are 0 or 1. Are p0 and p1 based on the regression equation calculated by R, or my actual data?

I cannot seem to find a good tutorial for how to conduct these power analyses, so I am coming here for help.

CLARIFICATION My x-axis variable is a float measure of ancestry ranging from 0 and 1. I am testing whether various binary variables (absence or presence of traits, 0 or 1) are associated with ancestry. Our sample sizes are small, so we want to do a power analysis to determine how likely we could actually detect a true positive.

  • $\begingroup$ Can you add more detail around your data and what your research question is? $\endgroup$ Jan 6, 2022 at 1:48
  • $\begingroup$ @DemetriPananos, see update $\endgroup$
    – dnv89
    Jan 6, 2022 at 18:20
  • $\begingroup$ So is your outcome a float from 0 to 1? You call it your "x axis" variable but also say you want to measure the association between other binary variables and ancestry $\endgroup$ Jan 6, 2022 at 18:51
  • $\begingroup$ @DemetriPananos, I have a measure of ancestry for each individual in my dataset. This measure is a float between 0 and 1 (though none of the individuals I am testing are exactly 0 or exactly 1). I testing association between ancestry and presence/absence variables (e.g., did this individual have trait A or not). $\endgroup$
    – dnv89
    Jan 6, 2022 at 19:46

1 Answer 1


OK, so this should be fairly straight forward. Since the outcome (has trait, does not have trait) is a binary variable, you can use logistic regression with the ancestry variable as a predictor.

Because you have a fixed sample size, a better approach is to calculate power but rather to calculate what effects can be reasonable estimated with a specific statistical power. The formula for this is

$$ \pm \beta_{j}^{a}=\frac{z_{1-\alpha / 2}+z_{\gamma}}{\sigma_{x_{j}} \sqrt{n p(1-p)\left(1-\rho_{j}^{2}\right)}}$$


  • $\beta$ is the log odds ratio for the ancestry variable

  • $z_{1-\alpha/2}$ is the $1-\alpha/2$ quantile of a standard normal. If you use a standard false positive rate of $\alpha=0.05$ then $z_{1-\alpha/2} = 1.96$

  • $z_\gamma$ is the $\gamma$ quantile of a standard normal, where $\gamma$ is the desired statistical power. If you use a standard power of $\gamma=0.8$ then $z_\gamma = 0.84$.

  • $\sigma_{x}$ is the standard deviation of the ancestry predictor.

  • $n$ is the sample size

  • $p$ is the marginal probability of the outcome (the sample mean of the outcome ignoring the ancestry variable).

  • $1-\rho^2$ is the variance inflation factor, but since you only have a single predictor you can ignore this.

This formula will tell you the log odds ratio you can detect at a given power with your sample.

  • $\begingroup$ The ancestry predictor doesn't have a standard deviation in this case, however. $\endgroup$
    – dnv89
    Jan 7, 2022 at 0:56
  • $\begingroup$ @dnv89 and why would that be $\endgroup$ Jan 7, 2022 at 1:07
  • $\begingroup$ I think I confused myself. You mean the standard deviation from R from the glm(formula = variable ~ ancestry, family = binomial, data = dataset) not from the ancestry data itself, correct? $\endgroup$
    – dnv89
    Jan 7, 2022 at 1:25
  • $\begingroup$ @dnv89 No, I mean the output of sd(ancestry) $\endgroup$ Jan 7, 2022 at 1:29
  • $\begingroup$ Standard deviation of the ancestry sampleset going into the logistic, OK, I can do that $\endgroup$
    – dnv89
    Jan 7, 2022 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.