Generates a random variable from a Student-t sampling model.

rvt(n = 1, mu = 0, scale = 1, df, ncp, Sigma)

Arguments

n

integer, number of scalars to generate

mu

location, may be a rv

scale

scale, may be a rv

df

degrees of freedom, may be a rv

ncp

non-centrality parameter

Sigma

(optional) scaling matrix for multivariate generation

Details

This function generates both univariate (independent and identically distributed) Student-t random variables and multivariate Student-t distributed vectors (with a given scaling matrix).

For details of the parameters, see the entry on mvt in the mvtnorm package.

Note

If any of the arguments are random, the resulting simulations may have non-t marginal distributions.

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").

Author

Jouni Kerman jouni@kerman.com

Examples


  df <- 3
  x <- rvt(n=1, df=df)
  y <- rvnorm(1)/sqrt(rvchisq(1, df=df)/df) # Same distribution as above
  print(c(x,y))#'   
#>       mean  sd   1% 2.5%   25%    50%  75% 97.5% 99% sims
#> [1] -0.140 1.4 -3.6 -2.6 -0.69 -0.091 0.63   2.1 3.2  200
#> [2] -0.086 1.5 -6.3 -3.2 -0.72  0.040 0.61   2.7 3.1  200