norm_pval: Visualization of p-values for basic hypothesis tests with the...

Description Usage Arguments Value Author(s) Examples

View source: R/norm.R

Description

Given z ~ N(μ,σ^2) the function calculates the p-value and visualizes the result as the area under the density function. Furthermore the mean and the values one and two standard deviations from the mean are highlighted.

Usage

1
2
norm_pval(z_value = 0, mean = 0, sd = 1, direction = c("extreme",
  "less", "greater", "both"))

Arguments

z_value

The value of a test statistic with the underlying normal distribution

(values that are very far away from the mean - roughly more than 4 times the standard deviation - are not recommend to use as the p-value will be approximately 0 or 1 anyways)

mean

The mean of the underlying normal distribution (default is 0).

sd

The standard deviation of the underlying normal distribution (default is 1).

direction

The 'direction' of the test with respect to z:

extreme (default)

The p-value will be calculated using min(P(X ≤ z),P(X ≥ z)) with X~N(μ,σ^2)

less

The p-value will be calculated using P(X ≤ z) with X~N(μ,σ^2)

greater

The p-value will be calculated using P(X ≥ z) with X~N(μ,σ^2)

both

The p-value will be calculated using 2*min(P(X ≤ z),P(X ≥ z)) with X~N(μ,σ^2)

So for the first three options a one sided hypothesis gets tested and for the last one a two sided hypothesis is tested.

Value

a ggplot2 object displaying the results

Author(s)

Emanuel Sommer

Examples

1
2
norm_pval(-2)
norm_pval(z_value = 100, mean = 120, sd = 20, direction = "both")

EmanuelSommer/PvalVis documentation built on Nov. 20, 2020, 1:34 a.m.