Learn R Programming

BinaryReplicates (version 1.0.0)

bayesian_computations: Bayesian computations

Description

Get credible intervals, Bayesian scores, and prevalence estimate from the stanfit object returned by BayesianFit.

Usage

credint(fit, level = 0.9)

bayesian_scoring(ni, si, fit)

bayesian_prevalence_estimate(fit)

Value

The credint function returns the credible interval bounds for the fixed parameters of the Bayesian model. The default posterior probability is 90%.

The bayesian_scoring function returns the Bayesian scores. These scores are the posterior probabilities that the true latent \(T_i\)'s are equal to 1.

The bayesian_prevalence_estimate function returns the posterior mean of the posterior distribution on the prevalence of \(T_i = 1\).

Arguments

fit

The stanfit object returned by BayesianFit

level

Posterior probability of the credible intervals

ni

Numeric vector of \(n_i\)'s, the total numbers of replicates for each individual

si

Numeric vector of \(s_i\)'s, the numbers of replicates equal to 1 for each individual

Details

See BayesianFit for details on the Bayesian model.

See Also

classify_with_scores, BayesianFit

Examples

Run this code
data("periodontal")
theta <- mean(periodontal$ti)
fit <- BayesianFit(periodontal$ni, periodontal$si, chains = 2, iter = 5000)
credint(fit)
Y_B <- bayesian_scoring(periodontal$ni, periodontal$si, fit)
T_B <- classify_with_scores(Y_B, .4, .6)
theta_B <- bayesian_prevalence_estimate(fit)
cat("The Bayesian prevalence estimate is ", theta_B, "\n")
cat("The prevalence in the data is ", theta, "\n")

Run the code above in your browser using DataLab