Power Analysis

Overview

Power analysis is an important aspect of experimental design. It allows us to determine the sample size required to detect an effect of a given size with a given degree of confidence. Conversely, it allows us to determine the probability of detecting an effect of a given size with a given level of confidence, under sample size constraints. If the probability is unacceptably low, we would be wise to alter or abandon the experiment.

The following four quantities have an intimate relationship:

  1. sample size
  2. effect size
  3. significance level = P(Type I error) = probability of finding an effect that is not there
  4. power = 1 - P(Type II error) = probability of finding an effect that is there

Given any three, we can determine the fourth.

Power Analysis in R

The pwr package develped by Stéphane Champely, impliments power analysis as outlined by Cohen (!988). Some of the more important functions are listed below.

function power calculations for
pwr.2p.test two proportions (equal n)
pwr.2p2n.test two proportions (unequal n)
pwr.anova.test balanced one way ANOVA
pwr.chisq.test chi-square test
pwr.f2.test general linear model
pwr.p.test proportion (one sample)
pwr.r.test correlation
pwr.t.test t-tests (one sample, 2 sample, paired)
pwr.t2n.test t-test (two samples with unequal n)

For each of these functions, you enter three of the four quantities (effect size, sample size, significance level, power) and the fourth is calculated.

The significance level defaults to 0.05. Therefore, to calculate the significance level, given an effect size, sample size, and power, use the option "sig.level=NULL".

Specifying an effect size can be a daunting task. ES formulas and Cohen's suggestions (based on social science research) are provided below. Cohen's suggestions should only be seen as very rough guidelines. Your own subject matter experience should be brought to bear.

t-tests

For t-tests, use the following functions:

pwr.t.test(n = , d = , sig.level = , power = , type = c("two.sample", "one.sample", "paired"))

where n is the sample size, d is the effect size, and type indicates a two-sample t-test, one-sample t-test or paired t-test. If you have unequal sample sizes, use

pwr.t2n.test(n1 = , n2= , d = , sig.level =, power = )

where n1 and n2 are the sample sizes.

For t-tests, the effect size is assessed as

Cohen d

Cohen suggests that d values of 0.2, 0.5, and 0.8 represent small, medium, and large effect sizes respectively.

You can specify alternative="two.sided", "less", or "greater" to indicate a two-tailed, or one-tailed test. A two tailed test is the default.

ANOVA

For a one-way analysis of variance use

pwr.anova.test(k = , n = , f = , sig.level = , power = )

where k is the number of groups and n is the common sample size in each group.

For a one-way ANOVA effect size is measured by f where

Cohen f
Cohen suggests that f values of 0.1, 0.25, and 0.4 represent small, medium, and large effect sizes respectively.

Correlations

For correlation coefficients use

pwr.r.test(n = , r = , sig.level = , power = )

where n is the sample size and r is the correlation. We use the population correlation coefficient as the effect size measure. Cohen suggests that r values of 0.1, 0.3, and 0.5 represent small, medium, and large effect sizes respectively.

Linear Models

For linear models (e.g., multiple regression) use

pwr.f2.test(u =, v = , f2 = , sig.level = , power = )

where u and v are the numerator and denominator degrees of freedom. We use f2 as the effect size measure.

cohen f2

Cohen f2 alternate

The first formula is appropriate when we are evaluating the impact of a set of predictors on an outcome. The second formula is appropriate when we are evaluating the impact of one set of predictors above and beyond a second set of predictors (or covariates). Cohen suggests f2 values of 0.02, 0.15, and 0.35 represent small, medium, and large effect sizes.

Tests of Proportions

When comparing two proportions use

pwr.2p.test(h = , n = , sig.level =, power = )

where h is the effect size and n is the common sample size in each group.

Cohen h

Cohen suggests that h values of 0.2, 0.5, and 0.8 represent small, medium, and large effect sizes respectively.

For unequal n's use

pwr.2p2n.test(h = , n1 = , n2 = , sig.level = , power = )

To test a single proportion use

pwr.p.test(h = , n = , sig.level = power = )

For both two sample and one sample proportion tests, you can specify alternative="two.sided", "less", or "greater" to indicate a two-tailed, or one-tailed test. A two tailed test is the default.

Chi-square Tests

For chi-square tests use

pwr.chisq.test(w =, N = , df = , sig.level =, power = )

where w is the effect size, N is the total sample size, and df is the degrees of freedom. The effect size w is defined as

Cohen w

Cohen suggests that w values of 0.1, 0.3, and 0.5 represent small, medium, and large effect sizes respectively.

some Examples

library(pwr)

# For a one-way ANOVA comparing 5 groups, calculate the
# sample size needed in each group to obtain a power of
# 0.80, when the effect size is moderate (0.25) and a
# significance level of 0.05 is employed.

pwr.anova.test(k=5,f=.25,sig.level=.05,power=.8)

# What is the power of a one-tailed t-test, with a
# significance level of 0.01, 25 people in each group, 
# and an effect size equal to 0.75?

pwr.t.test(n=25,d=0.75,sig.level=.01,alternative="greater")

# Using a two-tailed test proportions, and assuming a
# significance level of 0.01 and a common sample size of 
# 30 for each proportion, what effect size can be detected 
# with a power of .75? 

pwr.2p.test(n=30,sig.level=0.01,power=0.75)

Creating Power or Sample Size Plots

The functions in the pwr package can be used to generate power and sample size graphs.

# Plot sample size curves for detecting correlations of
# various sizes.

library(pwr)

# range of correlations
r <- seq(.1,.5,.01)
nr <- length(r)

# power values
p <- seq(.4,.9,.1)
np <- length(p)

# obtain sample sizes
samsize <- array(numeric(nr*np), dim=c(nr,np))
for (i in 1:np){
  for (j in 1:nr){
    result <- pwr.r.test(n = NULL, r = r[j],
    sig.level = .05, power = p[i],
    alternative = "two.sided")
    samsize[j,i] <- ceiling(result$n)
  }
}

# set up graph
xrange <- range(r)
yrange <- round(range(samsize))
colors <- rainbow(length(p))
plot(xrange, yrange, type="n",
  xlab="Correlation Coefficient (r)",
  ylab="Sample Size (n)" )

# add power curves
for (i in 1:np){
  lines(r, samsize[,i], type="l", lwd=2, col=colors[i])
}

# add annotation (grid lines, title, legend) 
abline(v=0, h=seq(0,yrange[2],50), lty=2, col="grey89")
abline(h=0, v=seq(xrange[1],xrange[2],.02), lty=2,
   col="grey89")
title("Sample Size Estimation for Correlation Studies\n
  Sig=0.05 (Two-tailed)")
legend("topright", title="Power", as.character(p),
   fill=colors)

sample size curves click to view

http://www.statmethods.net/stats/power.html

### 回答1: PowerGUI是一种强大的免费工具,用于Windows环境下的PowerShell脚本开发和管理。它提供了一个直观的用户界面,使用户能够轻松编写、调试和管理PowerShell脚本。PowerGUI具有丰富的功能集,包括自动完成功能、语法高亮显示、调试器等,这些功能使得PowerShell脚本的开发变得更加高效和易于维护。 PowerGUI还提供了一些附加工具,如FFT(快速傅里叶变换)分析工具。FFT分析是一种通过将信号转换为频谱表示来分析信号的方法。在信号处理和通信系统领域,FFT分析经常用于检测、分析和处理信号。PowerGUI的FFT分析工具使用户能够通过输入信号数据和选择相应的参数,执行FFT分析并获得频谱图。通过观察频谱图,用户可以分析信号的频域特性,以了解信号中存在的频率成分或频谱分布情况。 使用PowerGUI的FFT分析工具,用户可以对音频、振动、光谱等信号进行分析。它可以帮助用户检测信号中的噪声、干扰、频率成分以及频谱特征等信息。对于工程师、科学家和研究人员来说,PowerGUI的FFT分析工具是一种非常有用的工具,它可以帮助他们进行信号分析、故障诊断、性能优化等工作。 总之,PowerGUI是一个功能强大的PowerShell脚本开发和管理工具,它提供了FFT分析工具,方便用户进行信号分析和频谱分析。无论是用于学习、研究还是工程应用,PowerGUI的FFT分析工具对于信号处理和分析都是一种实用的工具。 ### 回答2: PowerGUI是一个用于Windows操作系统的免费的集成开发环境(IDE)和管理工具。它是以PowerShell为基础的脚本语言开发的,用于帮助系统管理员和开发人员进行自动化任务和脚本编写。PowerGUI提供了丰富的图形化界面和工具来简化和加速PowerShell脚本的创建和管理。 FFT(快速傅里叶变换)分析工具是PowerGUI中一个重要的功能,它用于分析和处理信号和频谱数据。FFT是一种数学算法,可以将时域信号转换为频域信号,从而显示出信号所包含的各个频率成分和其强度。 在PowerGUI中,FFT分析工具允许用户输入信号数据,并使用FFT算法将其转换为频谱图。这样用户可以直观地观察信号的频谱特征,了解各个频率成分的贡献以及它们之间的关系。用户可以通过设置参数和选项来调整FFT分析的精度和显示方式,以满足不同的需求和分析目的。 FFT分析工具还提供了一些额外的功能,如波形显示、峰值分析以及频谱滤波等。用户可以通过这些功能对信号进行进一步的分析和处理,以提取有用的信息和特性。 总之,PowerGUI FFT分析工具是一种方便、强大的信号分析工具,可以帮助用户深入了解和处理频域数据。它在科学研究、信号处理、音频分析等领域具有广泛的应用价值。 ### 回答3: PowerGUI FFT分析工具是一个用于进行频谱分析的工具。FFT全称为快速傅里叶变换,是一种算法,可以将一个时域信号转换为频域信号。PowerGUI FFT分析工具利用FFT算法,可以将输入的信号在频域上进行分析,以获得信号的频谱信息。 PowerGUI FFT分析工具的主要功能包括: 1. 频谱显示:工具可以将信号的频谱以直观的方式展示出来,用户可以清晰地看到信号在不同频率上的分布情况。 2. 频谱分析:工具可以对信号的频谱进行进一步分析,如计算主要频率成分、查找峰值频率等。这些信息对于理解信号的特征和性质非常有帮助。 3. 频域滤波:工具可以对信号的频谱进行滤波操作,用户可以选择性地去除或增强某些频率的成分。这对于信号处理和去噪非常有用。 4. 频率解析:工具可以对信号的频谱进行精确的频率定量分析,例如计算信号的主频率、谐波频率等。 使用PowerGUI FFT分析工具可以帮助用户更好地理解和处理信号,在信号处理、音频处理、振动分析等领域有着广泛的应用。它可以帮助工程师、科研人员等专业人士进行精确的信号分析和处理,提高工作效率和准确性。同时,它也对学生学习信号处理和频谱分析有着很好的辅助作用,帮助他们更好地理解和掌握相关知识。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值