Binorm {VGAM}R Documentation

Bivariate Normal Distribution Cumulative Distribution Function

Description

Density, cumulative distribution function and random generation for the bivariate normal distribution distribution.

Usage

dbinorm(x1, x2, mean1 = 0, mean2 = 0, var1 = 1, var2 = 1, cov12 = 0,
        log = FALSE)
pbinorm(q1, q2, mean1 = 0, mean2 = 0, var1 = 1, var2 = 1, cov12 = 0)
rbinorm(n,      mean1 = 0, mean2 = 0, var1 = 1, var2 = 1, cov12 = 0)
 pnorm2(x1, x2, mean1 = 0, mean2 = 0, var1 = 1, var2 = 1, cov12 = 0)

Arguments

x1, x2, q1, q2

vector of quantiles.

mean1, mean2, var1, var2, cov12

vector of means, variances and the covariance.

n

number of observations. Same as rnorm.

log

Logical. If log = TRUE then the logarithm of the density is returned.

Details

The default arguments correspond to the standard bivariate normal distribution with correlation parameter ρ=0\rho = 0. That is, two independent standard normal distributions. Let sd1 (say) be sqrt(var1) and written σ1\sigma_1, etc. Then the general formula for the correlation coefficient is ρ=cov/(σ1σ2)\rho = cov / (\sigma_1 \sigma_2) where covcov is argument cov12. Thus if arguments var1 and var2 are left alone then cov12 can be inputted with ρ\rho.

One can think of this function as an extension of pnorm to two dimensions, however note that the argument names have been changed for VGAM 0.9-1 onwards.

Value

dbinorm gives the density, pbinorm gives the cumulative distribution function, rbinorm generates random deviates (nn by 2 matrix).

Warning

Being based on an approximation, the results of pbinorm() may be negative! Also, pnorm2() should be withdrawn soon; use pbinorm() instead because it is identical.

Note

For rbinorm(), if the iith variance-covariance matrix is not positive-definite then the iith row is all NAs.

References

pbinorm() is based on Donnelly (1973), the code was translated from FORTRAN to ratfor using struct, and then from ratfor to C manually. The function was originally called bivnor, and TWY only wrote a wrapper function.

Donnelly, T. G. (1973). Algorithm 462: Bivariate Normal Distribution. Communications of the ACM, 16, 638.

See Also

pnorm, binormal, uninormal.

Examples

yvec <- c(-5, -1.96, 0, 1.96, 5)
ymat <- expand.grid(yvec, yvec)
cbind(ymat, pbinorm(ymat[, 1], ymat[, 2]))

## Not run:  rhovec <- seq(-0.95, 0.95, by = 0.01)
plot(rhovec, pbinorm(0, 0, cov12 = rhovec),
     xlab = expression(rho), lwd = 2,
     type = "l", col = "blue", las = 1)
abline(v = 0, h = 0.25, col = "gray", lty = "dashed") 
## End(Not run)

[Package VGAM version 1.1-11 Index]