Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
vistributions 0.2.2
vistributions draws the probability and percentile questions you ask of the normal, t, chi-square, F and binomial distributions, with the answer printed on the plot.
Version 0.2.2 is a correctness release. What the plot shades and what its caption prints now agree with the exact probability, and inputs that cannot describe an event stop with a clear message. If you use the binomial functions to size an event, read the first section.
< section id="install-from-cran" class="level2">Install from CRAN
install.packages("vistributions")
The full list of changes is in the release notes.
< section id="shading-follows-the-event" class="level2">Shading follows the event
A trial cohort has 40 users, and about 25% of trial users usually upgrade. How likely is it that exactly 10 of them upgrade?
vdist_binom_prob(n = 40, p = 0.25, s = 10, type = "exact")
The exact value, from base R:
dbinom(10, size = 40, prob = 0.25)
[1] 0.1443643
The caption and the shaded bar match this value. The change matters most for large n, where bars are grouped. A grouped bar that crossed the cutoff was painted whole: for n = 10000, p = 0.01 and s = 100, the shaded area was 19.26% for an event whose exact probability is 4.01% (release notes). Every event cutoff is now a bar edge, so the shaded bar heights add up to dbinom() or pbinom() for the event.
Inputs that cannot be an event
A count of successes has to lie between 0 and the number of trials. Asking for a negative count used to be accepted, with the caption P(X) <= -1 = 0. It now gives the same clear error as a count above n:
tryCatch( vdist_binom_prob(n = 10, p = 0.3, s = -1, type = "lower"), error = function(e) conditionMessage(e) )
[1] "s must be a whole number of successes between 0 and n (n = 10)."
The same release adds checks for the other families, for example whole-number arguments for the binomial and a documented range for percentile probabilities (1e-12 < probs < 1 - 1e-12).
Percentiles under a decimal comma
Delivery times are about 48 hours on average, with a standard deviation of 6 hours. By what time have 95% of orders arrived?
With options(OutDec = ","), which is common in European locales, every percentile and probability export used to fail with NAs introduced by coercion. The decimal mark is now fixed to . wherever numbers are printed and parsed back:
old <- options(OutDec = ",") vdist_normal_perc(probs = 0.95, mean = 48, sd = 6, type = "lower")
options(old)
qnorm(0.95, mean = 48, sd = 6)
[1] 57.86912
Other improvements
- Continuous percentile probabilities and the normal scale have documented limits, and every limit stops with its own message.
- Captions print enough digits for the percentage they show, including probabilities below 0.1%.
- Binomial captions put the inequality inside
P(), for exampleP(X >= 4), and round once from the exact probability. vdist_t_*(),vdist_chisquare_*()andvdist_f_*()no longer truncate non-integer degrees of freedom.- Plot grids have a bounded number of points, however large the scale.
The release notes carry the rest.
< section id="documentation" class="level2">Documentation
Documentation and examples for every function are at vistributions.rsquaredacademy.com. Report problems at github.com/rsquaredacademy/vistributions/issues.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
