![](/user_photo/2706_HbeT2.jpg)
Robert I. Kabacoff - R in action
.pdf![](/html/2706/143/html_Xn7PsORXYS.WerA/htmlconvd-prQjwo281x1.jpg)
256 |
CHAPTER 10 Power analysis |
the alternative hypothesis in a two-way contingency table. Here, P is a hypothesized two-way probability table.
As a simple example, let’s assume that you’re looking the relationship between ethnicity and promotion. You anticipate that 70 percent of your sample will be Caucasian, 10 percent will be African American, and 20 percent will be Hispanic. Further, you believe that 60 percent of Caucasians tend to be promoted, compared with 30 percent for African Americans, and 50 percent for Hispanics. Your research hypothesis is that the probability of promotion follows the values in table 10.2.
Table 10.2 Proportion of individuals expected to be promoted based on the research hypothesis
Ethnicity |
Promoted |
Not promoted |
|
|
|
Caucasian |
0.42 |
0.28 |
African American |
0.03 |
0.07 |
Hispanic |
0.10 |
0.10 |
|
|
|
For example, you expect that 42 percent of the population will be promoted Caucasians (.42 = .70 × .60) and 7 percent of the population will be nonpromoted African Americans (.07 = .10 × .70). Let’s assume a significance level of 0.05 and the desired power level is 0.90. The degrees of freedom in a two-way contingency table are (r-1)*(c-1), where r is the number of rows and c is the number of columns. You can calculate the hypothesized effect size with the following code:
>prob <- matrix(c(.42, .28, .03, .07, .10, .10), byrow=TRUE, nrow=3)
>ES.w2(prob)
[1] 0.1853198
Using this information, you can calculate the necessary sample size like this:
> pwr.chisq.test(w=.1853, df=2, sig.level=.05, power=.9)
Chi squared power calculation
w |
= 0.1853 |
|
N |
= 368.5317 |
|
df |
= 2 |
|
sig.level |
= |
0.05 |
power |
= |
0.9 |
NOTE: N is the number of observations
The results suggest that a study with 369 participants will be adequate to detect a relationship between ethnicity and promotion given the effect size, power, and significance level specified.
![](/html/2706/143/html_Xn7PsORXYS.WerA/htmlconvd-prQjwo282x1.jpg)
Implementing power analysis with the pwr package |
257 |
10.2.7 Choosing an appropriate effect size in novel situations
In power analysis, the expected effect size is the most difficult parameter to determine. It typically requires that you have experience with the subject matter and the measures employed. For example, the data from past studies can be used to calculate effect sizes, which can then be used to plan future studies.
But what can you do when the research situation is completely novel and you have no past experience to call upon? In the area of behavioral sciences, Cohen (1988) attempted to provide benchmarks for “small,” “medium,” and “large” effect sizes for various statistical tests. These guidelines are provided in table 10.3.
Table 10.3 Cohen’s effect size benchmarks
Statistical method |
Effect size measures |
Suggested guidelines for effect size |
|||
|
|
|
|
|
|
|
|
Small |
Medium |
Large |
|
|
|
|
|
|
|
t-test |
d |
0.20 |
0.50 |
0.80 |
|
ANOVA |
f |
0.10 |
0.25 |
0.40 |
|
Linear models |
f2 |
0.02 |
|
|
|
0.15 |
0.35 |
||||
Test of propor tions |
h |
0.20 |
|
|
|
0.50 |
0.80 |
||||
Chi-square |
w |
0.10 |
|
|
|
0.30 |
0.50 |
||||
|
|
|
|
|
When you have no idea what effect size may be present, this table may provide some guidance. For example, what’s the probability of rejecting a false null hypothesis (that is, finding a real effect), if you’re using a one-way ANOVA with 5 groups, 25 subjects per group, and a significance level of 0.05?
Using the pwr.anova.test() function and the suggestions in f row of table 10.3, the power would be 0.118 for detecting a small effect, 0.574 for detecting a moderate effect, and 0.957 for detecting a large effect. Given the sample size limitations, you’re only likely to find an effect if it’s large.
It’s important to keep in mind that Cohen’s benchmarks are just general suggestions derived from a range of social research studies and may not apply to your particular field of research. An alternative is to vary the study parameters and note the impact on such things as sample size and power. For example, again assume that you want to compare five groups using a one-way ANOVA and a 0.05 significance level. The following listing computes the sample sizes needed to detect a range of effect sizes and plots the results in figure 10.2.
![](/html/2706/143/html_Xn7PsORXYS.WerA/htmlconvd-prQjwo283x1.jpg)
![](/html/2706/143/html_Xn7PsORXYS.WerA/htmlconvd-prQjwo284x1.jpg)
![](/html/2706/143/html_Xn7PsORXYS.WerA/htmlconvd-prQjwo285x1.jpg)
![](/html/2706/143/html_Xn7PsORXYS.WerA/htmlconvd-prQjwo286x1.jpg)
Summary |
261 |
install.packages(“piface”, repos=”http://R-Forge.R-project.org”) library(piface)
piface()
The package is particularly useful for exploring the impact of changes in sample size, effect size, significance levels, and desired power on the other parameters.
Other packages related to power analysis are described in table 10.4. The last five are particularly focused on power analysis in genetic studies. Genome-wide association studies (GWAS) are studies used to identify genetic associations with observable traits. For example, these studies would focus on why some people get a specific type of heart disease.
Table 10.4 Specialized power analysis packages
Package |
Purpose |
|
|
asypow |
Power calculations via asymptotic likelihood ratio methods |
PwrGSD |
Power analysis for group sequential designs |
pamm |
Power analysis for random effects in mixed models |
powerSurvEpi |
Power and sample size calculations for sur vival analysis in |
|
epidemiological studies |
powerpkg |
Power analyses for the affected sib pair and the TDT (transmission |
|
disequilibrium test) design |
powerGWASinteraction |
Power calculations for interactions for GWAS |
pedantics |
Functions to facilitate power analyses for genetic studies |
|
of natural populations |
gap |
Functions for power and sample size calculations in |
|
case-cohor t designs |
ssize.fdr |
Sample size calculations for microarray experiments |
|
|
Finally, the MBESS package contains a wide range of functions that can be used for various forms of power analysis. The functions are particularly relevant for researchers in the behavioral, educational, and social sciences.
10.5 Summary
In chapters 7, 8, and 9, we explored a wide range of R functions for statistical hypothesis testing. In this chapter, we focused on the planning stages of such research. Power analysis helps you to determine the sample sizes needed to discern an effect of a given size with a given degree of confidence. It can also tell you the probability of detecting such an effect for a given sample size. You can directly see the tradeoff between limiting the likelihood of wrongly declaring an effect significant (a Type I error) with the likelihood of rightly identifying a real effect (power).
262 |
CHAPTER 10 Power analysis |
The bulk of this chapter has focused on the use of functions provided by the pwr package. These functions can be used to carry out power and sample size determinations for common statistical methods (including t-tests, chi-square tests, and tests of proportions, ANOVA, and regression). Pointers to more specialized methods were provided in the final section.
Power analysis is typically an interactive process. The investigator varies the parameters of sample size, effect size, desired significance level, and desired power to observe their impact on each other. The results are used to plan studies that are more likely to yield meaningful results. Information from past research (particularly regarding effect sizes) can be used to design more effective and efficient future research.
An important side benefit of power analysis is the shift that it encourages, away from a singular focus on binary hypothesis testing (that is, does an effect exists or not), toward an appreciation of the size of the effect under consideration. Journal editors are increasingly requiring authors to include effect sizes as well as p values when reporting research results. This helps you to determine both the practical implications of the research and provides you with information that can be used to plan future studies.
In the next chapter, we’ll look at additional and novel ways to visualize multivariate relationships. These graphic methods can complement and enhance the analytic methods that we’ve discussed so far and prepare you for the advanced methods covered in part 3.
![](/html/2706/143/html_Xn7PsORXYS.WerA/htmlconvd-prQjwo288x1.jpg)
264 |
CHAPTER 11 Intermediate graphs |
■When plotting the relationship between two variables drawn from a large dataset (say 10,000 observations), how can you deal with the massive overlap of data points you’re likely to see? In other words, what do you do when your graph is one big smudge?
■How can you visualize the multivariate relationships among three variables at once (given a 2D computer screen or sheet of paper, and a budget slightly less than that for Avatar)?
■How can you display the growth of several trees over time?
■How can you visualize the correlations among a dozen variables in a single graph? How does it help you to understand the structure of your data?
■How can you visualize the relationship of class, gender, and age with passenger survival on the Titanic? What can you learn from such a graph?
These are the types of questions that can be answered with the methods described in this chapter. The datasets that we’ll use are examples of what’s possible. It’s the general techniques that are most important. If the topic of automobile characteristics or tree growth isn’t interesting to you, plug in your own data!
We’ll start with scatter plots and scatter plot matrices. Then, we’ll explore line charts of various types. These approaches are well known and widely used in research. Next, we’ll review the use of correlograms for visualizing correlations and mosaic plots for visualizing multivariate relationships among categorical variables. These approaches are also useful but much less well known among researchers and data analysts. You’ll see examples of how you can use each of these approaches to gain a better understanding of your data and communicate these findings to others.
11.1 Scatter plots
As you’ve seen in previous chapters, scatter plots describe the relationship between two continuous variables. In this section, we’ll start with a depiction of a single bivariate relationship (x versus y). We’ll then explore ways to enhance this plot by superimposing additional information. Next, we’ll learn how to combine several scatter plots into a scatter plot matrix so that you can view many bivariate relationships at once. We’ll also review the special case where many data points overlap, limiting our ability to picture the data, and we’ll discuss a number of ways around this difficulty. Finally, we’ll extend the two-dimensional graph to three dimensions, with the addition of a third continuous variable. This will include 3D scatter plots and bubble plots. Each can help you understand the multivariate relationship among three variables at once.
The basic function for creating a scatter plot in R is plot(x, y), where x and y are numeric vectors denoting the (x, y) points to plot. Listing 11.1 presents an example.
![](/html/2706/143/html_Xn7PsORXYS.WerA/htmlconvd-prQjwo290x1.jpg)