get_p_value: Compute p-value

Description Usage Arguments Value Aliases Examples

View source: R/get_p_value.R

Description

Simulation-based methods are (currently only) supported.

Usage

1
2
3
get_p_value(x, obs_stat, direction)

get_pvalue(x, obs_stat, direction)

Arguments

x

Data frame of calculated statistics as returned by generate()

obs_stat

A numeric value or a 1x1 data frame (as extreme or more extreme than this).

direction

A character string. Options are "less", "greater", or "two_sided". Can also use "left", "right", or "both".

Value

A 1x1 tibble with value between 0 and 1.

Aliases

get_pvalue() is an alias of get_p_value(). p_value is a deprecated alias of get_p_value().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Prepare the dataset
mtcars_df <- mtcars %>%
  dplyr::mutate(am = factor(am))

# Calculate the difference in means in the dataset
d_hat <- mtcars_df %>%
  specify(mpg ~ am) %>%
  calculate(stat = "diff in means", order = c("1", "0"))

# Same calculation on 100 permutation replicates
null_distn <- mtcars_df %>%
  specify(mpg ~ am) %>%
  hypothesize(null = "independence") %>%
  generate(reps = 100) %>%
  calculate(stat = "diff in means", order = c("1", "0"))

# What proportion of replicates had a difference
# in means more extreme than in the dataset?
null_distn %>%
  get_p_value(obs_stat = d_hat, direction = "right")

andrewpbray/infer documentation built on Aug. 29, 2019, 5:57 a.m.