
"prova" /'prɔva/ noun: test, trial, assessment, proof, evidence, sign, indication, try, attempt; verb: test!, try out!, assess!, attempt!, prove!, demonstrate!, show!
("What's a variate?" Answer here[^1])
A versatile R package for general-purpose probabilistic and statistical data analysis and inference, including specialized kinds of analysis. These are its main features:
The package essentially performs Bayesian nonparametric inference (also called "density inference" or "inference under exchangeability"), which makes most features above possible.
Use examples (see literature below for concrete examples):
Load the package:
library('prova')
Use the R penguins dataset (or download a shuffled version from here), together with the metadata meta_penguins available in Prova. Metadata contain the characteristics of the dataset's variates.
"Learn" from this dataset using the function learn(). Note that the dataset has partially missing values (datapoint #4 for instance), but this is not a problem for Prova:
K <- learn(data = penguins, metadata = meta_penguins)
# [progress output about the learning computation]
The object K (for "Knowledge" or "Known") encodes what has been learnt from data and metadata.
Ask a statistical question about the penguin population. For example: given the data we have collected, what is the probability that a new penguin from this population is of species 'Adélie', if its bill length is 40 mm? In probability notation:
$$ \mathrm{Pr}(\text{species = Adelie} \thinspace\vert\thinspace\mathopen{} \text{bill len = 40 mm}, K) $$
where $K$ stands for the knowledge acquired from data and metadata. To answer this question, use the function Pr(), which has arguments corresponding to the notation above, and print a summary of the result:
prob <- Pr(
data.frame(species = 'Adelie'), # predictand
data.frame(bill_len = 40), # predictor
K # Knowledge from data & metadata
)
print(prob)
# , , |bill_len = 40
#
# probability
# species value +/- Q5.5% Q25% Q75% Q94.5%
# Adelie 0.94827 0.00049 0.91272 0.93652 0.96289 0.97634
The answer is that there is roughly a 95% probability that a new penguin, among those with a 40 mm bill length, is of species 'Adélie'.
Now ask: what is the relative frequency of the species 'Adélie' in the whole subpopulation of penguins (including unsampled penguins) having bill length of 40 mm? This question cannot be answered with certainty, because we have only a sample of the full population. But Prova can calculate the probability distribution for this full-population frequency. In fact, it has already been calculated by the function Pr() above, and we can visualize it with a plot:
hist(prob)
The plot shows that this full-population frequency is most likely (with roughly 90% probability) between 0.91 and 0.98. These are the "Q5.5%" and "Q94.5%" values shown by print(prob) above.
The inverse question can also be asked: if we observe a new penguin of species 'Adélie', what could its bill length be? The answer is uncertain, and Prova can calculate the probability distribution of the penguin's bill length:
invprob <- Pr(
data.frame(bill_len = seq(30, 60, by = 0.5)), # predictand
data.frame(species = 'Adelie'), # predictor
K # knowledge
)
plot(invprob, col = 2)
this probability distribution has a peak between 35 mm and 40 mm and it's slightly skewed.
This distribution is not the frequency distribution of bill length in the whole subpopulation of Adélie penguins: such distribution is uncertain because we have only a sample. But the plot above shows that this frequency distribution is (with roughly 90% probability) somewhere between the widest coloured bands. Alternatively we can display this uncertainty with an ensemble plot of probable frequency distributions:
plot(invprob, col = 2, spread = 'samples')
This was just a minimal example, just touching on the basic functionality. More complex combinations of variates and more complex probabilistic-statistical questions can be approached.
The introductory vignette explains, with a guided example, most of the features above, as well as the main ideas and functions. It can be particularly useful for researchers who are more familiar with traditional "frequentist" statistics but would like to try the Bayesian approach. See the post by Barbara W. Sarnecka, frequentist statistician turned Bayesian, for a brilliant overview of the Bayesian advantages. The vignette about mutual information explains the use of this powerful measure of association.
The package is under continuous development, but the core functionalities work and have been tested in concrete research projects; see example applications below.
The package internally does the computations necessary for Bayesian inference by means of Monte Carlo methods thanks to the R package Nimble. As already mentioned, this computation is automated. Users familiar with Monte Carlo methods can still access computational details and can even change some of the computation hyperparameters.
You need to have installed the package Nimble, at least version 1.4.2. Please follow Nimble's installation instructions for your operating system.
Then Prova can be installed from CRAN with
install.packages('prova')
In case of a newer version not yet on CRAN, it can be installed with
# remotes::install_github('pglpm/prova')
install.packages("prova", repos = c('https://pglpm.r-universe.dev', 'https://cloud.r-project.org'))
or, if you also want the vignettes, with
remotes::install_github('pglpm/prova', build_vignettes = TRUE, dependencies = TRUE)
The vignette An introduction to probabilistic-statistical variate analysis is a step-by-step introduction to Prova and also to Bayesian nonparametrics. It guides you through a concrete example with various kinds of inferences. You may also try to follow it using a dataset of your own.
Other tutorials are available at pglpm.github.io/prova, or can be accessed in an R session with browseVignettes('prova').
A summary of the theoretical foundations, including further references, is available in this draft. The main idea for the internal mathematical representation comes from Dunson & Bhattacharya and Ishwaran & Zarepour.
For a low-level course on Bayesian nonparametric inference and Decision Theory see Data Science and AI Prototyping.
Please report bugs and request features or specific documentation on GitHub Issues. If you have other questions about application, theory, technical implementation, feel free to contact Luca pglXYZ@portamanaXYZ.org (remove 'XYZ' for anti-spam purposes).
No large language models were used in the production of this software and of its documents.
[^1]: variate: "a quantity having a numerical value for each member of a group, especially one whose values occur according to a frequency distribution." (Concise Oxford English Dictionary).
variable: "a factor or quantity able to assume different numerical values" (Concise Oxford English Dictionary).