diff --git a/.DS_Store b/.DS_Store index e0bf89f..05e5514 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/DESCRIPTION b/DESCRIPTION index 1d181a9..5f92571 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: concurve Type: Package -Date: 2019-07-10 +Date: 2019-09-18 Title: Computes and Plots Consonance (Confidence) Intervals, P-Values, and S-Values to Form Consonance and Surprisal Functions -Version: 2.0.1 +Version: 2.1.0 Authors@R: c( person("Zad R.", "Chow", , "zad@lesslikely.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1545-8199") @@ -12,7 +12,7 @@ Authors@R: c( ) ) Maintainer: Zad R. Chow -Description: Allows one to compute consonance (confidence) intervals for various statistical tests along with their corresponding P-values and S-values. The intervals can be plotted to create consonance and surprisal functions allowing one to see what effect sizes are compatible with the test model at various consonance levels rather than being limited to one interval estimate such as 95%. These methods are discussed by Poole C. (1987) , Schweder T, Hjort NL. (2002) , Singh K, Xie M, Strawderman WE. (2007) , Rothman KJ, Greenland S, Lash TL. (2008, ISBN:9781451190052), Amrhein V, Trafimow D, Greenland S. (2019) , and Greenland S. (2019) . +Description: Allows one to compute consonance (confidence) intervals for various statistical tests along with their corresponding P-values and S-values. The intervals can be plotted to create consonance and surprisal functions allowing one to see what effect sizes are compatible with the test model at various consonance levels rather than being limited to one interval estimate such as 95%. These methods are discussed by Poole C. (1987) , Schweder T, Hjort NL. (2002) , Singh K, Xie M, Strawderman WE. (2007) , Rothman KJ, Greenland S, Lash TL. (2008, ISBN:9781451190052), Amrhein V, Trafimow D, Greenland S. (2019) , Greenland S. (2019) , Chow ZR, Greenland S. (2019) , and Greenland S, Chow ZR. (2019) . Imports: parallel, ggplot2, metafor, diff --git a/NEWS.md b/NEWS.md index 7dc398b..7edfd63 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# concurve 2.1.0 + +## Major changes +* `ggconcurve()` now plots both the P-values and CI level using both y-axes when the type = "consonance". Previously, this was only possible via `plot_concurve()` (which uses base R graphics) because `ggplot2` had a bug in its last few versions, which inhibited proper transformations in the y-axis. + # concurve 2.0.1 ## Major changes diff --git a/R/curve_rev.R b/R/curve_rev.R index 9eb1931..d6fc3dd 100644 --- a/R/curve_rev.R +++ b/R/curve_rev.R @@ -1,6 +1,6 @@ # Reverse Engineer Consonance Functions Using the Point Estimate and Confidence Limits -curve_rev <- function(point, LL, UL, measure = "default") { +curve_rev <- function(point, LL, UL, measure = "default", steps = 10000) { if (is.numeric(point) != TRUE) { stop("Error: 'x' must be a numeric vector") } @@ -14,7 +14,7 @@ curve_rev <- function(point, LL, UL, measure = "default") { stop("Error: 'measure' must be a string such as 'default' or 'ratio'") } - intrvls <- (1:10000) / 10000 + intrvls <- (1:steps) / steps z <- qnorm(1 - intrvls / 2) if (measure == "default") { diff --git a/R/ggconcurve.R b/R/ggconcurve.R index 05b33da..60c6c24 100644 --- a/R/ggconcurve.R +++ b/R/ggconcurve.R @@ -1,9 +1,8 @@ ggconcurve <- function(type = "consonance", data, measure = "default", nullvalue = "absent", position = "pyramid", title = "Consonance Function", subtitle = "The function contains consonance intervals at every level.", - caption = "Produced with the concurve R package.", xaxis = "Range of Values", - yaxis = "Consonance Level (%)", + yaxis = "P-value", color = "#555555", fill = "#239a98") { if (type == "consonance") { @@ -28,9 +27,6 @@ ggconcurve <- function(type = "consonance", data, measure = "default", nullvalue if (is.character(subtitle) != TRUE) { stop("Error: 'subtitle' must be a string.") } - if (is.character(caption) != TRUE) { - stop("Error: 'caption' must be a string.") - } if (is.character(xaxis) != TRUE) { stop("Error: 'xaxis' must be a string.") } @@ -41,53 +37,61 @@ ggconcurve <- function(type = "consonance", data, measure = "default", nullvalue stop("Error: 'fill' must be a string for the color.") } ggplot(data = data) + - geom_point(aes(x = lower.limit, y = intrvl.level * 100), + geom_point(aes(x = lower.limit, y = pvalue), color = color, fill = fill, alpha = 0.5, shape = 20, size = 0.1 ) + - geom_point(aes(x = upper.limit, y = intrvl.level * 100), + geom_point(aes(x = upper.limit, y = pvalue), color = color, fill = fill, alpha = 0.5, shape = 20, size = 0.1 ) + - geom_ribbon(aes(x = lower.limit, ymin = max(intrvl.level * 100), ymax = intrvl.level * 100), + geom_ribbon(aes(x = lower.limit, ymin = min(pvalue), ymax = pvalue), fill = fill, alpha = 0.30 ) + - geom_ribbon(aes(x = upper.limit, ymin = max(intrvl.level * 100), ymax = intrvl.level * 100), + geom_ribbon(aes(x = upper.limit, ymin = min(pvalue), ymax = pvalue), fill = fill, alpha = 0.30 ) + labs( title = title, subtitle = subtitle, - caption = caption, x = xaxis, y = yaxis ) + theme_light() + theme( - axis.title.x = element_text(size = 13), - axis.title.y = element_text(size = 13) + axis.title.x = element_text(size = 12), + axis.title.y = element_text(size = 12) ) + { if (measure == "default") scale_x_continuous(breaks = scales::pretty_breaks(n = 10)) } + { if (measure == "ratio") scale_x_log10(breaks = scales::pretty_breaks(n = 10)) } + { - if (position == "inverted") scale_y_continuous(breaks = seq(0, 100, 5), expand = c(0, 0)) + if (position == "inverted") { + scale_y_reverse( + breaks = seq(0, 1, .05), + sec.axis = sec_axis(~ (1 - .) * 100, name = "Levels for CI (%)", breaks = seq(0, 100, 5)) + ) + } } + { - if (position == "pyramid") scale_y_continuous(trans = "reverse", breaks = seq(0, 100, 5), expand = c(0, 0)) + if (position == "pyramid") { + scale_y_continuous( + breaks = seq(0, 1, .05), + sec.axis = sec_axis(~ (1 - .) * 100, name = "Levels for CI (%)", breaks = seq(0, 100, 5)) + ) + } } + - theme(text = element_text(size = 15)) + + theme(text = element_text(size = 11)) + theme( - plot.title = element_text(size = 16), - plot.subtitle = element_text(size = 12), - plot.caption = element_text(size = 8) + plot.title = element_text(size = 12), + plot.subtitle = element_text(size = 11) ) + if (nullvalue == "present") { if (measure == "default") { annotate("segment", - x = 0, xend = 0, y = 0, yend = 100, + x = 0, xend = 0, y = 0, yend = 1, color = "#990000", alpha = 0.3, size = .6 ) } else if (measure == "ratio") { annotate("segment", - x = 1, xend = 1, y = 0, yend = 100, + x = 1, xend = 1, y = 0, yend = 1, color = "#990000", alpha = 0.3, size = .6 ) } @@ -110,9 +114,6 @@ ggconcurve <- function(type = "consonance", data, measure = "default", nullvalue if (is.character(subtitle) != TRUE) { stop("Error: 'subtitle' must be a string.") } - if (is.character(caption) != TRUE) { - stop("Error: 'caption' must be a string.") - } if (is.character(xaxis) != TRUE) { stop("Error: 'xaxis' must be a string.") } @@ -136,27 +137,25 @@ ggconcurve <- function(type = "consonance", data, measure = "default", nullvalue fill = fill, alpha = 0.30 ) + labs( - title = "Surprisal Function", + title = title, subtitle = subtitle, - caption = caption, x = xaxis, y = "S-value (bits of information)" ) + theme_light() + theme( - axis.title.x = element_text(size = 13), - axis.title.y = element_text(size = 13) + axis.title.x = element_text(size = 12), + axis.title.y = element_text(size = 12) ) + { if (measure == "default") scale_x_continuous(breaks = scales::pretty_breaks(n = 10)) } + { if (measure == "ratio") scale_x_log10(breaks = scales::pretty_breaks(n = 10)) } + scale_y_continuous(breaks = seq(0, 14, 0.5), expand = c(0, 0)) + - theme(text = element_text(size = 15)) + + theme(text = element_text(size = 11)) + theme( - plot.title = element_text(size = 16), - plot.subtitle = element_text(size = 12), - plot.caption = element_text(size = 8) + plot.title = element_text(size = 12), + plot.subtitle = element_text(size = 11) ) } } diff --git a/R/plot_concurve.R b/R/plot_concurve.R index b7f16c2..c5ada9d 100644 --- a/R/plot_concurve.R +++ b/R/plot_concurve.R @@ -1,18 +1,21 @@ plot_concurve <- function(type = "consonance", data, measure = "default", + intervals = FALSE, title = "Consonance Function", xlab = "Theta", ylab1 = "P-value", ylab2 = "Confidence Level (%)", + fontsize = 12, fill = "#239a9880") { # Overall graph parameters par( + ps = fontsize, mar = c(4.5, 5, 3, 5), font.main = 1, - cex.main = 1.3, - cex.lab = 1.15 + cex.main = 1, + cex.lab = 1 ) # Consonance function @@ -86,8 +89,11 @@ plot_concurve <- function(type = "consonance", side = 4, at = c(seq(from = 0, to = 100, by = 10)), tck = 1, lty = 2, col = "grey", las = 1 ) - text(par("usr") + 0.95, 28, - srt = -90, adj = 0, labels = "Consonance Level (%)", cex = 1.05, + + # 0.95, 28 + + text(par("usr") + 1, 15, + srt = -90, adj = 0, labels = ylab2, cex = 1, xpd = TRUE ) par(new = T) @@ -97,7 +103,7 @@ plot_concurve <- function(type = "consonance", ) # Labels for interval estimates and maximum likelihood - + if (intervals == TRUE) { text( x = 1.27, y = 3, paste( @@ -142,6 +148,7 @@ plot_concurve <- function(type = "consonance", ), cex = 0.93, col = "black" ) + } } # Surprisal function @@ -154,9 +161,9 @@ plot_concurve <- function(type = "consonance", xlim = c(min(lower.limit), max(upper.limit)), panel.first = grid(), type = "l", - xlab = "Theta", - ylab = "S-value", - main = "Surpisal Function", + xlab = xlab, + ylab = "S-value (bits of information)", + main = title, yaxt = "n", las = 1 ) @@ -166,9 +173,9 @@ plot_concurve <- function(type = "consonance", xlim = c(min(lower.limit), max(upper.limit)), panel.first = grid(), type = "l", - xlab = "Theta", - ylab = "S-value", - main = "Surpisal Function", + xlab = xlab, + ylab = "S-value (bits of information)", + main = title, yaxt = "n", las = 1, log = "x" diff --git a/README.Rmd b/README.Rmd index f3516bc..c286d42 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,8 +18,8 @@ concurve | Graph Interval Functions - + + * * * @@ -96,3 +96,5 @@ install_github("zadchow/concurve") 7. Amrhein V, Trafimow D, Greenland S. Inferential Statistics as Descriptive Statistics: There is No Replication Crisis if We Don't Expect Replication. _Am Stat_. 2019 8. Greenland S. Valid P-values Behave Exactly As They Should. Some misleading criticisms of P-values and their resolution with S-values. _Am Stat_. 2019;18(136). 9. Fraser DAS. The p-value Function and Statistical Inference. _Am Stat_. 2019 +10. Chow ZR, Greenland S. Semantic and Cognitive Tools to Aid Statistical Inference: Replace Confidence and Significance by Compatibility and Surprise. _arXiv:1909.08579 [stat.ME]_. 2019 +11. Greenland S, Chow ZR. To Aid Statistical Inference, Emphasize Unconditional Descriptions of Statistics. _arXiv:1909.08583 [stat.ME]_. 2019 diff --git a/README.md b/README.md index d7641ac..22d3241 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ status](https://ci.appveyor.com/api/projects/status/v8sp9x96dap2om9s?svg=true)]( # Examples - - + + ----- @@ -114,3 +114,9 @@ install_github("zadchow/concurve") S-values. *Am Stat*. 2019;18(136). 9. Fraser DAS. The p-value Function and Statistical Inference. *Am Stat*. 2019 +10. Chow ZR, Greenland S. Semantic and Cognitive Tools to Aid + Statistical Inference: Replace Confidence and Significance by + Compatibility and Surprise. *arXiv:1909.08579 \[stat.ME\]*. 2019 +11. Greenland S, Chow ZR. To Aid Statistical Inference, Emphasize + Unconditional Descriptions of Statistics. *arXiv:1909.08583 + \[stat.ME\]*. 2019 diff --git a/_pkgdown.yml b/_pkgdown.yml index a3f8c64..5438c4f 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -33,8 +33,10 @@ navbar: articles: text: Articles menu: - - text: Examples With Simulated Data + - text: Examples in R href: articles/examples.html + - text: Using Stata + href: articles/stata.html news: text: News href: news/index.html diff --git a/codemeta.json b/codemeta.json index 5f4ab49..3842882 100644 --- a/codemeta.json +++ b/codemeta.json @@ -5,7 +5,7 @@ ], "@type": "SoftwareSourceCode", "identifier": "concurve", - "description": "Allows one to compute consonance (confidence) intervals for various statistical tests along with their corresponding P-values and S-values. The intervals can be plotted to create consonance and surprisal functions allowing one to see what effect sizes are compatible with the test model at various consonance levels rather than being limited to one interval estimate such as 95%. These methods are discussed by Poole C. (1987) , Schweder T, Hjort NL. (2002) , Singh K, Xie M, Strawderman WE. (2007) , Rothman KJ, Greenland S, Lash TL. (2008, ISBN:9781451190052), Amrhein V, Trafimow D, Greenland S. (2019) , and Greenland S. (2019) .", + "description": "Allows one to compute consonance (confidence) intervals for various statistical tests along with their corresponding P-values and S-values. The intervals can be plotted to create consonance and surprisal functions allowing one to see what effect sizes are compatible with the test model at various consonance levels rather than being limited to one interval estimate such as 95%. These methods are discussed by Poole C. (1987) , Schweder T, Hjort NL. (2002) , Singh K, Xie M, Strawderman WE. (2007) , Rothman KJ, Greenland S, Lash TL. (2008, ISBN:9781451190052), Amrhein V, Trafimow D, Greenland S. (2019) , Greenland S. (2019) , Chow ZR, Greenland S. (2019) , and Greenland S, Chow ZR. (2019) .", "name": "concurve: Computes and Plots Consonance (Confidence) Intervals, P-Values, and S-Values to Form Consonance and Surprisal Functions", "date": "2019-05-10", "codeRepository": "https://github.com/Zadchow/concurve", @@ -16,7 +16,7 @@ ], "issueTracker": "https://github.com/Zadchow/concurve/issues", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "2.0.1", + "version": "2.1.0", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", @@ -184,7 +184,7 @@ } ], "keywords": ["confidence", "compatibility", "consonance", "surprisal", "interval", "function", "curve"], - "fileSize": "3936.013KB", + "fileSize": "3833.993KB", "contIntegration": [ "https://travis-ci.org/Zadchow/concurve", "https://ci.appveyor.com/project/Zadchow/concurve", diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..375b745 --- /dev/null +++ b/docs/404.html @@ -0,0 +1,193 @@ + + + + + + + + +Page not found (404) • concurve + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +Content not found. Please use links in the navbar. + +
+ +
+ + + + +
+ + + + + + + + + + + diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index cb9a033..9a55734 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -15,21 +15,25 @@ + + - + + - - + + + @@ -45,13 +49,14 @@ - + + @@ -62,6 +67,7 @@ + @@ -78,7 +84,7 @@ concurve - 2.0.1 + 2.1.0 @@ -112,7 +118,6 @@ News - -