distr {FAmle} | R Documentation |
Distribution functions 4-in-1
Description
This function can be used to call any of the 4 functions specific to a given probability distribution available in R.
Usage
distr(x, dist, param, type = "d", model = NULL, ...)
Arguments
x |
Vector (or array) of quantiles, vector (or array) of probabilities, or number of observations. |
dist |
Distribution name. |
param |
Vector (or array) of parameters. |
type |
Type of function to be called ( |
model |
Object from the class |
... |
Additional arguments |
Details
For each distribution available in R, 4 functions can be called. For example, for the normal distribution, the following 4 functions are available: dnorm
, pnorm
, qnorm
, and rnorm
. For the normal distribution, based on the argument type
, distr
may be used to call any one of the previous four functions.
Value
Returns the density, the distribution function, the quantile function, or random variates.
Note
Most functions in FAmle
rely upon distr
.
Examples
## Example 1
dnorm(-4:4,0,1,log=TRUE)
distr(-4:4,'norm',c(0,1),type='d',log=TRUE)
## Example 2
mu.vec <- c(1,100,100)
sigma.vec <- c(1,11,111)
n <- 3
set.seed(123)
rnorm(n,mu.vec,sigma.vec)
set.seed(123)
distr(n,'norm',cbind(mu.vec,sigma.vec),'r')
## Example 3
qnorm(.9,mu.vec,sigma.vec)
distr(.9,'norm',cbind(mu.vec,sigma.vec),'q')