Learn R Programming

SciencesPo (version 1.3.9)

samplePower: Calculate and plot power of a sample

Description

Calculates and plots power of a sample z-test of a sample mean mu1 against a population mean mu0 (H_{0}: mu0 = mu1, H_{1}: mu0 <> mu1).

Usage

samplePower(mu0 = 0, mu1 = 0, sigma = 1, n = 100, alpha = 0.05)

Arguments

mu0
This should be the "known" mean value for your population.
mu1
This should be the "expected" mean value from your sample. The delta between mu(0) and mu(1) is what you should consider a significant difference for the test.
sigma
This should be the known sigma (standard deviation) for the population.
n
The sample size.
alpha
This is the significance level, default is alpha(twosided) = .05.

Value

  • n the sample size; sigma the standard deviation; SE the standard error of the mean; mu0 the mean of H_{0} in the population; mu1 the sample mean; mean.crit the critical value of sample mean to achieve significance; ES the population "effect" size gamma; delta the effect size delta (Cohen); alpha the significance level alpha (twosided); power the power (1-beta).

Details

sample.power calculates the power of a one-sample z-test (twosided) and plots the density distributions under the assumption of of H_{0}: m = mu0 and H_{1}: m = mu1. The rejection regions of H_{0} (alpha) are colored blue, while the rejection region of H_{1} (beta) is colored red.

Examples

Run this code
samplePower(mu0=68, mu1=69, sigma=3.1, n=100)
## gives a power of .90

Run the code above in your browser using DataLab