| Type: | Package |
| Title: | Probabilities for Bivariate Normal Distribution |
| Version: | 0.5-47 |
| Date: | 2023-11-30 15:01:12.000296 |
| Author: | Alexander Robitzsch [aut,cre] (<https://orcid.org/0000-0002-8226-3132>) |
| Maintainer: | Alexander Robitzsch <robitzsch@ipn.uni-kiel.de> |
| Description: | Computes probabilities of the bivariate normal distribution in a vectorized R function (Drezner & Wesolowsky, 1990, <doi:10.1080/00949659008811236>). |
| Depends: | R (≥ 3.1) |
| Imports: | Rcpp |
| Enhances: | pbivnorm |
| LinkingTo: | Rcpp, RcppArmadillo |
| URL: | https://github.com/alexanderrobitzsch/pbv,https://sites.google.com/view/alexander-robitzsch/software |
| License: | GPL-2 |GPL-3 [expanded from: GPL (≥ 2)] |
| NeedsCompilation: | yes |
| Packaged: | 2023-11-30 14:02:18 UTC; sunpn563 |
| Repository: | CRAN |
| Date/Publication: | 2023-11-30 15:20:02 UTC |
Probabilities for Bivariate Normal Distribution
Description
Computes probabilities of the bivariate normal distribution in a vectorized R function (Drezner & Wesolowsky, 1990, <doi:10.1080/00949659008811236>).
Author(s)
Alexander Robitzsch [aut,cre] (<https://orcid.org/0000-0002-8226-3132>)
Maintainer: Alexander Robitzsch <robitzsch@ipn.uni-kiel.de>
References
Drezner, Z., & Wesolowsky, G. O. (1990). On the computation of the bivariate normal integral.Journal of Statistical Computation and Simulation, 35(1-2), 101-107.doi:10.1080/00949659008811236
Probabilities for Bivariate Normal Distribution
Description
The functionpbvnorm computes probabilities\Phi_2(x,y,\rho) forthe standardized bivariate normal distribution (Drezner & Wesolowsky, 1990;West, 2004).
The functiondbvnorm computes the corresponding density\phi_2(x,y,\rho).
Usage
pbvnorm(x, y, rho)dbvnorm(x, y, rho, log=FALSE)## exported Rcpp functionspbv_rcpp_pbvnorm0( h1, hk, r)pbv_rcpp_pbvnorm( x, y, rho)pbv_rcpp_dbvnorm0( x, y, rho, use_log)pbv_rcpp_dbvnorm( x, y, rho, use_log)Arguments
x | Vector of first ordinate |
y | Vector of second ordinate |
rho | Vector of correlations |
log | Logical indicating whether logarithm of the densityshould be calculated |
h1 | Numeric |
hk | Numeric |
r | Numeric |
use_log | Logical |
Value
A vector
Note
Thepbv package can also be used to includeRcpp functions forcomputing bivariate probabilities at the C++ level. Numeric and vector versions aredouble pbv::pbv_rcpp_pbvnorm0( double h1, double hk, double r)Rcpp::NumericVector pbv::pbv_rcpp_pbvnorm( Rcpp::NumericVector x, Rcpp::NumericVector y, Rcpp::NumericVector rho)
References
Drezner, Z., & Wesolowsky, G. O. (1990). On the computation of the bivariate normalintegral.Journal of Statistical Computation and Simulation, 35(1-2), 101-107.doi:10.1080/00949659008811236
Genz, A. (1992). Numerical computation of multivariate normal probabilities.Journal of Computational and Graphical Statistics, 1(2), 141-149.
West, G. (2005). Better approximations to cumulative normal functions.Wilmott Magazine, 9, 70-76.
See Also
Seepbivnorm::pbivnorm in thepbivnorm packageandmnormt::biv.nt.prob in themnormt packagefor alternative implementations (Genz, 1992).
Examples
############################################################################## EXAMPLE 1: Comparison with alternative implementations##############################################################################*** simulate different values of ordinates and correlationsset.seed(9898)N <- 3000x <- stats::runif(N,-3,3)y <- stats::runif(N,-3,3)rho <- stats::runif(N,-.95,.95)#*** compute probabilitiesres1 <- pbv::pbvnorm(x=x,y=y,rho=rho)## Not run: #-- compare results with pbivnorm packagelibrary(pbivnorm)res2 <- pbivnorm::pbivnorm(x=x, y=y, rho=rho)summary(abs(res1-res2))#*** compute density valueslog <- TRUE # logical indicating whether log density should be evaluatedres1 <- pbv::dbvnorm(x=x, y=y, rho=rho, log=log )#-- compare results with mvtnorm packagelibrary(mvtnorm)res2 <- rep(NA, N)sigma <- diag(2)for (ii in 1:N){ sigma[1,2] <- sigma[2,1] <- rho[ii] res2[ii] <- mvtnorm::dmvnorm(x=c(x[ii],y[ii]), sigma=sigma, log=log)}summary(abs(res1-res2))## End(Not run)