Compute a p-value from a null distribution and observed statistc. Simulation-based methods are (currently only) supported.
Learn more in vignette("infer")
.
get_p_value(x, obs_stat, direction) get_pvalue(x, obs_stat, direction)
x | Data frame of calculated statistics as returned by |
---|---|
obs_stat | A numeric value or a 1x1 data frame (as extreme or more extreme than this). |
direction | A character string. Options are |
A 1x1 tibble with value between 0 and 1.
get_pvalue()
is an alias of get_p_value()
.
p_value
is a deprecated alias of get_p_value()
.
# find the point estimate---mean number of hours worked per week point_estimate <- gss %>% specify(response = hours) %>% calculate(stat = "mean") %>% dplyr::pull()#> Warning: Removed 1244 rows containing missing values.# starting with the gss dataset gss %>% # ...we're interested in the number of hours worked per week specify(response = hours) %>% # hypothesizing that the mean is 40 hypothesize(null = "point", mu = 40) %>% # generating data points for a null distribution generate(reps = 10000, type = "bootstrap") %>% # finding the null distribution calculate(stat = "mean") %>% get_p_value(obs_stat = point_estimate, direction = "two_sided")#> Warning: Removed 1244 rows containing missing values.#> # A tibble: 1 x 1 #> p_value #> <dbl> #> 1 0.0182#> Warning: vignette ‘infer’ not found