# Power analysis for binomial regression (success/failure)

I've collect 161 people for a study which the original power analysis was based on correlations, but now I've realised binomial regression would be better. I can find a lot of articles on comparing binomial proportions (45/60 vs 48/60) and linear regressions, but nothing about a regression predicting a proportion (specifically one with success/fail: 48/60 rather than proportion success: 80% )

I have a variable (ordinal, 0-30) predicting performance in each block of 60 trials. My research question is: does Unex predict performance?

res <- glm(cbind(B1_success, (60 - B1_success)) ~  Unex, data = Df, family = "binomial")

I'm not sure what the effect size would be to use for this either, as glm does not give overall effect sizes except for beta coefficients(?). Overall, I wanted to work out power for 77%, 78%, 82%, 83% etc. (H1) compared to 80% (H0), or small, medium, strong effect size? And post-hoc achieved power.

Any help would be appreciated! Sorry if this is unclear, my first post.

I've seen Power analysis for binomial data when the null hypothesis is that $p = 0$ but not sure its relevant to me.

Edit: Thanks for the help. I've added an R function that other might find useful

powerBinom<-function(beta, N, outcomeVariance, predictorSD){

if (outcomeVariance >.25) {print("ERROR: Maximum 0.25 for binomial outcome")}

powerBinom = 1 - pnorm(1.96 - beta * predictorSD * sqrt((N*outcomeVariance)))
print(powerBinom)
}

First off, post hoc power is a load of crap, so let's just get that out of the way.

If you want to know power for detecting an effect, you need to know a few things first.

• The marginal variance of the outcome.
• A minimal detectable effect per one unit standard deviation increase in the predictor. The reason I say one standard deviation increase in the predictor is because it gives us one less thing to estimate in the power calculations.

The power achieved by having these things and a sample size of 161 at a 0.05 significance level is $$\gamma = 1 - {\bf{\Phi}}(1.96-\vert\beta\vert\sigma_x \sqrt{(np(1-p)} )$$

Here $$\bf{\Phi}$$ is the CDF for a standard normal distribution. $$\sigma_x$$ is the standard deviation for your predictor. If it is 1, as I suggest, then $$\beta$$ is the change in log odds per one standrd deviation change in the predictor. Also, $$p(1-p)$$ is the marginal variance of the outcome, regardless Unex.