Skip to content

Commit

Permalink
version 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Infanger authored and cran-robot committed Nov 29, 2019
1 parent 33dfa71 commit 2db7578
Show file tree
Hide file tree
Showing 11 changed files with 477 additions and 429 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
Expand Up @@ -2,22 +2,22 @@ Package: pvaluefunctions
Type: Package
Title: Creates and Plots P-Value Functions, S-Value Functions,
Confidence Distributions and Confidence Densities
Version: 1.4.0
Version: 1.5.0
Authors@R: person("Denis", "Infanger", email = "denis.infanger@unibas.ch", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9028-7110"))
Maintainer: Denis Infanger <denis.infanger@unibas.ch>
Description: Contains functions to compute and plot confidence distributions, confidence densities, p-value functions and s-value (surprisal) functions for several commonly used estimates. Instead of just calculating one p-value and one confidence interval, p-value functions display p-values and confidence intervals for many levels thereby allowing to gauge the compatibility of several parameter values with the data. These methods are discussed by Infanger D, Schmidt-Trucksäss A. (2019) <doi:10.1002/sim.8293>; Poole C. (1987) <doi:10.2105/AJPH.77.2.195>; Schweder T, Hjort NL. (2002) <doi:10.1111/1467-9469.00285>; Bender R, Berg G, Zeeb H. (2005) <doi:10.1002/bimj.200410104> ; Singh K, Xie M, Strawderman WE. (2007) <doi:10.1214/074921707000000102>; Rothman KJ, Greenland S, Lash TL. (2008, ISBN:9781451190052); Amrhein V, Trafimow D, Greenland S. (2019) <doi:10.1080/00031305.2018.1543137>; and Greenland S. (2019) <doi:10.1080/00031305.2018.1529625>.
Depends: R (>= 3.1.0)
Imports: ggplot2 (>= 3.1.1), scales (>= 1.0.0), zipfR (>= 0.6-10),
Imports: ggplot2 (>= 3.2.1), scales (>= 1.1.0), zipfR (>= 0.6-66),
stats
Suggests: knitr, rmarkdown, devtools
License: GPL-3
URL: https://github.com/DInfanger/pvaluefunctions
VignetteBuilder: knitr
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.0.1
NeedsCompilation: no
Packaged: 2019-07-29 10:11:41 UTC; denis
Packaged: 2019-11-28 16:18:24 UTC; denis
Author: Denis Infanger [aut, cre] (<https://orcid.org/0000-0001-9028-7110>)
Repository: CRAN
Date/Publication: 2019-07-29 10:30:02 UTC
Date/Publication: 2019-11-29 19:30:02 UTC
20 changes: 10 additions & 10 deletions MD5
@@ -1,16 +1,16 @@
8bac1519d3b70342b71c6da01b161c5a *DESCRIPTION
f4e77ba3810347894cacc5e5b68da3c0 *NAMESPACE
432f7c368403a84d8c7eb4cda3c5f4e7 *NEWS.md
857de638980826a182058eaeb581a529 *R/confidence_distributions.R
2e00cc6973ec02d032d81f028bf97549 *README.md
de48818d4f845bdb6bd4aa34b465ede4 *DESCRIPTION
3409f9c443502b59ae0ad5470176af68 *NAMESPACE
2c6b403d7ba9c1f151d0d3868912c087 *NEWS.md
50c765ca454c7ec1275c12a0b7e3128d *R/confidence_distributions.R
d5a552f9cec9e869a4ada9c7837c653b *README.md
74eefc761dce35d2d65c8015f7ca0786 *build/vignette.rds
0f8cd72defecc9bfe64f4f2c90ce1d8f *inst/doc/pvaluefun.R
e8ca070218f0d915bc92e46cef44a1d2 *inst/doc/pvaluefun.Rmd
5c84400fcda421accac14043de11e382 *inst/doc/pvaluefun.html
d07ff02d3da2633b39a22cecc9f899b2 *man/conf_dist.Rd
154b5bc5c2f4cdf2e7cecdd2553640a2 *inst/doc/pvaluefun.R
324f4e4961c5f7e5462d3856505411a9 *inst/doc/pvaluefun.Rmd
c031fdd00e77b223629be8b2515e1862 *inst/doc/pvaluefun.html
e6633ca7aae7c9fad21342643bfc575d *man/conf_dist.Rd
980cb17e2b55086ed935ceb30719966c *man/figures/README-benderfig1-1.png
0f6a5b495f94aac63300fe76cf7ebc60 *man/figures/README-ttest_pval-1.png
45b1828f89a32887dff20ed1cab87bdf *man/figures/README-ttest_sval-1.png
70f0280813823dfe841f21813465f121 *man/figures/logo.svg
f8ad09a83a4bae484432532e94a6c95d *man/figures/logo2.svg
e8ca070218f0d915bc92e46cef44a1d2 *vignettes/pvaluefun.Rmd
324f4e4961c5f7e5462d3856505411a9 *vignettes/pvaluefun.Rmd
2 changes: 1 addition & 1 deletion NAMESPACE
@@ -1,4 +1,4 @@
# Generated by roxygen2: do not edit by hand
# Generated by roxygen2: do not edit by hand

export(conf_dist)
import(ggplot2)
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
@@ -1,5 +1,13 @@
## NEWS and changes for the pvaluefunctions package


1.5.0
-------------

* Vignette, README and DESCRIPTION updated to reflect that the newest version of ggplot2 (3.2.1) fixes the former bug with `sec_axis`.
* Added an option `plot` to `conf_dist` that controls whether a plot is created or not. If users want to create their own plots, they can set this option to `FALSE` and use the returned data (`res_frame`) which is the basis for the plots to create them.


1.4.0
-------------

Expand Down
24 changes: 18 additions & 6 deletions R/confidence_distributions.R
Expand Up @@ -41,13 +41,14 @@ if (getRversion() >= "2.15.1") {
#' @param ylab_sec (optional) String indicating the title for the secondary (right) y-axis.
#' @param inverted Logical. Indicating the orientation of the y-axis for the \emph{P}-value function (\code{p_val}), S-value function (\code{s_val}) and the confidence distribution (\code{cdf}). By default (i.e. \code{inverted = FALSE}) small \emph{P}-values are plotted at the bottom and large ones at the top so that the cusp of the \emph{P}-value function is a the top. By setting \code{inverted = TRUE}, the y-axis is inverted. Ignored for confidence densities.
#' @param x_scale String indicating the scaling of the x-axis. The default is to scale the x-axis logarithmically if the transformation specified in \code{trans} is "exp" (exponential) and linearly otherwise. The option \code{linear} (can be abbreviated) forces a linear scaling and the option \code{logarithm} (can be abbreviated) forces a logarithmic scaling, regardless what has been specified in \code{trans}.
#'
#' @return \code{conf_dist} returns four data frames and a ggplot2-plot object: \code{res_frame} (contains parameter values, \emph{p}-values (one- and two-sided), s-values, confidence distribution and density, variable names and type of hypothesis), \code{conf_frame} (contains the specified confidence level(s) and the corresponding lower and upper limits as well as the corresponding variable name), \code{counternull_frame} (contains the counternull and the corresponding null values), \code{point_est} (contains the mean, median and mode point estimates) and \code{plot} (a ggplot2-plot object).
#' @param plot Logical. Should a plot be created (\code{TRUE}, the default) or not (\code{FALSE}). \code{FALSE} can be useful if users want to create their own plots using the returned data from the function. If \code{FALSE}, no ggplot2 object is returned.

#' @return \code{conf_dist} returns four data frames and if \code{plot = TRUE} was specified, a ggplot2-plot object: \code{res_frame} (contains parameter values (e.g. mean differences, odds ratios etc.), \emph{p}-values (one- and two-sided), s-values, confidence distributions and densities, variable names and type of hypothesis), \code{conf_frame} (contains the specified confidence level(s) and the corresponding lower and upper limits as well as the corresponding variable name), \code{counternull_frame} (contains the counternull and the corresponding null values), \code{point_est} (contains the mean, median and mode point estimates) and if \code{plot = TRUE} was specified, \code{plot} (a ggplot2 object).
#' @references Bender R, Berg G, Zeeb H. Tutorial: using confidence curves in medical research. \emph{Biom J.} 2005;47(2):237-247.
#'
#' Bonett DG, Wright TA. Sample size requirements for estimating Pearson, Kendall and Spearman correlations. \emph{Psychometrika.} 2000;65(1):23-28.
#'
#' Infanger D, Schmidt-Trucksäss A. \emph{P} value functions: An underused method to present research results and to promote quantitative reasoning. \emph{Stat Med.} 2019;1-9.
#' Infanger D, Schmidt-Trucksäss A. \emph{P} value functions: An underused method to present research results and to promote quantitative reasoning. \emph{Stat Med.} 2019;38:4189-4197.
#'
#' Newcombe RG. Interval estimation for the difference between independent proportions: comparison of eleven methods. \emph{Stat Med.} 1998;17:873-890.
#'
Expand Down Expand Up @@ -94,6 +95,7 @@ if (getRversion() >= "2.15.1") {
#' , ylab_sec = NULL
#' , inverted = FALSE
#' , x_scale = "default"
#' , plot = TRUE
#' )
#'
#' #======================================================================================
Expand Down Expand Up @@ -125,6 +127,7 @@ if (getRversion() >= "2.15.1") {
#' , ylab_sec = NULL
#' , inverted = FALSE
#' , x_scale = "default"
#' , plot = TRUE
#' )
#'
#' #=======================================================================================
Expand Down Expand Up @@ -154,6 +157,7 @@ if (getRversion() >= "2.15.1") {
#' , ylab_sec = NULL
#' , inverted = TRUE
#' , x_scale = "default"
#' , plot = TRUE
#' )
#'
#' #======================================================================================
Expand Down Expand Up @@ -181,6 +185,7 @@ if (getRversion() >= "2.15.1") {
#' , ylab_sec = NULL
#' , inverted = FALSE
#' , x_scale = "default"
#' , plot = TRUE
#' )
#'
#' #======================================================================================
Expand Down Expand Up @@ -228,6 +233,7 @@ if (getRversion() >= "2.15.1") {
#' , ylab_sec = NULL
#' , inverted = FALSE
#' , x_scale = "default"
#' , plot = TRUE
#' )
#'
#' #========================================================================================
Expand Down Expand Up @@ -266,6 +272,7 @@ if (getRversion() >= "2.15.1") {
#' , inverted = TRUE
#' , title = "Figure 1 in Bender et al. (2005)"
#' , x_scale = "default"
#' , plot = TRUE
#' )
#'
#' @seealso \code{\link[concurve]{ggconcurve}}
Expand Down Expand Up @@ -303,6 +310,7 @@ conf_dist <- function(
, ylab_sec = NULL
, inverted = FALSE
, x_scale = c("default", "linear", "logarithm")
, plot = TRUE
) {

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -851,6 +859,8 @@ conf_dist <- function(
# Plot using ggplot2
#-----------------------------------------------------------------------------



# Create custom y-axis scale (mixed linear and logarithmic)

# Transform cutoff for log-y-axis if applicable
Expand Down Expand Up @@ -1314,9 +1324,11 @@ conf_dist <- function(
p <- p + ggtitle(title)
}

res$plot <- p

suppressWarnings(print(p))
# Only print and return the plot object if requested
if (isTRUE(plot)) {
res$plot <- p
suppressWarnings(print(p))
}

return(res)

Expand Down
63 changes: 27 additions & 36 deletions README.md
Expand Up @@ -9,7 +9,6 @@ pvaluefunctions
- [Overview](#overview)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [Important information\!](#important-information)
- [Examples](#examples)
- [References](#references)
- [Contact](#contact)
Expand All @@ -33,7 +32,8 @@ 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,* 1-9. doi: 10.1002/sim.8293.
reasoning. *Statistics in Medicine.* **38**: 4189-4197. doi:
10.1002/sim.8293.

### Recreation of the figures in the paper

Expand Down Expand Up @@ -62,31 +62,22 @@ using `library(pvaluefunctions)`.
The function depends on the following R packages, which need to be
installed beforehand:

- ggplot2
- ggplot2 (at least version 3.2.1)
- scales
- zipfR

Use the command `install.packages(c("ggplot2", "scales", "zipfR"))` in R
to install those packages.

### Important information\!
<!-- ### Important information! -->

The newest version of [ggplot2
(3.1.1)](https://CRAN.R-project.org/package=ggplot2) has a
[bug](https://github.com/tidyverse/ggplot2/issues/2978) in `sec_axis`
that will lead to the secondary y-axis being labelled wrongly.
<!-- The newest version of [ggplot2 (3.1.1)](https://CRAN.R-project.org/package=ggplot2) has a [bug](https://github.com/tidyverse/ggplot2/issues/2978) in `sec_axis` that will lead to the secondary y-axis being labelled wrongly. -->

It is therefore recommended that you install the developmental version
of ggplot2 until the bug has been fixed. You can install the
developmental version using the following command (after installing the
[`devtools`](https://CRAN.R-project.org/package=devtools) package):
`devtools::install_github("tidyverse/ggplot2")`
<!-- It is therefore recommended that you install the developmental version of ggplot2 until the bug has been fixed. You can install the developmental version using the following command (after installing the [`devtools`](https://CRAN.R-project.org/package=devtools) package): `devtools::install_github("tidyverse/ggplot2")` -->

To see what version of ggplot2 has been used to create the plots on this
page, see the [Session info](#session-info).
<!-- To see what version of ggplot2 has been used to create the plots on this page, see the [Session info]. -->

This warning will be deleted upon the release of a new version of
ggplot2 that fixes the bug.
<!-- This warning will be deleted upon the release of a new version of ggplot2 that fixes the bug. -->

## Examples

Expand All @@ -113,7 +104,7 @@ Misleading Criticisms of *P*-Values and Their Resolution with

Infanger D, Schmidt-Trucksäss A. (2019): *P* value functions: An
underused method to present research results and to promote quantitative
reasoning. *Stat Med,* 1-9. doi: 10.1002/sim.8293.
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.
Expand Down Expand Up @@ -157,26 +148,26 @@ distribution estimator of a parameter: A review. *Internat Statist Rev.*
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] pvaluefunctions_1.4.0
#> [1] pvaluefunctions_1.5.0
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_1.0.2 pillar_1.4.2 compiler_3.6.1
#> [4] prettyunits_1.0.2 remotes_2.1.0 tools_3.6.1
#> [7] testthat_2.2.1 digest_0.6.20 pkgbuild_1.0.3
#> [10] pkgload_1.0.2 tibble_2.1.3 gtable_0.3.0
#> [13] evaluate_0.14 memoise_1.1.0 pkgconfig_2.0.2
#> [16] rlang_0.4.0 cli_1.1.0 curl_4.0
#> [19] yaml_2.2.0 xfun_0.8 dplyr_0.8.3
#> [22] withr_2.1.2 stringr_1.4.0 knitr_1.23
#> [25] desc_1.2.0 fs_1.3.1 devtools_2.1.0
#> [28] tidyselect_0.2.5 rprojroot_1.3-2 grid_3.6.1
#> [31] glue_1.3.1 R6_2.4.0 processx_3.4.1
#> [34] rmarkdown_1.14 sessioninfo_1.1.1 purrr_0.3.2
#> [37] callr_3.3.1 ggplot2_3.2.0.9000 magrittr_1.5
#> [40] scales_1.0.0 backports_1.1.4 ps_1.3.0
#> [43] htmltools_0.3.6 usethis_1.5.1 assertthat_0.2.1
#> [46] colorspace_1.4-1 stringi_1.4.3 lazyeval_0.2.2
#> [49] munsell_0.5.0 crayon_1.3.4
#> [1] Rcpp_1.0.2 pillar_1.4.2 compiler_3.6.1
#> [4] prettyunits_1.0.2 remotes_2.1.0 tools_3.6.1
#> [7] testthat_2.2.1 digest_0.6.20 pkgbuild_1.0.4
#> [10] pkgload_1.0.2 tibble_2.1.3 gtable_0.3.0
#> [13] evaluate_0.14 memoise_1.1.0 pkgconfig_2.0.2
#> [16] rlang_0.4.0 cli_1.1.0 curl_4.0
#> [19] yaml_2.2.0 xfun_0.8 dplyr_0.8.3
#> [22] withr_2.1.2 stringr_1.4.0 knitr_1.24
#> [25] desc_1.2.0 fs_1.3.1 devtools_2.1.0
#> [28] tidyselect_0.2.5 rprojroot_1.3-2 grid_3.6.1
#> [31] glue_1.3.1 R6_2.4.0 processx_3.4.1
#> [34] rmarkdown_1.14 sessioninfo_1.1.1 purrr_0.3.2
#> [37] callr_3.3.1 ggplot2_3.2.1 magrittr_1.5
#> [40] scales_1.0.0 backports_1.1.4 ps_1.3.0
#> [43] htmltools_0.3.6 usethis_1.5.1 assertthat_0.2.1
#> [46] colorspace_1.4-1 stringi_1.4.3 lazyeval_0.2.2
#> [49] munsell_0.5.0 crayon_1.3.4

## License

Expand Down
7 changes: 5 additions & 2 deletions inst/doc/pvaluefun.R
@@ -1,4 +1,4 @@
## ----setup, include = FALSE, echo = FALSE--------------------------------
## ----setup, include = FALSE, echo = FALSE-------------------------------------
knitr::opts_chunk$set(
collapse = TRUE
, comment = "#>"
Expand Down Expand Up @@ -45,8 +45,10 @@ res <- conf_dist(
, plot_p_limit = 1 - 0.999
, plot_counternull = TRUE
, x_scale = "line"
, plot = TRUE
)


## ----linreg_single_pval, message = FALSE, warning = FALSE, fig.width = 9, fig.height = 7, out.width = "80%", fig.align='center', dev = "png", dev.args = list(type = "cairo-png"), dpi = 200----
#-----------------------------------------------------------------------------
# Model
Expand Down Expand Up @@ -79,6 +81,7 @@ res <- conf_dist(
, together = FALSE
, plot_p_limit = 1 - 0.999
, plot_counternull = FALSE
, plot = TRUE
)

## ----linreg_single_cdf, message = FALSE, warning = FALSE, fig.width = 9, fig.height = 7, out.width = "80%", fig.align='center', dev = "png", dev.args = list(type = "cairo-png"), dpi = 200----
Expand Down Expand Up @@ -408,6 +411,6 @@ res <- conf_dist(
rm(rse_fun, rse_fun_inv)


## ----session_info, include=TRUE, echo=FALSE------------------------------
## ----session_info, include=TRUE, echo=FALSE-----------------------------------
sessionInfo()

0 comments on commit 2db7578

Please sign in to comment.