prob {rvec}R Documentation

Calculate Probabilities from Random Draws

Description

Convert an rvec of logical values (an rvec_lgl) into a vector of probabilities.

Usage

prob(x, na_rm = FALSE)

## S3 method for class 'rvec_lgl'
prob(x, na_rm = FALSE)

## S3 method for class 'logical'
prob(x, na_rm = FALSE)

Arguments

x

An object of class rvec_lgl.

na_rm

Whether to remove NAs before calculating summaries. Default is FALSE.

Details

prob() is essentially just draws_mean() with a different name. The proportion of draws that are TRUE is used as an estimate of the underlying probability. The different name can make the intent of the code clearer.

Value

A logical vector with the same length as x.

See Also

Examples

m <- rbind(c(FALSE,  TRUE),
           c(TRUE,   TRUE),
           c(FALSE,  FALSE))
x <- rvec(m)
x
prob(x)

## logical rvec created on the fly
## through operations such as '>'
m <- rbind(c(-1,  1.3, 2),
           c(2, 0.1, -1),
           c(Inf, 0, -0.5))
y <- rvec(m)
y
prob(y > 0)
prob(y >= 0)
prob(y^2 > 0)

[Package rvec version 0.0.8 Index]