rvfactor {rv}R Documentation

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, ...)
  is.rvfactor(x)
  ## S3 method for class 'rvfactor':
  as.rv(x, ...)
  as.rvfactor(x, ...)
  ## S3 method for class 'rvfactor':
  print(x, all.levels=FALSE, ...)

Arguments

x object to be coerced or tested.
levels factor levels (labels for the levels)
all.levels logical; whether to print all levels or not (see below for details)
... other arguments

Details

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

The number of levels to print when all.levels==FALSE can be set by rvpar(max.levels=...). By default this is set to 10.

Value

rvfactor: an rvfactor object.
is.rvfactor: TRUE or FALSE.
as.rv.rvfactor: an rv object.
as.rvfactor.rv: an rvfactor object.

Author(s)

Jouni Kerman jouni@kerman.com

References

Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.

See also vignette("rv").

Examples

  # 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))

[Package rv version 1.0 Index]