Sample size and power calculations in Mendelian randomization with a single instrumental variable and a binary outcome

Similar documents
Use of allele scores as instrumental variables for Mendelian randomization

Use of allele scores as instrumental variables for Mendelian randomization

Mendelian randomization analysis with multiple genetic variants using summarized data

Mendelian Randomisation and Causal Inference in Observational Epidemiology. Nuala Sheehan

Mendelian Randomization

Mendelian randomization with a binary exposure variable: interpretation and presentation of causal estimates

MEA DISCUSSION PAPERS

Methods for meta-analysis of individual participant data from Mendelian randomization studies with binary outcomes

Advanced IPD meta-analysis methods for observational studies

MMI 409 Spring 2009 Final Examination Gordon Bleil. 1. Is there a difference in depression as a function of group and drug?

An instrumental variable in an observational study behaves

Network Mendelian randomization: using genetic variants as instrumental variables to investigate mediation in causal pathways

Outline. Introduction GitHub and installation Worked example Stata wishes Discussion. mrrobust: a Stata package for MR-Egger regression type analyses

Unit 1 Exploring and Understanding Data

EPI 200C Final, June 4 th, 2009 This exam includes 24 questions.

2.75: 84% 2.5: 80% 2.25: 78% 2: 74% 1.75: 70% 1.5: 66% 1.25: 64% 1.0: 60% 0.5: 50% 0.25: 25% 0: 0%

Mendelian randomization with fine-mapped genetic data: choosing from large numbers of correlated instrumental variables

C2 Training: August 2010

Instrumental variable analysis in randomized trials with noncompliance. for observational pharmacoepidemiologic

Citation for published version (APA): Ebbes, P. (2004). Latent instrumental variables: a new approach to solve for endogeneity s.n.

Simple Linear Regression the model, estimation and testing

Business Statistics Probability

Inference with Difference-in-Differences Revisited

Evidence-Based Medicine Journal Club. A Primer in Statistics, Study Design, and Epidemiology. August, 2013

Introduction to diagnostic accuracy meta-analysis. Yemisi Takwoingi October 2015

Logistic regression. Department of Statistics, University of South Carolina. Stat 205: Elementary Statistics for the Biological and Life Sciences

Meta-Analysis. Zifei Liu. Biological and Agricultural Engineering

An Empirical Assessment of Bivariate Methods for Meta-analysis of Test Accuracy

Methods Research Report. An Empirical Assessment of Bivariate Methods for Meta-Analysis of Test Accuracy

Treatment effect estimates adjusted for small-study effects via a limit meta-analysis

Improving ecological inference using individual-level data

Mendelian randomization: Using genes as instruments for making causal inferences in epidemiology

Chapter 11: Advanced Remedial Measures. Weighted Least Squares (WLS)

Problem #1 Neurological signs and symptoms of ciguatera poisoning as the start of treatment and 2.5 hours after treatment with mannitol.

Article from. Forecasting and Futurism. Month Year July 2015 Issue Number 11

Clinical trial design issues and options for the study of rare diseases

Chapter 17 Sensitivity Analysis and Model Validation

Fundamental Clinical Trial Design

Understandable Statistics

Investigating causality in the association between 25(OH)D and schizophrenia

Examining Relationships Least-squares regression. Sections 2.3

Chapter 1: Exploring Data

Describe what is meant by a placebo Contrast the double-blind procedure with the single-blind procedure Review the structure for organizing a memo

Example 7.2. Autocorrelation. Pilar González and Susan Orbe. Dpt. Applied Economics III (Econometrics and Statistics)

Midterm Exam MMI 409 Spring 2009 Gordon Bleil

Ec331: Research in Applied Economics Spring term, Panel Data: brief outlines

Propensity Score Matching with Limited Overlap. Abstract

Describe what is meant by a placebo Contrast the double-blind procedure with the single-blind procedure Review the structure for organizing a memo

Analysis of Rheumatoid Arthritis Data using Logistic Regression and Penalized Approach

investigate. educate. inform.

Statistics as a Tool. A set of tools for collecting, organizing, presenting and analyzing numerical facts or observations.

Applied Econometrics for Development: Experiments II

Instrumental Variables. Application and Limitations

Still important ideas

Study Guide for the Final Exam

Index. Springer International Publishing Switzerland 2017 T.J. Cleophas, A.H. Zwinderman, Modern Meta-Analysis, DOI /

Abstract Title Page Not included in page count. Authors and Affiliations: Joe McIntyre, Harvard Graduate School of Education

Models for potentially biased evidence in meta-analysis using empirically based priors

School of Population and Public Health SPPH 503 Epidemiologic methods II January to April 2019

Sampling Uncertainty / Sample Size for Cost-Effectiveness Analysis

Correlation and regression

Overview of Non-Parametric Statistics

Day 11: Measures of Association and ANOVA

Binary Diagnostic Tests Two Independent Samples

STATISTICS AND RESEARCH DESIGN

Problem set 2: understanding ordinary least squares regressions

Study protocol v. 1.0 Systematic review of the Sequential Organ Failure Assessment score as a surrogate endpoint in randomized controlled trials

Technical appendix Strengthening accountability through media in Bangladesh: final evaluation

Performance of Median and Least Squares Regression for Slightly Skewed Data

Evidence Based Medicine

EXERCISE: HOW TO DO POWER CALCULATIONS IN OPTIMAL DESIGN SOFTWARE

Sampling Weights, Model Misspecification and Informative Sampling: A Simulation Study

SWITCH Trial. A Sequential Multiple Adaptive Randomization Trial

Data Analysis in Practice-Based Research. Stephen Zyzanski, PhD Department of Family Medicine Case Western Reserve University School of Medicine

Biostatistics. Donna Kritz-Silverstein, Ph.D. Professor Department of Family & Preventive Medicine University of California, San Diego

POST GRADUATE DIPLOMA IN BIOETHICS (PGDBE) Term-End Examination June, 2016 MHS-014 : RESEARCH METHODOLOGY

The Analysis of 2 K Contingency Tables with Different Statistical Approaches

Developments in cluster randomized trials and Statistics in Medicine

Propensity scores: what, why and why not?

Meta-Analysis and Publication Bias: How Well Does the FAT-PET-PEESE Procedure Work?

STATISTICAL METHODS FOR DIAGNOSTIC TESTING: AN ILLUSTRATION USING A NEW METHOD FOR CANCER DETECTION XIN SUN. PhD, Kansas State University, 2012

Flexible Matching in Case-Control Studies of Gene-Environment Interactions

Chapter 2 Organizing and Summarizing Data. Chapter 3 Numerically Summarizing Data. Chapter 4 Describing the Relation between Two Variables

Fixed Effect Combining

Association of plasma uric acid with ischemic heart disease and blood pressure:

The Association Design and a Continuous Phenotype

Understanding Uncertainty in School League Tables*

Regression Discontinuity Analysis

Sanjay P. Zodpey Clinical Epidemiology Unit, Department of Preventive and Social Medicine, Government Medical College, Nagpur, Maharashtra, India.

Describe what is meant by a placebo Contrast the double-blind procedure with the single-blind procedure Review the structure for organizing a memo

Analyzing diastolic and systolic blood pressure individually or jointly?

For more information about how to cite these materials visit

Biostatistics II

Still important ideas

Abstract Title Page. Authors and Affiliations: Chi Chang, Michigan State University. SREE Spring 2015 Conference Abstract Template

GUIDELINE COMPARATORS & COMPARISONS:

Hypothesis Testing. Richard S. Balkin, Ph.D., LPC-S, NCC

Detection of Differential Test Functioning (DTF) and Differential Item Functioning (DIF) in MCCQE Part II Using Logistic Models

Carrying out an Empirical Project

Transcription:

Sample size and power calculations in Mendelian randomization with a single instrumental variable and a binary outcome Stephen Burgess July 10, 2013 Abstract Background: Sample size calculations are an important tool for planning epidemiological studies. Large sample sizes are often required in Mendelian randomization investigations. Methods and results: Resources are provided for investigators to perform sample size and power calculations for Mendelian randomization with a binary outcome. We initially provide formulae for the continuous outcome case, and then analogous formulae for the binary outcome case. The formulae are valid for a single instrumental variable, which may be a single genetic variant or an allele score comprising multiple variants. Graphs are provided to give the required sample size for 80% power for given values of the causal effect of the risk factor on the outcome and of the squared correlation between the risk factor and instrumental variable. R code is made available for calculating the sample size needed for a chosen power level given these parameters, as well as the power given the chosen sample size and these parameters. Conclusions: The sample size required for a given power of Mendelian randomization investigation depends greatly on the proportion of variance in the risk factor explained by the instrumental variable. The inclusion of multiple variants into an allele score to explain more of the variance in the risk factor will improve power, however care must be taken not to introduce bias by the inclusion of invalid variants. Keywords: Mendelian randomization, sample size, power, binary outcome, allele score. 1

Introduction Sample size calculations are an important part of experimental design. They inform an investigator of the expected power of a given analysis to reject the null hypothesis. If the power of an analysis is low, then not only is the probability of rejecting the null hypothesis low, but when the null hypothesis is rejected, the posterior probability that the rejection of the null hypothesis is not simply a chance finding is low [1]. Mendelian randomization is the use of genetic variants as instrumental variables for assessing the causal association of a risk factor on an outcome from observational data [2]. Genetic variants are chosen which are specifically associated with a risk factor of interest, and not associated with variables which may be confounders of the association between the risk factor and outcome [3]. Such a variant divides the population into groups which are similar to treatment arms in a randomized controlled trial [4]. Under the instrumental variable assumptions [5, 6], a statistical association between the genetic variant and the outcome implies that the risk factor has a causal effect on the outcome [7]. However, as genetic variants typically explain a small proportion of the variance in risk factors, the power to detect a significant association between the variant and outcome in an applied Mendelian randomization context can be low [8]. Sample size analysis is particularly important to inform whether a null finding is representative of a true null causal association, or simply a lack of power to detect an effect size of clinical interest. Sample size calculations have been previously presented for Mendelian randomization experiments with continuous outcomes. Calculations based on asymptotical statistical theory have been presented with a single instrumental variable (IV), whether that IV is a single genetic variant or an allele score [9]. An allele score (also called a genetic risk score) is a single variable summarizing multiple genetic variants as a weighted or unweighted sum of risk factor-increasing alleles [10]. A simulation study for estimating power has also been presented with both single and multiple IVs [11]. These approaches have shown good agreement. However, in many cases, the outcome in a Mendelian randomization experiment is dichotomous, such as disease. In this note, we present power calculations for Mendelian randomization studies with a binary outcome. Methods We give results for the asymptotic variance of IV estimators with a single IV, and for the resulting sample size needed in a Mendelian randomization study to obtain a given power level. We initially present formulae with a continuous outcome, and then analogous formulae with a binary outcome. Power with a continuous outcome With a single IV and a continuous outcome, the IV estimates from the ratio, two-stage least squares (2SLS) and limited information maximum likelihood (LIML) methods 2

coincide [12]. The estimator can be expressed as the ratio between the coefficient from the regression of the outcome (Y ) on the genetic variant (G), divided by the coefficient from the regression of the risk factor (X) on the variant: ˆβ IV = ˆβ GY ˆβ GX (1) The asymptotic variance of this IV estimator is given by the formula: var( ˆβ IV ) = var(r Y ) N var(x) ρ 2 GX (2) where R Y = Y β 1 X is the residual of the outcome on subtraction of the causal effect of the risk factor, and ρ 2 GX is the square of the correlation between the risk factor X and the IV G [13]. The coefficient of determination (R 2 ) in the regression of the risk factor on the IV is an estimate of ρ 2 GX. The IV in these calculations could either be a single genetic variant or an allele score [10]. The asymptotic variance of the conventional regression (ordinary least squares, OLS) estimator of the association between the risk factor X and the outcome Y is given by the formula: var( ˆβ IV ) = var(r Y ) (3) N var(x) The sample size necessary for an IV analysis to demonstrate a non-zero association, for a given magnitude of causal effect is therefore approximately equal to that for a conventional epidemiological analysis to demonstrate the same magnitude of association divided by the ρ 2 GX value for the IV [14]. If the significance level is α and the power desired to test the null hypothesis is 1 β, then the sample size required to test a causal effect of size β 1 using IV analysis is [9]: Sample size = (z (1 α 2 ) + z β ) 2 var(r Y ) var(x) β 2 1 ρ 2 GX (4) where z a is the 100a percentile point on the normal distribution. If the significance level is 0.05 and the power is 0.8, then the sample size for to test a change of β 1 standard deviations in Y per standard deviation increase in X is: Sample size = 7.848 β 2 1 ρ 2 GX (5) We use these formulae to construct power curves for Mendelian randomization using a significance level of 0.05. In Figure 1 (left), we fix the squared correlation ρ 2 GX at 0.02, meaning the variant explains on average 2% of the variance of the risk factor, and vary the size of the effect β 1 = 0.05, 0.1, 0.15, 0.2, 0.25, 0.3 and the sample size N = 1000 to 10 000. In Figure 1 (right), we fix the size of the effect at β 1 = 0.2 and vary the squared correlation ρ 2 GX = 0.005, 0.01, 0.015, 0.02, 0.03, 0.05 and the sample size as before. In each of the figures, the power to detect a positive causal association 3

is displayed; this tends to 0.025 as the sample size tends to zero. We see that the power increases as the causal effect increases, and as the IV explains more of the variance in the risk factor (the ρ 2 GX parameter or the expected value of the R2 statistic increases). Similar formulae to these have been made available in an online tool for calculating either power for a given sample size or sample size needed for a given power, taking the causal effect (β 1 ) and squared correlation (ρ 2 GX ) parameters, as well as the variance of the risk factor and outcome, and the observational (OLS) coefficient of the risk factor from regression on the outcome [15]. Power (%) 0 20 40 60 80 100 Power (%) 0 20 40 60 80 100 0 2000 4000 6000 8000 10000 Sample size 0 2000 4000 6000 8000 10000 Sample size Figure 1: Power curves varying the sample size with continuous outcome and a single instrumental variable: (left panel) for a fixed value of the IV strength (ρ 2 GX = 0.02) and different values of the size of the causal effect (β 1 = 0.05, 0.1,..., 0.3); (right panel) for a fixed value of the causal effect (β 1 = 0.2) and varying the size of the IV strength (ρ 2 GX = 0.005, 0.01,..., 0.05) Power with a binary outcome With a single IV and a binary outcome, the same IV estimator (1) as in the continuous outcome case can be evaluated, except that typically a logistic model is used in the regression of the outcome on the genetic variant [16]. The asymptotic variance of this expression can be approximated using the delta method for this ratio of estimates [17]. The leading term in the expansion is: var( ˆβ IV ) = var( ˆβ GY ) ˆβ GX (6) The asymptotic variance of the coefficient from the logistic regression (var( ˆβ GY )) is difficult to evaluate analytically. We estimated the variance by simulating data on a 4

genetic variant and outcome for a sample size of 1000 with roughly equal numbers of cases and controls. The data generating model for individuals indexed by i was: g i N (0, 1) (7) x i N (g i, 1 ρ 2 GX) y i Binomial(1, expit(β 1 x i )) where expit(x) = exp(x) is the inverse of the logit function and β 1+exp(x) 1 is the log odds ratio per unit (which equals 1 standard deviation) increase in the risk factor. The genetic variant is modelled by a standard normal distribution for computational simplicity; it could be regarded as a standardized weighted allele score. The mean value of the variance of var( ˆβ GY ) was taken across 100 simulated datasets. We found that the variance of the parameter depended on the number of cases, and was not sensitive to the incidence of disease in the population. Results for the sample size calculations are cited in terms of number of cases required. If the ascertained population contains a greater proportion of control participants than a 1:1 ratio, then these sample sizes will be conservative. The variance of the relevant coefficient was similar in a log-linear model assuming that the sample was a population cohort rather than a case-control sample The sample size (number of cases) required for 80% power using a significance level of 0.05 was calculated as: Number of cases = 7.848 var( ˆβ GY ) β 2 1 ρ 2 GX 500 (8) We use this approximation to calculate the number of cases needed to obtain 80% power in a Mendelian randomization analysis with a binary outcome for different values of β 1 and ρ 2 GX. The results displayed in Figure 2. We note that when the genetic variants explain a small proportion of the variance in the risk factor, large sample sizes are requires to detect even moderately large causal effects with reasonable power. An R [18] script for performing sample size and power calculations is provided in the Appendix. This code enables the calculation of the sample size required for a chosen power level given the values of β 1 and ρ 2 GX, as well as the power given the values of β 1, ρ 2 GX and the chosen sample size. Discussion In this paper, we have provided information on sample sizes required to obtain 80% power in a Mendelian randomization analysis with a single IV and a binary outcome. We have shown in the continuous setting how the power depends on the magnitude of causal effect and the proportion of variance in the risk factor explained by the IV. With a binary outcome, the precision of the coefficient in the regression of the outcome on the IV is reduced compared to with a continuous outcome, as the outcome can only take two values. As a result, the required sample sizes to obtain 80% power are much larger. 5

Number of cases required for 80% power 2K 10K 20K 30K 40K 50K ρ 2 GX =1% 2 =2% 2 =3% 2 =5% 2 =8% 1.1 1.2 1.3 1.4 1.5 Odds ratio per SD increase in risk factor Number of cases required for 80% power 5K 20K 40K 60K 80K 100K ρ 2 GX =0.5% 2 =1.0% 2 =1.5% 2 =2.0% 2 =2.5% 2 =3.0% 1.1 1.2 1.3 1.4 1.5 Odds ratio per SD increase in risk factor Figure 2: Number of cases required in a Mendelian randomization analysis with a binary outcome and a single instrumental variable for 80% power with a 5% significance level varying the size of causal effect (odds ratio per unit increase in risk factor) for different values of IV strength (ρ 2 GX ) 6

For a given applied example, the magnitude of the causal effect of a risk factor is fixed, as is the expected proportion of variance in the risk factor explained by each variant. However, the expected proportion of variance in the risk factor explained by the IV depends on the choice of IV. The required sample size for a given power level can be reduced (or equivalently the expected power at a given sample size can be increased) by including more genetic variants into the IV. This can be achieved by using multiple variants as separate IVs [19], or as a single IV using an allele score approach. With an allele score, power can be further increased by the use of relevant weights for the variants [10]. Provided that weights are not derived naively from the data under analysis, the allele score approach avoids some of the problems of bias from weak instruments resulting from using many IVs [20]. A disadvantage of the the inclusion of many variants in an IV analysis, whether in a multiple IV or an allele score model, is that one or more of the variants may not be a valid IV. If a variant is associated with a confounder of the risk factor outcome association, or with the outcome through a pathway not via the risk factor of interest, then the estimate associated with this IV may be biased. If the function and relevance of some variants as IVs is uncertain, investigators will have to balance the risk of a biased analysis against the risk of an underpowered analysis. Sensitivity analysis may be a valuable tool to assess the homogeneity of IV estimates using different sets of variants. The calculations in this paper make several assumptions. The distribution of the IV estimator is assumed to be well approximated by a normal distribution. This is known to be a poor approximation when the IV is weak [21]; however, if the IV is weak, then the power will usually be low. The standard deviation of this normal distribution is assumed to be close to the first-order term from the delta expansion. This term only involves the uncertainty in the coefficient from the genetic association with the outcome. The uncertainty in the estimate of the genetic association with the risk factor is not accounted for. Typically, this uncertainty will be small in comparison as the genetic association with the outcome is assumed to be mediated through the risk factor. Again, if this uncertainty is large, then the power of the analysis will usually be low. If a more precise estimate of the power is required, either further terms from the delta expansion could be used, or a direct simulation approach could be undertaken. As the power is very sensitive to the squared correlation term ρ 2 GX, it is advisable to take a conservative estimate of this parameter. Although the sample sizes required in Mendelian randomization experiments are often large, it is not always necessary to measure the risk factor on all of the participants in a study. Simulations have shown that, in some cases, 90% of the power of the complete-data analysis can be obtained while only measuring the risk factor on 10% of participants [22]. This means that obtaining measurements of the risk factor, which may be expensive or impractical for a large sample, should not be the prohibitive factor for a Mendelian randomization investigation. 7

Key messages: Resources are provided for investigators to perform sample size and power calculations for Mendelian randomization with a binary outcome. The sample size required for a given power level is highly dependent on the proportion of the variance in the risk factor explained by the instrumental variable. References [1] Davey Smith G, Ebrahim S. Data dredging, bias, or confounding. British Medical Journal 2002; 325(7378):1437, doi:10.1136/bmj.325.7378.1437. [2] Davey Smith G, Ebrahim S. Mendelian randomization : can genetic epidemiology contribute to understanding environmental determinants of disease? International Journal of Epidemiology 2003; 32(1):1 22, doi:10.1093/ije/dyg070. [3] Lawlor D, Harbord R, Sterne J, Timpson N, Davey Smith G. Mendelian randomization: using genes as instruments for making causal inferences in epidemiology. Statistics in Medicine 2008; 27(8):1133 1163, doi:10.1002/sim.3034. [4] Nitsch D, Molokhia M, Smeeth L, DeStavola B, Whittaker J, Leon D. Limits to causal inference based on Mendelian randomization: a comparison with randomized controlled trials. American Journal of Epidemiology 2006; 163(5):397 403, doi:10.1093/aje/kwj062. [5] Greenland S. An introduction to instrumental variables for epidemiologists. International Journal of Epidemiology 2000; 29(4):722 729, doi:10.1093/ije/29.4.722. [6] Martens E, Pestman W, de Boer A, Belitser S, Klungel O. Instrumental variables: application and limitations. Epidemiology 2006; 17(3):260 267, doi: 10.1097/01.ede.0000215160.88317.cb. [7] Didelez V, Sheehan N. Mendelian randomization as an instrumental variable approach to causal inference. Statistical Methods in Medical Research 2007; 16(4):309 330, doi:10.1177/0962280206077743. [8] Schatzkin A, Abnet C, Cross A, Gunter M, Pfeiffer R, Gail M, Lim U, Davey Smith G. Mendelian randomization: how it can and cannot help confirm causal relations between nutrition and cancer. Cancer Prevention Research 2009; 2(2):104 113, doi:10.1158/1940-6207.capr-08-0070. [9] Freeman G, Cowling B, Schooling M. Power and sample size calculations for Mendelian randomization studies. International Journal of Epidemiology 2013;. 8

[10] Burgess S, Thompson S. Use of allele scores as instrumental variables for Mendelian randomization. International Journal of Epidemiology 2013; doi: 10.1093/ije/dyt093. [11] Pierce B, Ahsan H, VanderWeele T. Power and instrument strength requirements for Mendelian randomization studies using multiple genetic variants. International Journal of Epidemiology 2011; 40(3):740 752, doi:10.1093/ije/dyq151. [12] Burgess S, Thompson S. Improvement of bias and coverage in instrumental variable analysis with weak instruments for continuous and binary outcomes. Statistics in Medicine 15 2012; 31:1582 1600, doi:10.1002/sim.4498. [13] Nelson C, Startz R. The distribution of the instrumental variables estimator and its t-ratio when the instrument is a poor one. Journal of Business 1990; 63(1):125 140. [14] Wooldridge J. Econometric analysis of cross section and panel data. MIT Press, 2002. [15] Shakhbazov K. mrnd: Power calculations for Mendelian randomization. http://glimmer.rstudio.com/kn3in/mrnd. [16] Didelez V, Meng S, Sheehan N. Assumptions of IV methods for observational epidemiology. Statistical Science 2010; 25(1):22 40, doi:10.1214/09-sts316. [17] Thomas D, Conti D. Commentary: the concept of Mendelian Randomization. International Journal of Epidemiology 2004; 33(1):21 25, doi: 10.1093/ije/dyh048. [18] R Development Core Team. R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria 2011. URL http://www.r-project.org, ISBN 3-900051-07-0. [19] Palmer T, Lawlor D, Harbord R, Sheehan N, Tobias J, Timpson N, Davey Smith G, Sterne J. Using multiple genetic variants as instrumental variables for modifiable risk factors. Statistical Methods in Medical Research 2011; 21(3):223 242, doi:10.1177/0962280210394459. [20] Burgess S, Thompson S, CRP CHD Genetics Collaboration. Avoiding bias from weak instruments in Mendelian randomization studies. International Journal of Epidemiology 2011; 40(3):755 764, doi:10.1093/ije/dyr036. [21] Burgess S, Thompson S. Bias in causal estimates from Mendelian randomization studies with weak instruments. Statistics in Medicine 2011; 30(11):1312 1323, doi:10.1002/sim.4197. [22] Pierce B, Burgess S. Efficient design for Mendelian randomization studies: subsample instrumental variable estimators. American Journal of Epidemiology 2013; doi:10.1093/aje/kwt084. 9

Appendix A.1 R code for performing sample size and power calculations We here provide R code for performing sample size and power calculations. The code requires the causal effect (β 1 ) and squared correlation (ρ 2 GX ), and can either provide the sample size (number of cases) required for a given level of power, or the power for a given sample size. expit <- function(x) { return(exp(x)/(1+exp(x))) } parts = 1000 betsd = NULL rsq = 0.02 # squared correlation b1 = 0.2 # causal effect (log odds ratio per SD) sig = 0.05 # significance level (alpha) pow = 0.8 # power level (1-beta) for (k in 1:100) { g=rnorm(parts, sd=1) x=sqrt(rsq)*g+rnorm(parts, sd=sqrt(1-rsq)) y=rbinom(parts, 1, expit(b1*x)) betsd[k]=summary(glm(y~g, family=binomial))$coef[2,2] } cat("number of cases required for ", pow*100, "% power: ", ceiling((qnorm(1-sig/2)+qnorm(pow))^2/b1^2*mean(betsd)^2/rsq*5)*100) n = 20000 # Number of cases cat("power of analysis with ", n, "cases: ", pnorm(sqrt(n/500*rsq)*b1/mean(betsd)-qnorm(1-sig/2))) 10