pwr.t.test.contour: Plot a Power Contour for a t-test comparison

Description Usage Arguments Value Author(s) Examples

View source: R/convenience.R

Description

Plot a contour of sample size, effect size and power for t-test comparisons in the style of Richard Morey's jpower JAMOVI module.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
pwr.t.test.contour(
  nmin,
  nmax,
  esmin,
  esmax,
  sig.level = 0.05,
  type = c("two.sample", "one.sample", "paired"),
  alternative = c("two.sided", "less", "greater"),
  pwrbands = c(0.5, 0.8, 0.95),
  d_unitconversion = 1,
  d_units = "Cohen's d",
  alpha = 0.6
)

Arguments

nmin

Minimum sample size for the plot.

nmax

Maximum sample size for the plot.

esmin

Minimum effect size for the plot. Defaults to Cohen's d, but can be percentages or units of measurement if desired using the d_unitconversion parameter.

esmax

Maximum effect size for the plot. Defaults to Cohen's d, but can be percentages or units of measurement if desired using the d_unitconversion parameter.

sig.level

Significance level, or alpha. Defaults to 0.05.

type

The t-test type. The default is "two.sample", but other options are "paired" or "one.sample".

alternative

The alternative hypothesis. The default is "two.sided", but other options are "less" or "greater".

pwrbands

Additional black power bands to display on the figure to emphasise certain power levels. Defaults to c(0.5, 0.8, 0.95).

d_unitconversion

Unit conversion of Cohen's d. If specified as 5, for example, 5 units of change in the units of the figure are considered equivalent to Cohen's d = 1. This conversion should be calculated in advance. Defaults to 1 for Cohen's d.

d_units

The units of the difference. Defaults to "Cohen's d".

alpha

The transparency of the contours, in order to show grid lines below.

Value

A ggplot2 object.

Author(s)

Granville J Matheson, mathesong@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# A straightforward example
pwr.t.test.contour(3, 100, 0.1, 1, sig.level=0.05)

# Custom units
pwr.t.test.contour(3, 100, 0.5, 5, sig.level=0.05,
                   d_unitconversion=5, d_units="mmHg")

# Adding things
pwr.t.test.contour(3, 100, 0.5, 5, sig.level=0.05,
                   d_unitconversion=5, d_units="mmHg") +
                   ggplot2::annotate("text", x=25, y=2,
                   label="We don't want to be here")

mathesong/pwrcontour documentation built on Jan. 1, 2021, 9:19 a.m.