{"id":20065949,"url":"https://github.com/hneth/riskyr","last_synced_at":"2025-07-06T20:36:28.132Z","repository":{"id":50649950,"uuid":"113996718","full_name":"hneth/riskyr","owner":"hneth","description":"A toolbox for rendering risk literacy more transparent","archived":false,"fork":false,"pushed_at":"2025-06-05T12:45:49.000Z","size":480438,"stargazers_count":18,"open_issues_count":7,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-05T13:43:26.368Z","etag":null,"topics":["2x2-matrix","bayesian-inference","contingency-table","r","r-package","representation","risk","risk-literacy","rstats","visualization"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hneth.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-12T13:56:30.000Z","updated_at":"2025-06-05T12:45:50.000Z","dependencies_parsed_at":"2024-11-13T14:03:49.603Z","dependency_job_id":null,"html_url":"https://github.com/hneth/riskyr","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/hneth/riskyr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hneth%2Friskyr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hneth%2Friskyr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hneth%2Friskyr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hneth%2Friskyr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hneth","download_url":"https://codeload.github.com/hneth/riskyr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hneth%2Friskyr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263965153,"owners_count":23536791,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2x2-matrix","bayesian-inference","contingency-table","r","r-package","representation","risk","risk-literacy","rstats","visualization"],"created_at":"2024-11-13T13:53:37.556Z","updated_at":"2025-07-06T20:36:28.106Z","avatar_url":"https://github.com/hneth.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please only edit this (.Rmd) file! --\u003e\n\n\u003c!-- Devel badges start: --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/riskyr)](https://CRAN.R-project.org/package=riskyr) \n[![Downloads/month](https://cranlogs.r-pkg.org/badges/riskyr?color='00a9e0')](https://www.r-pkg.org:443/pkg/riskyr) \n[![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/riskyr?color=blue)](https://www.r-pkg.org/pkg/riskyr) \n[![R-CMD-check](https://github.com/hneth/riskyr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hneth/riskyr/actions/workflows/R-CMD-check.yaml)\n\u003c!-- Devel badges end. --\u003e\n\n\u003c!-- Release badges start: --\u003e\n\u003c!-- [![CRAN status](https://www.r-pkg.org/badges/version/riskyr)](https://CRAN.R-project.org/package=riskyr)  --\u003e\n\u003c!-- [![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/riskyr?color=blue)](https://www.r-pkg.org/pkg/riskyr) --\u003e\n\u003c!-- Release badges end. --\u003e\n\n\u003c!-- Possible status badges: \n[![CRAN status](https://www.r-pkg.org/badges/version/riskyr)](https://CRAN.R-project.org/package=riskyr) \n[![R-CMD-check](https://github.com/hneth/riskyr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/hneth/riskyr/actions/workflows/R-CMD-check.yaml)\n[![Build_status](https://travis-ci.org/hneth/riskyr.svg?branch=master)](https://travis-ci.org/hneth/riskyr/) \n[![Downloads/month](https://cranlogs.r-pkg.org/badges/riskyr?color=brightgreen)](https://www.r-pkg.org:443/pkg/riskyr) \n[![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/riskyr?color='e0607e')](https://www.r-pkg.org/pkg/riskyr)\n[![Rdoc](https://www.rdocumentation.org/badges/version/riskyr)](https://www.rdocumentation.org/packages/riskyr/) \n--\u003e\n\n```{r setup, echo = FALSE}\n# Chunk options:\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"inst/pix/README-\",\n  fig.align = \"center\"\n)\n\n# URLs:\nurl_riskyr_org \u003c- \"https://riskyr.org/\"\n```\n\n\u003c!-- riskyr logo: --\u003e\n\n# riskyr `r packageVersion('riskyr')` \u003cimg src = \"./inst/pix/logo.png\" align = \"right\" alt = \"riskyr\" width = \"160\" /\u003e\n\n\u003c!-- riskyr logo: --\u003e  \n\u003c!-- \n\u003ca href = \"https://github.com/hneth/riskyr/\"\u003e\n\u003cimg alt = \"riskyr logo\" title = \"riskyr\" src = \"./inst/pix/riskyr_cube.png\" width = \"180px\" align = \"right\" style = \"float:right; border:20; width:180px;\"/\u003e\n\u003c/a\u003e \n--\u003e\n\u003c!-- \u003cimg src = \"./inst/pix/riskyr_cube_s.png\" alt = \"riskyr\" align = \"right\" style = \"float: right; border:20;\"/\u003e --\u003e\n\u003c!-- ![riskyr](./inst/pix/riskyr_cube_s.png) --\u003e \n\u003c!-- knitr::include_graphics(\"./inst/pix/riskyr_cube_s.png\") --\u003e\n\n\n### A toolbox for rendering risk literacy more transparent {-}\n\n\u003c!-- Current package Description (updated on 2021-03-19): --\u003e\n\nRisk-related information ---\\ like the prevalence of conditions, the sensitivity and specificity of diagnostic tests, or the effectiveness of interventions or treatments\\ --- can be expressed in terms of frequencies or probabilities. By providing a toolbox of corresponding metrics and representations, **riskyr** computes, translates, and visualizes risk-related information in a variety of ways. Adopting multiple complementary perspectives provides insights into the interplay between key parameters and renders teaching and training programs on risk literacy more transparent.\n\n\n## Motivation \n\n\u003e Solving a problem simply means representing it \u003cbr\u003e\n\u003e so as to make the solution transparent. (H.A. Simon)[^1]\n\n[^1]: Simon, H.A. (1996). _The Sciences of the Artificial_ (3rd ed.). The MIT Press, Cambridge, MA. (p. 132).\n\n\u003c!-- Risk perception as representational effects: --\u003e\n\nThe goals of **riskyr** are less of a _computational_ and more of a _representational_ nature: \nWe express risk-related information in multiple formats, facilitate the translation between them, and provide a variety of attractive visualizations that emphasize different aspects of risk-related scenarios. Whereas people find it difficult to understand and compute information expressed in terms of probabilities, the same information is easier to understand and compute when expressed in terms of frequencies (e.g., Gigerenzer, 2002, 2014; Gigerenzer \u0026 Hoffrage, 1995). But rather than just expressing probabilities in terms of frequencies, **riskyr** allows translating between formats and illustrates the relationships between different representations in a variety of ways. Switching between and interacting with different representations fosters transparency and boosts human understanding of risk-related information.[^2]\n\n\u003c!-- Defining \"risk\" (in footnote): --\u003e\n\n[^2]: To clarify our notion of \"risk\" in this context, we need to distinguish it from its everyday usage as anything implying a chance of danger or harm.  \nIn basic research on judgment and decision making and the more applied fields of risk perception and risk communication, the term _risk_ typically refers to decisions or events for which the options and their consequences are known and probabilities for all possible outcomes can be provided.  \nFor our present purposes, the notion of risk-related information refers to any scenario in which some events of interest are determined by probabilities. While it is important that quantitative (estimates of) probabilities are provided, their origin, reliability and validity is not questioned here. Thus, the probabilities provided can be based on clinical intuition, on recordings of extensive experience, or on statistical simulation models (e.g., repeatedly casting dice and counting the frequencies of outcomes).  \nThis notion of _risk_ is typically contrasted with the much wider notion of _uncertainty_ in which options or probabilities are unknown or cannot be quantified. (See Gigerenzer and Gaissmaier, 2011, or Neth and Gigerenzer, 2015, on this conceptual distinction and corresponding decision strategies.) \n\n\u003c!-- On \"riskyr\": --\u003e\n\nThe basic assumptions and aspirations driving the current development of **riskyr** include:\n\n1. Effective training in risk literacy requires transparent representations, smart strategies, and simple tools. \n\n2. We aim to provide a set of (computational and representational) functions that facilitate various calculations, translations between formats, and enable a range of alternative views on the interplay between probabilities and frequencies. \n\n3. Just as no single tool fits all tasks, no single graph illustrates all aspects of a problem. A variety of visualizations that illustrate the interplay of parameters and metrics can facilitate active and explorative learning. It is particularly helpful to view relationships from alternative perspectives and to observe the change of one parameter as a function of others. \n\nBased on these assumptions and goals, **riskyr** provides a range of computational and representational tools. Importantly, the objects and functions in the **riskyr** toolbox are not isolated, but complement, explain, and support each other. All functions and visualizations can be used separately or explored interactively, providing immediate feedback on the effect of changes in parameter values. By providing a variety of customization options, users can explore and design representations of risk-related information that fit to different tasks and meet their personal needs and goals.  \n\n\n## Getting riskyr\n\n### Installation\n\nThe current release of **riskyr** is available from [CRAN](https://CRAN.R-project.org/) at \u003chttps://CRAN.R-project.org/package=riskyr\u003e:\n\n```{r install-CRAN, echo = TRUE, eval = FALSE}\ninstall.packages('riskyr')  # install riskyr from CRAN client\nlibrary('riskyr')           # load to use the package\n```\n\nThe current development version can be installed from its [GitHub](https://github.com) repository at \u003chttps://github.com/hneth/riskyr/\u003e: \n\n```{r install-github, echo = TRUE, eval = FALSE}\n# install.packages('devtools')\ndevtools::install_github('hneth/riskyr')\n```\n\n### Available resources\n\n- An **interactive online version** is available at [https://riskyr.org/](`r url_riskyr_org`). \n\n- The **package documentation** is available online:  \n    - current release version: \u003chttps://hneth.github.io/riskyr/\u003e \n    - current development version: \u003chttps://hneth.github.io/riskyr/dev/\u003e\n\n## Quick start guide \n\n\u003c!-- 1: Defining a scenario --\u003e\n\n### Defining a scenario\n\n**riskyr** is designed to address problems like the following:[^3]\n\n[^3]: See Gigerenzer (2002, 2014), Gigerenzer and Hoffrage, U. (1995), Gigerenzer et al. (2007), and Hoffrage et al. (2015) for scientific background information and similar problems. See Sedlmeier and Gigerenzer (2001) and Kurzenhäuser and Hoffrage (2002) for related training programs (with remarkable results), and Micallef et al. (2012) and Khan et al. (2015) for (rather sceptical and somewhat sobering) studies on the potential benefits of static representations for solving Bayesian problems.\n\n\u003c!-- Example: --\u003e\n\n\u003e **Screening for hustosis**  \n\u003e  \n\u003e A screening device for detecting the clinical condition of _hustosis_ is developed. The current device is very good, but not perfect. We have the following information:  \n\u003e 1. About 4% of the people of the general population suffer from _hustosis_.  \n\u003e 2. If someone suffers from hustosis, there is a chance of 80% that he or she will test positively for the condition.    \n\u003e 3. If someone is free from hustosis, there is a chance of 5% that he or she will still test positively for the condition.  \n\u003e \n\u003e Mr. and Ms. Smith have both been screened with the device:  \n\u003e - Mr. Smith tested positively (i.e., received a diagnosis of hustosis).     \n\u003e - Ms. Smith tested negatively (i.e., was judged to be free of hustosis).   \n\u003e \n\u003e Please answer the following questions:   \n\u003e - What is the probability that Mr. Smith actually suffers from hustosis?  \n\u003e - What is the probability that Ms. Smith is actually free of hustosis?  \n\n\n#### Probabilities provided\n\nThe first challenge in solving such problems is in understanding the information that is being provided. \nThe problem description provides three essential probabilities: \n\n1. The condition's _prevalence_ (in the general population) is 4%: `prev = .04`.  \n2. The device's or diagnostic decision's _sensitivity_ is 80%: `sens = .80`.  \n3. The device's or diagnostic decision's _false alarm rate_ is 5%: `fart = .05`, \nimplying a _specificity_ of (100% $-$ 5%) = 95%: `spec = .95`.  \n\n#### Understanding the questions asked\n\nThe second challenge here lies in understanding the questions that are being asked — and in realizing that their answers are _not_ simply the decision's sensitivity or specificity values. Instead, we are asked to provide two _conditional_ probabilities:\n\n- The conditional probability of suffering from the condition given a positive test result, \u003cbr\u003eaka. the _positive predictive value_ (`PPV`). \n- The conditional probability of being free of the condition given a negative test result, \u003cbr\u003eaka. the _negative predictive value_ (`NPV`). \n\n#### Translating into frequencies\n\nOne of the best tricks in risk literacy education is to translate probabilistic information into frequencies.[^4] To do this, we imagine a representative sample of `N = 1000` individuals. Rather than asking about the probabilities for Mr. and Ms. Smith, we could re-frame the questions as:\n\n\u003e Assuming a representative sample of 1000 individuals:   \n\u003e - What proportion of individuals with a positive test result actually suffer from hustosis?  \n\u003e - What proportion of individuals with a negative test result are actually free of hustosis? \n\n[^4]: See Gigerenzer and Hoffrage (1995) and Hoffrage et al. (2000, 2002) on the concept of _natural frequencies_. \n\n\n#### Using riskyr\n\nHere is how **riskyr** allows you to view and solve such problems:\n\n```{r load-riskyr, eval = TRUE, message = FALSE, warning = FALSE}\nlibrary(riskyr)  # loads the package\n```\n\n#### Creating a scenario from probabilities\n\nWe define a new **riskyr** scenario (called `hustosis`) by using the `riskyr()` function and entering the information provided by our problem as its arguments: \n\n```{r ex1-definition, eval = TRUE}\nhustosis \u003c- riskyr(scen_lbl = \"Example\", \n                   cond_lbl = \"Hustosis\",\n                   dec_lbl = \"Screening\",\n                   popu_lbl = \"Sample\", \n                   N = 1000,  # population size\n                   prev = .04, sens = .80, spec = (1 - .05)  # 3 probabilities\n                   )\n```\n\nBy providing the argument `N = 1000` we define the scenario for a target population of 1000 people. If we leave this parameter unspecified (or `NA`), the `riskyr()` function will automatically pick a suitable value of `N`. \n\n#### Summary\n\nTo obtain a quick overview of key parameter values, we ask for the `summary` of `hustosis`:\n\n```{r ex1-summary, echo = TRUE, eval = FALSE}\nsummary(hustosis)  # summarizes key parameter values: \n```\n\nThe summary distinguishes between probabilities, frequencies, and accuracy information. In `Probabilities` we find the answer to both of our questions that take into account all the information provided above:\n\n- The conditional probability that Mr. Smith actually suffers from hustosis given his positive test result is 40% (as `PPV = 0.400`). \n\n- The conditional probability that Ms. Smith is actually free of hustosis given her negative test result is 99.1% (as `NPV = 0.991`).\n\nIf find these answers surprising, you are an ideal candidate for additional insights into the realm of risk literacy. \nA key component of **riskyr** is to analyze and view a scenario from a variety of different perspectives. To get you started immediately, we only illustrate some introductory commands here and focus on different types of visualizations. (Call `riskyr.guide()` for various vignettes that provide more detailed information.) \n\n#### Creating a scenario from frequencies\n\nRather than defining our `hustosis` scenario by providing 3 essential probabilities (`prev`, `sens`, and `spec`), we could define the same scenario by providing 4 essential frequencies (`hi`, `mi`, `fa`, and `cr`) as follows:\n\n```{r ex1-definition_freq, echo = TRUE, eval = TRUE}\nhustosis_2 \u003c- riskyr(scen_lbl = \"Example\", \n                     cond_lbl = \"Hustosis\",\n                     dec_lbl = \"Screening\",\n                     popu_lbl = \"Sample\", \n                     hi = 32, mi = 8, fa = 48, cr = 912  # 4 key frequencies\n                     )\n```\n\nAs we took the values of these frequencies from the `summary` of `hustosis`, the `hustosis_2` scenario should contain exactly the same information as `hustosis`:\n\n```{r ex1-all-equal, eval = TRUE}\nall.equal(hustosis, hustosis_2)  # do both contain the same information? \n```\n\n### Visualizations\n\nVarious visualizations of **riskyr** scenarios can be created by a range of plotting functions. \n\n#### Prism plot\n\nThe default type of plot used in **riskyr** is a _prism plot_ (or network diagram) that shows key frequencies of a scenario as nodes and key probabilities as edges linking the nodes:\n\n```{r ex1-prism, eval = FALSE, fig.width = 6, fig.height = 5, fig.show = 'hold'}\nplot(hustosis)  # default plot\n\n# =\u003e internally calls plot_prism(...) with many additional arguments:\n# plot(hustosis, type = \"prism\", by = \"cddc\", area = \"no\", f_lbl = \"num\", p_lbl = \"mix\")\n```\n\n![Prism plot](inst/pix/README-ex1-prism-1.png)\n\n#### Tree diagram \n\nA _tree diagram_ is the upper half of a prism plot, which can be obtained by plotting a scenario with 1 of 3 perspectives:\n\n1. by condition (`by = \"cd\"`), to split the population into _TRUE_ vs. _FALSE_ (`cond_true` vs. `cond_false`) cases; \n2. by decision (`by = \"dc\"`), to split the population into _negative_ vs. _positive_ (`dec_neg` vs. `dec_pos`) decisions; \n3. by accuracy (`by = \"ac\"`), to split the population into _correct_ vs. _incorrect_ (`dec_cor` vs. `dec_err`) decisions. \n\nFor instance, the following command plots a frequency tree by decisions:\n\n```{r ex1-tree, eval = FALSE, fig.width = 6, fig.height = 3.5}\nplot(hustosis, by = \"dc\")  # plot a tree diagram (by decision)\n```\n\n![Tree diagram](inst/pix/README-ex1-tree-1.png)\n\nThis particular tree splits the population of `N = 1000` individuals into two subgroups _by decision_ (`by = \"dc\"`) and contains the answer to the second (frequency) version of our questions:\n\n- The proportion of individuals with a positive test result who actually suffer from hustosis is the frequency of \"true positive\" cases (shown in darker green) divided by \"decision positive\" cases (shown in purple): `32/80 = .400` (corresponding to our value of `PPV` above).  \n- The proportion of individuals with a negative test result who are actually free from hustosis is the frequency of \"true negative\" cases (shown in lighter green) divided by \"decision negative\" cases (shown in blue): `912/920 = .991` (corresponding to our value of `NPV` above, except for minimal differences due to rounding). \n\nOf course, the frequencies of these ratios were already contained in the `hustosis` summary above. But the representation in the form of a tree diagram makes it easier to understand the decomposition of the population into subgroups and to see which frequencies are required to answer a particular question.\n\n#### Frequency net\n\nA new type of visualization combines elements from 2x2 tables with those of tree or double tree diagrams. \nThe _frequency net_ (Binder et al., 2020) is similar to a 2x2 table insofar as its perspectives (shown by arranging marginal frequencies in a vertical vs. horizontal fashion) do not suggest an order or dependency (in contrast to trees or mosaic plots). \nAdditionally, the frequency net allows showing 3\\ kinds of (_marginal_, _conditional_, and _joint_) probabilities:\n\n```{r ex1-fnet, eval = FALSE, fig.width = 6, fig.height = 5}\nplot(hustosis, type = \"fnet\", by = \"cddc\",\n     f_lbl = \"namnum\")  # plot frequency net\n```\n\n![Frequency net](inst/pix/README-ex1-fnet-1.png)\n\nSee the `plot_fnet()` function for options and details.\n\n#### Icon array \n\nAn icon array shows the classification result for each of `N = 1000` individuals in our population: \n\n```{r ex1-icons, eval = FALSE, fig.width = 5.5, fig.height = 3.5}\nplot(hustosis, type = \"icons\")   # plot an icon array \n```\n\n![Icon array](inst/pix/README-ex1-icons-1.png)\n\nWhile this particular icon array is highly regular (as both the icons and classification types are ordered), **riskyr** provides many different versions of this type of graph. This allows viewing the probability of diagnostic outcomes as either frequency, area, or density (see `?plot_icons` for details and examples). \n\n#### Area plot\n\nAn area plot (or mosaic plot) offers a way of expressing classification results as the relationship between areas. Here, the entire population is represented as a square and the probability of its subgroups as the size of rectangles (see `?plot_area` for details and examples):  \n\n```{r ex1-area, eval = FALSE, fig.width = 5.5, fig.height = 4.0}\nplot(hustosis, type = \"area\")  # plot an area/mosaic plot (by = \"cddc\")\n```\n\n![Area/mosaic plot](inst/pix/README-ex1-area-1.png)\n\n#### Table plot\n\nWhen not scaling the size of rectangles by their relative frequencies or probabilities, we can plot basic scenario information as a 2-by-2 confusion (or contingency) table (see `?plot_tab` for details and examples):  \n\n```{r ex1-tab, eval = FALSE, fig.width = 5.5, fig.height = 4}\nplot(hustosis, type = \"table\")  # plot 2x2 confusion table (by = \"cddc\") \n```\n\n![Table plot](inst/pix/README-ex1-tab-1.png)\n\n#### Bar plot\n\nA _bar plot_ allows comparing relative frequencies as the heights of bars (see `?plot_bar` for details and examples):  \n\n```{r ex1-bar, eval = FALSE, fig.width = 5.5, fig.height = 5.0}\nplot(hustosis, type = \"bar\", f_lbl = \"abb\")  # plot bar chart (by \"all\" perspectives): \n```\n\n![Bar plot](inst/pix/README-ex1-bar-1.png)\n\n#### Curves\n\nBy adopting a functional perspective, we can ask how the values of some probabilities (e.g., the predictive values `PPV` and `NPV`) change as a function of another (e.g., the condition's prevalence `prev`, see `?plot_curve` for details and examples):\n\n```{r ex1-curve, eval = FALSE, fig.width = 5.5, fig.height = 4.5}\nplot(hustosis, type = \"curve\", uc = .05)   # plot probability curves (by prevalence):\n```\n\n![Probability curves](inst/pix/README-ex1-curve-1.png)\n\n#### Planes \n\nWhen parameter values systematically depend on two other parameters, we can plot this as a plane in a 3D cube. The following graph plots the `PPV` as a function of the sensitivity (`sens`) and specificity (`spec`) of our test for a given prevalence (`prev`, see `?plot_plane` for details and examples):\n\n```{r ex1-plane, eval = FALSE, fig.width = 5, fig.height = 4}\nplot(hustosis, type = \"plane\")  # plot probability plane (by sens x spec):\n```\n\n![Probability plane](inst/pix/README-ex1-plane-1.png)\n\nThe L-shape of this plane reveals a real problem with our current test: Given a prevalence of 4% for hustosis in our target population, the `PPV` remains very low for the majority of the possible range of sensitivity and specificity values. To achieve a high `PPV`, the key requirement for our test is an extremely high specificity. Although our current specificity value of 95% (`spec = .95`) may sound pretty good, it is still not high enough to yield a `PPV` beyond 40%. \n\n\u003c!--\n\n#### Plots currently under development\n\nThe current development version of **riskyr** (version 0.1.0.930+) replaces some of the above plots with a set of more powerful and more integrated functions. To use them and preview their effects, install the development version and explore the following commands:\n\n```{r preview-current-dev, echo = TRUE, eval = FALSE}\n## Install current development version: \n# install.packages(\"devtools\")\ndevtools::install_github(\"hneth/riskyr\")\n\n## Preview latest functions (riskyr \u003e v0.0.1.930):\nplot(hustosis, type = \"prism\", by = \"cddc\")  \nplot(hustosis, type = \"tree\",  by = \"ac\") \nplot(hustosis, type = \"area\",  by = \"cddc\")\nplot(hustosis, type = \"tab\",   by = \"cddc\")\nplot(hustosis, type = \"bar\",   dir = 2)\n```\n\n--\u003e\n\n\u003c!-- 2: Loading and using pre-defined scenarios --\u003e\n\n### Using existing scenarios\n\nAs defining your own scenarios can be cumbersome and the literature is full of risk-related problems (often referred to as \"Bayesian reasoning\"), **riskyr** provides a set of — currently `r length(scenarios) - 1` — pre-defined scenarios (stored in a list `scenarios`). \nHere, we provide an example that shows how you can select and explore them. \n\n#### Selecting a scenario\n\nLet us assume you want to learn more about the controversy surrounding screening procedures of prostate-cancer (known as PSA screening). Scenario 10 in our collection of `scenarios` is from an article on this topic (Arkes \u0026 Gaissmaier, 2012). To select a particular scenario, simply assign it to an R object. For instance, we can assign Scenario 10 to `s10`:\n\n```{r ex2-select, eval = TRUE}\ns10 \u003c- scenarios$n10  # assign pre-defined Scenario 10 to s10\n```\n\n#### Scenario summary \n\nOur selected scenario object `s10` is a list with `r length(s10)` elements, which describe it in both text and numeric variables. The following commands provide an overview of `s10` in text form:\n\n```{r ex2-basic-info, eval = FALSE}\ns10$scen_lbl   # a descriptive label\ns10$cond_lbl   # the current condition\ns10$dec_lbl    # the current decision\ns10$popu_lbl   # the current population\n\n# summary(s10) # summarizes a scenario\n```\n\nGenerating some **riskyr** plots allows a quick visual exploration of the scenario. \nWe only illustrate some selected plots and options here, and trust that you will play with and explore the rest for yourself.\n\n#### Prism plots\n\nA tree diagram is a prism plot that views the population from only one perspective, but provides a quick overview. In the following plot, the boxes are depicted as squares with area sizes that are scaled by relative frequencies (using the `area = \"sq\"` argument): \n\n```{r ex2-tree, eval = FALSE, fig.width = 5.5, fig.height = 3.5}\nplot(s10, type = \"tree\", by = \"cd\", area = \"sq\",  # tree/prism plot with scaled squares \n     f_lbl = \"def\", f_lbl_sep = \":\\n\")            # custom frequency labels \n```\n\n![Prism/tree plot (with scaled squares)](inst/pix/README-ex2-tree-1.png)\n\nThe prism plot (or network diagram) combines 2 tree diagrams to simultaneously provide two perspectives on a population (see Wassner et al., 2004). **riskyr** provides several variants of prism plots. To avoid redundancy to the previous tree diagram, the following version splits the population by accuracy and by decision (see the `by = \"acdc\"` argument). In addition, the frequencies are represented as horizontal rectangles (`area = \"hr\"`) so that their relative width reflect the number of people in the corresponding subgroup: \n\n```{r ex2-prism-hr, eval = FALSE, fig.width = 6, fig.height = 4}\nplot(s10, type = \"prism\", by = \"acdc\", area = \"hr\",  # prism plot with horizontal rectangles\n     p_lbl = \"num\")                                  # numeric probability labels\n```\n\n![Prism plot (with scaled horizontal rectangles)](inst/pix/README-ex2-prism-hr-1.png)\n\n#### Frequency net\n\nJust like the 2x2 table, area plot, and prism plot, the frequency net allows selecting two out of three perspectives. \nAdditionally, the shape and size of the frequency boxes can be adjusted by using the `area = \"sq\"` option. \nThe following example shows a frequency net by condition and accuracy (`by = \"cdac\"`) without the joint probabilities, \nwith custom settings for labels, links, and colors: \n\n```{r ex2-fnet, eval = FALSE, fig.width = 5.5, fig.height = 3.5}\nplot(s10, type = \"fnet\", by = \"cdac\",  # frequency net (by condition and accuracy) \n     area = \"sq\", joint_p = FALSE, arr_c = 2,     # custom areas, links, and arrows \n     f_lbl = \"namnum\", p_lbl = \"num\", col_pal = pal_rgb) # custom labels and colors \n```\n\n![Frequency net (with custom perspective and options)](inst/pix/README-ex2-fnet-1.png)\n\n#### Icon array\n\n```{r ex2-icons, eval = FALSE, fig.width = 5.5, fig.height = 3.5}\nplot(s10, type = \"icons\", arr_type = \"shuffled\")   # plot a shuffled icon array \n```\n\n\u003c!-- ![](inst/pix/README-ex2-icons-1.png) --\u003e \n\n#### Area plot\n\n```{r ex2-area, eval = FALSE, fig.width = 5.5, fig.height = 4.5}\nplot(s10, type = \"area\", p_split = \"v\", p_lbl = \"def\")  # plot an area/mosaic plot (with probabilities) \n```\n\n\u003c!-- ![](inst/pix/README-ex2-area-1.png) --\u003e\n\n#### Table plot\n\n```{r ex2-tab, eval = FALSE, fig.width = 5.5, fig.height = 4.5}\nplot(s10, type = \"tab\", p_split = \"h\", p_lbl = \"def\")  # plot a 2x2 table (with probabilities)\n```\n\n\u003c!-- ![](inst/pix/README-ex2-tab-1.png) --\u003e\n\n#### Curves \n\nThe following curves show the values of several conditional probabilities as a function of prevalence: \n\n```{r ex2-curve, eval = FALSE, fig.width = 5.5, fig.height = 4.5}\nplot(s10, type = \"curve\", what = \"all\", uc = .05)  # plot all curves (by prev):\n```\n\n\u003c!-- ![Probability curves (with uncertainty)](inst/pix/README-ex2-curve-1.png) --\u003e \n\nAdding the argument `what = \"all\"` also shows the proportion of positive decisions (`ppod`) and the decision's overall accuracy (`accu`) as a function of the prevalence (`prev`). Would you have predicted their shape without seeing this graph?\n\n#### Planes\n\nThe following surface shows the negative predictive value (NPV) as a function of sensitivity and specificity (for a given prevalence): \n\n```{r ex2-plane, eval = FALSE, fig.width = 5.5, fig.height = 4}\nplot(s10, type = \"plane\", what = \"NPV\")  # plot plane (as a function of sens x spec):\n```\n\n\u003c!-- ![Probability plane (NPV)](inst/pix/README-ex2-plane-1.png) --\u003e \n\nHopefully, this brief overview managed to whet your appetite for visual exploration. \nIf so, call `riskyr.guide()` for viewing the package vignettes and obtaining additional information. \n\n\n## About\n\n\u003c!-- uni.kn logo and link to SPDS: --\u003e  \n\u003c!-- ![](./inst/pix/uniKn_logo.png) --\u003e \n\u003ca href=\"https://www.spds.uni-konstanz.de/\"\u003e\n\u003cimg src = \"./inst/pix/uniKn_logo.png\" alt = \"spds.uni.kn\" align = \"right\" width = \"300\" style = \"width: 300px; float: right; border:20;\"/\u003e\n\u003c!-- \u003cimg src = \"./inst/pix/uniKn_logo_s.png\" alt = \"spds.uni.kn\" style = \"float: right; border:20;\"/\u003e --\u003e \n\u003c/a\u003e\n\n**riskyr** originated out of a series of lectures and workshops on risk literacy.  \nThe current version (0.4.0, as of Aug. 15, 2022) is under active development. \nIts primary designers are \n[Hansjörg Neth](https://www.spds.uni-konstanz.de/hans-neth), \n[Felix Gaisbauer](https://www.spds.uni-konstanz.de/people), \n[Nico Gradwohl](https://www.spds.uni-konstanz.de/people), and \n[Wolfgang Gaissmaier](https://www.spds.uni-konstanz.de/people), who are researchers at the department of \n[Social Psychology and Decision Sciences](https://www.spds.uni-konstanz.de/) at the \n[University of Konstanz](https://www.uni-konstanz.de/en/), Germany. \n\nThe **riskyr** package is open source software written in [R](https://www.r-project.org/) and released under the \n[GPL 2](https://tldrlegal.com/license/gnu-general-public-license-v2) | \n[GPL 3](https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)) licenses.  \n\nThe theoretical background of **riskyr** is illuminated further in the following article:\n\n- Neth, H., Gradwohl, N., Streeb, D., Keim, D.A., \u0026 Gaissmaier, W. (2021). \nPerspectives on the 2x2 matrix: \nSolving semantically distinct problems based on a shared structure of binary contingencies. \n_Frontiers in Psychology: Cognition_, _11_, 567817. \ndoi: [10.3389/fpsyg.2020.567817](https://doi.org/10.3389/fpsyg.2020.567817) \n\n\n### Resources\n\nThe following resources and versions are currently available:\n\nType:                    | Version:           | URL:                           |        \n:------------------------|:-------------------|:-------------------------------|\nA. **riskyr** (R package): | [Release version](https://CRAN.R-project.org/package=riskyr)  | \u003chttps://CRAN.R-project.org/package=riskyr\u003e |\n    \u0026nbsp;               | [Development version](https://github.com/hneth/riskyr/)         | \u003chttps://github.com/hneth/riskyr/\u003e | \nB. **riskyrApp** (R Shiny code): | [Online version](`r url_riskyr_org`)                    | [https://riskyr.org/](`r url_riskyr_org`) | \n    \u0026nbsp;               | [Development version](https://github.com/hneth/riskyrApp/)      | \u003chttps://github.com/hneth/riskyrApp/\u003e | \nC. Online documentation: | [Release version](https://hneth.github.io/riskyr/)              | \u003chttps://hneth.github.io/riskyr/\u003e | \n    \u0026nbsp;               | [Development version](https://hneth.github.io/riskyr/dev/)      | \u003chttps://hneth.github.io/riskyr/dev/\u003e | \n\n\n### Contact\n\nWe appreciate your feedback, comments, or questions. \n\n- Please report any **riskyr**-related issues at \u003chttps://github.com/hneth/riskyr/issues/\u003e. \n\n- Contact us at \u003ccontact.riskyr@gmail.com\u003e with any comments, questions, or suggestions. \n\n\n### Reference\n\n\u003c!-- riskyr logo: --\u003e  \n\u003ca href = \"https://github.com/hneth/riskyr/\"\u003e\n\u003cimg alt = \"riskyr logo\" title = \"riskyr\" src = \"./inst/pix/logo.png\" width = \"180px\" align = \"right\" style = \"float:right; border:20; width:180px;\"/\u003e\n\u003c/a\u003e \n\u003c!-- \u003cimg src = \"./inst/pix/riskyr_cube_s.png\" alt = \"riskyr\" align = \"right\" style = \"float: right; border:20;\"/\u003e --\u003e\n\u003c!-- ![riskyr](./inst/pix/riskyr_cube_s.png) --\u003e \n\u003c!-- knitr::include_graphics(\"./inst/pix/riskyr_cube_s.png\") --\u003e\n\nTo cite **riskyr** in derivations and publications, please use:\n\n- Neth, H., Gaisbauer, F., Gradwohl, N., \u0026 Gaissmaier, W. (2022).  \n  riskyr: Rendering Risk Literacy more Transparent.  \n  Social Psychology and Decision Sciences, University of Konstanz, Germany.  \n  Computer software (R package version 0.4.0, Aug. 15, 2022).  \n  Retrieved from \u003chttps://CRAN.R-project.org/package=riskyr\u003e.  \n\nA BibTeX entry for LaTeX users is: \n\n    @Manual{riskyr,\n      title = {riskyr: Rendering Risk Literacy more Transparent},\n      author = {Hansjörg Neth and Felix Gaisbauer and Nico Gradwohl and Wolfgang Gaissmaier},\n      year = {2022},\n      organization = {Social Psychology and Decision Sciences, University of Konstanz},\n      address = {Konstanz, Germany},\n      note = {R package (version 0.4.0, Aug. 15, 2022)},\n      url = {https://CRAN.R-project.org/package=riskyr},\n      }    \n    \nCalling `citation(\"riskyr\")` in the package also displays this information.\n\n### References\n\n- Arkes, H. R., \u0026 Gaissmaier, W. (2012). \nPsychological research and the prostate-cancer screening controversy. \n_Psychological Science_, _23_, 547–553.\n\n- Binder, K., Krauss, S., and Wiesner, P. (2020). A new visualization for probabilistic situations containing\ntwo binary events: The frequency net. _Frontiers in Psychology_, _11_, 750. \ndoi: [10.3389/fpsyg.2020.00750](https://doi.org/10.3389/fpsyg.2020.00750)\n\n- Garcia-Retamero, R., \u0026 Cokely, E. T. (2017). \nDesigning visual aids that promote risk literacy: \nA systematic review of health research and evidence-based design heuristics. \n_Human Factors_, _59_, 582–627.  \n\n- Gigerenzer, G. (2002). \n_Reckoning with risk: Learning to live with uncertainty_. \nLondon, UK: Penguin.\n\n- Gigerenzer, G. (2014). \n_Risk savvy: How to make good decisions_. \nNew York, NY: Penguin.\n\n- Gigerenzer, G., \u0026 Gaissmaier, W. (2011). \nHeuristic decision making. \n_Annual Review of Psychology_, _62_, 451–482. \n([Available online](https://doi.org/10.1146/annurev-psych-120709-145346)) \n\n- Gigerenzer, G., Gaissmaier, W., Kurz-Milcke, E., Schwartz, L., \u0026 Woloshin, S. (2007). \nHelping doctors and patients make sense of health statistics. \n_Psychological Science in the Public Interest_, _8_, 53–96. \n([Available online](https://doi.org/10.1111/j.1539-6053.2008.00033.x))\n\n- Gigerenzer, G., \u0026 Hoffrage, U. (1995). \nHow to improve Bayesian reasoning without instruction: Frequency formats. \n_Psychological Review_, _102_, 684–704.\n\n- Hoffrage, U., Gigerenzer, G., Krauss, S., \u0026 Martignon, L. (2002). \nRepresentation facilitates reasoning: What natural frequencies are and what they are not. \n_Cognition_, _84_, 343–352.\n\n- Hoffrage, U., Krauss, S., Martignon, L., \u0026 Gigerenzer, G. (2015). \nNatural frequencies improve Bayesian reasoning in simple and complex inference tasks. \n_Frontiers in Psychology_, _6_, 1473. \ndoi: [10.3389/fpsyg.2015.01473](https://doi.org/10.3389/fpsyg.2015.01473) \n([Available online](https://doi.org/10.3389/fpsyg.2015.01473)) \n\n- Hoffrage, U., Lindsey, S., Hertwig, R., \u0026 Gigerenzer, G. (2000). \nCommunicating statistical information. \n_Science_, _290_, 2261–2262.\n\n- Khan, A., Breslav, S., Glueck, M., \u0026 Hornbæk, K. (2015). \nBenefits of visualization in the mammography problem. \n_International Journal of Human-Computer Studies_, _83_, 94–113.  \n\n- Kurzenhäuser, S., \u0026 Hoffrage, U. (2002). \nTeaching Bayesian reasoning: An evaluation of a classroom tutorial for medical students. \n_Medical Teacher_, _24_, 516–521.\n\n- Kurz-Milcke, E., Gigerenzer, G., \u0026 Martignon, L. (2008). \nTransparency in risk communication. \n_Annals of the New York Academy of Sciences_, _1128_, 18–28.\n\n- Micallef, L., Dragicevic, P., \u0026 Fekete, J.-D. (2012). \nAssessing the effect of visualizations on Bayesian reasoning through crowd-sourcing. \n_IEEE Transactions on Visualization and Computer Graphics_, _18_, 2536–2545.  \n\n- Neth, H., \u0026 Gigerenzer, G. (2015). \nHeuristics: Tools for an uncertain world. \nIn R. Scott \u0026 S. Kosslyn (Eds.), _Emerging trends in the social and behavioral sciences_. \nNew York, NY: Wiley Online Library. \ndoi: [10.1002/9781118900772.etrds0394](https://doi.org/10.1002/9781118900772.etrds0394) \n([Available online](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.726.1656\u0026rep=rep1\u0026type=pdf))  \n\n- Neth, H., Gradwohl, N., Streeb, D., Keim, D.A., \u0026 Gaissmaier, W. (2021). \nPerspectives on the 2x2 matrix: Solving semantically distinct problems based on a shared structure of binary contingencies. \n_Frontiers in Psychology_, _11_, 567817. \ndoi: [10.3389/fpsyg.2020.567817](https://doi.org/10.3389/fpsyg.2020.567817) \n([Available online](https://doi.org/10.3389/fpsyg.2020.567817))  \n\n- Sedlmeier, P., \u0026 Gigerenzer, G. (2001). \nTeaching Bayesian reasoning in less than two hours. \n_Journal of Experimental Psychology: General_, _130_, 380–400.\n\n- Wassner, C., Martignon, L., \u0026 Biehler, R. (2004). \nBayesianisches Denken in der Schule. \n_Unterrichtswissenschaft_, _32_, 58–96.\n\n\n\u003c!-- footer: --\u003e\n\n------ \n\n[`README.Rmd` updated on `r format(Sys.time(), \"%Y-%m-%d\")` by [hn](https://neth.de).] \n\n\u003c!-- eof --\u003e \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhneth%2Friskyr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhneth%2Friskyr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhneth%2Friskyr/lists"}