binormalUC.RdDensity, cumulative distribution function and random generation for the bivariate normal distribution distribution.
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)vector of quantiles.
vector of means, variances and the covariance.
number of observations.
Same as rnorm.
Logical.
If log = TRUE then the logarithm of the density is returned.
dbinorm gives the density,
pbinorm gives the cumulative distribution function,
rbinorm generates random deviates (\(n\) by 2 matrix).
The default arguments correspond to the standard bivariate normal
distribution with correlation parameter \(\rho = 0\).
That is, two independent standard normal distributions.
Let sd1 (say) be sqrt(var1) and
written \(\sigma_1\), etc.
Then the general formula for the correlation coefficient is
\(\rho = cov / (\sigma_1 \sigma_2)\)
where \(cov\) 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.
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.
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.
For rbinorm(),
if the \(i\)th variance-covariance matrix is not
positive-definite then the \(i\)th row is all NAs.
yvec <- c(-5, -1.96, 0, 1.96, 5)
ymat <- expand.grid(yvec, yvec)
cbind(ymat, pbinorm(ymat[, 1], ymat[, 2]))
#> Var1 Var2 pbinorm(ymat[, 1], ymat[, 2])
#> 1 -5.00 -5.00 8.216912e-14
#> 2 -1.96 -5.00 7.165686e-09
#> 3 0.00 -5.00 1.433258e-07
#> 4 1.96 -5.00 2.794859e-07
#> 5 5.00 -5.00 2.866515e-07
#> 6 -5.00 -1.96 7.165686e-09
#> 7 -1.96 -1.96 6.248948e-04
#> 8 0.00 -1.96 1.249895e-02
#> 9 1.96 -1.96 2.437300e-02
#> 10 5.00 -1.96 2.499789e-02
#> 11 -5.00 0.00 1.433258e-07
#> 12 -1.96 0.00 1.249895e-02
#> 13 0.00 0.00 2.500000e-01
#> 14 1.96 0.00 4.875011e-01
#> 15 5.00 0.00 4.999999e-01
#> 16 -5.00 1.96 2.794859e-07
#> 17 -1.96 1.96 2.437300e-02
#> 18 0.00 1.96 4.875011e-01
#> 19 1.96 1.96 9.506291e-01
#> 20 5.00 1.96 9.750018e-01
#> 21 -5.00 5.00 2.866515e-07
#> 22 -1.96 5.00 2.499789e-02
#> 23 0.00 5.00 4.999999e-01
#> 24 1.96 5.00 9.750018e-01
#> 25 5.00 5.00 9.999994e-01
if (FALSE) 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)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'rhovec' not found
abline(v = 0, h = 0.25, col = "gray", lty = "dashed") # \dontrun{}
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet