Power analysis for linear model test I am building a linear model to analyze experimental data with the following shape:
$$
y \sim b_0 + b_1T + b_2X + N(0, \sigma^2)
$$
Where $T$ is a binary variable indicating the treatment and $X$ is a covariate.
The hypothesis test that I am going to run to check if the treatment has any significant effect is:
$$
H_0: T = 0
$$
vs
$$
H_1: T \neq 0
$$
I want to analytically obtain expressions of the power of the test, something like this but for the linear model I am writing. Can anyone share the derivation of the power of the test?
Thanks in advance!
 A: In Regression Methods in Biostatistics, Second edition (Springer, 2012), Vittinghoff et al. provide formulas that can be adapted to your terminology.
First, the variance of the linear regression coefficient estimate $\hat \beta_T$ for predictor $T$ (treatment) in your two-predictor model is (based on their equation 4.4):
$$\text{Var}(\hat \beta_T ) = \frac{\sigma^2}{(n-1)\sigma^2_T(1-r^2_{TX})}.$$
Note that this depends on the correlation between $X$ and $T$, $r_{TX}$. More generally in a multiple-predictor model, you can replace $1/(1-r^2_{TX})$ with the variance inflation factor for $T$. A randomized trial will ideally minimize that correlation.
With a binary $T$, $\sigma^2_T=f_T(1-f_T)$, where $f_T$ is the fraction of cases in one of the two treatment categories.
The power $\gamma$ to distinguish a particular true coefficient value $\beta^a_T>0$ from 0 at a type-I error level of $\alpha$ is given by a large-sample normal approximation (their equation 4.14):
$$\gamma \approx \Phi \left[\beta^a_T/\text{SE}(\hat \beta_T) - z_{1-\alpha/2}\right],$$
where $\Phi$ is the standard normal cumulative distribution such that $\Phi(z_{1-\alpha/2})=1-\alpha/2$. Apply the inverse transformation $\Phi^{-1}$ to both sides of the power equation; $\Phi^{-1}(\gamma)=z_\gamma$. Under the large-sample approximation, replace $(n-1)$ in the variance estimate with $n$, take the square root to get the standard error $\text{SE}$, and solve for $n$ (based on their equation 4.15):
$$n = \frac{(z_{1-\alpha/2} + z_\gamma)^2\sigma^2}{(\beta^a_T\sigma_T)^2(1-r^2_{TX})}.$$
