knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-" )
We published an accompanying paper to illustrate the use of p-value functions:
Infanger D, Schmidt-Trucksäss A. (2019): P value functions: An underused method to present research results and to promote quantitative reasoning. Statistics in Medicine. 38: 4189-4197. doi: 10.1002/sim.8293.
The code and instructions to reproduce all graphics in our paper can be found in the following GitHub repository: https://github.com/DInfanger/pvalue_functions
This is the repository for the R-package pvaluefunctions
. The package contains R functions to create graphics of p-value functions, confidence distributions, confidence densities, or the Surprisal value (S-value) (Greenland 2019).
You can install the package directly from CRAN by typing install.packages("pvaluefunctions")
. After installation, load it in R using library(pvaluefunctions)
.
library(devtools) # Load main function source_url("https://raw.githubusercontent.com/DInfanger/pvaluefunctions/master/R/confidence_distributions.R")
The function depends on the following R packages, which need to be installed beforehand:
Use the command install.packages(c("ggplot2", "scales", "zipfR", "pracma", "gsl"))
in R to install those packages.
For more examples and code, see the vignette.
# devtools::install_github("DInfanger/pvaluefunctions") library(pvaluefunctions) #----------------------------------------------------------------------------- # Create p-value function #----------------------------------------------------------------------------- res <- conf_dist( estimate = c(-1.58) , df = c(17.77647) , tstat = c(-1.860813) , type = "ttest" , plot_type = "p_val" , n_values = 1e4L # , est_names = c("") , conf_level = c(0.95, 0.90, 0.80) , null_values = c(0) , trans = "identity" , alternative = "two_sided" , log_yaxis = FALSE , cut_logyaxis = 0.05 , xlab = "Mean difference (group 1 - group 2)" , together = FALSE , plot_p_limit = 1 - 0.999 , plot_counternull = TRUE , inverted = FALSE , title = expression(italic(P)~"-value function for a"~italic(t)~"-test") , plot = TRUE )
#----------------------------------------------------------------------------- # Create s-value function #----------------------------------------------------------------------------- res <- conf_dist( estimate = c(-1.58) , df = c(17.77647) , tstat = c(-1.860813) , type = "ttest" , plot_type = "s_val" , n_values = 1e4L # , est_names = c("") , conf_level = c(0.95, 0.90, 0.80) , null_values = c(0) , trans = "identity" , alternative = "two_sided" , log_yaxis = FALSE , cut_logyaxis = 0.05 , xlab = "Mean difference (group 1 - group 2)" , together = FALSE , col = "#C977A2" , plot_p_limit = 1 - 0.999 , plot_counternull = TRUE , inverted = FALSE , title = expression(italic(S)~"-value function for a"~italic(t)~"-test") )
rse_fun <- function(x){ 100*(1 - exp(x)) } rse_fun_inv <- function(x){ log(1 - (x/100)) } res <- conf_dist( estimate = c(log(0.72)) , stderr = (0.187618) , type = "coxreg" , plot_type = "p_val" , n_values = 1e4L , est_names = c("RSE") , conf_level = c(0.95, 0.8, 0.5) , null_values = rse_fun_inv(c(0)) , trans = "rse_fun" , alternative = "two_sided" , log_yaxis = FALSE , cut_logyaxis = 0.05 , xlab = "Relative survival effect (1 - HR%)" , xlim = rse_fun_inv(c(-30, 60)) , together = FALSE , plot_p_limit = 1 - 0.999 , plot_counternull = TRUE , inverted = TRUE , title = "Figure 1 in Bender et al. (2005)" )
Bender R, Berg G, Zeeb H. (2005): Tutorial: using confidence curves in medical research. Biom J. 47(2): 237-47.
Berrar D (2017): Confidence Curves: an alternative to null hypothesis significance testing for the comparison of classifiers. Mach Learn. 106:911-949.
Fraser D. A. S. (2019): The p-value function and statistical inference. Am Stat. 73:sup1, 135-147.
Greenland S (2019): Valid P-Values Behave Exactly as They Should: Some Misleading Criticisms of P-Values and Their Resolution with S-Values. Am Stat. 73sup1, 106-114.
Infanger D, Schmidt-Trucksäss A. (2019): P value functions: An underused method to present research results and to promote quantitative reasoning. Stat Med. 38, 4189-4197. doi: 10.1002/sim.8293.
Poole C. (1987a): Beyond the confidence interval. Am J Public Health. 77(2): 195-9.
Poole C. (1987b): Confidence intervals exclude nothing. Am J Public Health. 77(4): 492-3.
Rafi Z, Greenland S. (2020): Semantic and cognitive tools to aid statistical science: replace confidence and significance by compatibility and surprise. BMC Med Res Methodol. 20, 244. doi: 10.1186/s12874-020-01105-9.
Rosenthal R, Rubin DB. (1994): The counternull value of an effect size: A new statistic. Psychol Sci. 5(6): 329-34.
Schweder T, Hjort NL. (2016): Confidence, likelihood, probability: statistical inference with confidence distributions. New York, NY: Cambridge University Press.
Xie M, Singh K, Strawderman WE. (2011): Confidence Distributions and a Unifying Framework for Meta-Analysis. J Am Stat Assoc. 106(493): 320-33. doi: 10.1198/jasa.2011.tm09803.
Xie Mg, Singh K. (2013): Confidence distribution, the frequentist distribution estimator of a parameter: A review. Internat Statist Rev. 81(1): 3-39.
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.