Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you conduct a power analysis for logistic regression in R?

Tags:

r

I'm familiar with G*Power as a tool for power analyses, but have yet to find a resource on the internet describing how to compute a power analysis for for logistic regression in R. The pwr package doesn't list logistic regression as an option.

like image 569
timothy.s.lau Avatar asked Dec 01 '14 18:12

timothy.s.lau


2 Answers

You will very likely need to "roll your own".

  • Specify your hypothesized relationship between predictors and outcome.
  • Specify what values of your predictors you are likely to observe in your study. Will they be correlated?
  • Specify the effect size you would like to detect, e.g., odds ratios corresponding to two specific settings of your predictors.
  • Specify a power level, e.g., beta=0.80.
  • For different sample sizes n:
    • Simulate predictors as specified
    • Simulate outcomes
    • Run your analysis
    • Record whether you detect a statistically significant effect
    • Do these steps many times, on the order of 1000 or more times. Count how often you did detect an effect. If you detected an effect more than (e.g.) 80% of the time, you are overpowered - reduce n and start over. If you detected an effect less than 80%, you are underpowered - increase n and start over. Rinse & repeat until you have a good n.

And then think some more about whether all your assumptions really make sense. Vary them a bit. Is the resulting value of n sensitive to your assumptions?

Yes, this will be quite a bit of work. But it will be worth it. On the one hand, it will keep you from running an over- or underpowered study. On the other hand, as I wrote, this will force you to think deeply about your assumptions, and this is the path to enlightenment. (Which is a painful path to travel. Sorry.)

If you don't get any better answers specifically helping you to do this in R, you may want to look to CrossValidated for more help. Good luck!

like image 56
Stephan Kolassa Avatar answered Nov 07 '22 09:11

Stephan Kolassa


This question and answers on Crossvalidated discuss power for logistic regression and include R code as well as additional discussion and links for more information.

like image 34
Greg Snow Avatar answered Nov 07 '22 10:11

Greg Snow