Learn R Programming

rv (version 0.949)

rvfactor: Categorical Random Variables (Random Factors)

Description

Creates or tests for objects of type ``rvfactor".

Usage

rvfactor(x, ...)
  ## S3 method for class 'rv':
rvfactor(x, levels=NULL, \dots)
  is.rvfactor(x)
  ## S3 method for class 'rvfactor':
as.rv(x)
  as.rvfactor(x, ...)

Arguments

x
object to be coerced or tested.
levels
factor levels (labels for the levels)
...
other arguments

Value

  • rvfactor: an rvfactor object.

    is.rvfactor: TRUE or FALSE.

    as.rv.rvfactor: an rv object.

    as.rvfactor.rv: an rvfactor object.

Details

Internally random factors are integer-valued just like regular factors in R.

References

Kerman, Jouni and Gelman, Andrew. Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Technical report, Columbia University, New York. http://www.stat.columbia.edu/~kerman/Research/postsim.pdf

Examples

Run this code
# Probabilities of each integer of trunc(Z) where Z ~ N(0,1) ?
  x <- rvnorm(1)
  rvfactor(trunc(x))
  rvfactor(x>0)
  rvfactor(rvpois(1, lambda=0.5))

Run the code above in your browser using DataLab