% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dprodcor.R, R/pprodcor.R, R/qprodcor.R,
%   R/rprodcor.R
\name{prodcor}
\alias{prodcor}
\alias{dprodcor}
\alias{pprodcor}
\alias{qprodcor}
\alias{rprodcor}
\title{The Correlated Standard Normal Product Distribution}
\usage{
dprodcor(x, rho)

pprodcor(x, rho, eps = 1e-08)

qprodcor(p, rho)

rprodcor(n, rho)
}
\arguments{
\item{x}{Vector of quantiles.}

\item{rho}{Correlation parameter, must be a scalar in [-1, 1].}

\item{eps}{Near zero value to use for integrating around the divergence at \code{x=0}.}

\item{p}{Vector of probabilities.}

\item{n}{Number of observations.  If \code{length(n) > 1}, the length is taken to be the number required.}
}
\value{
\code{dprodcor} gives the density, \code{pprodcor} the cumulative, and \code{qprodcor} the quantile function.  \code{rprodcor} generates random deviates.  The length of the result is determined by \code{n} for \code{rnorm}, and it is the length of \code{x} or \code{p} for the other functions.
}
\description{
Density, cumulative, quantile, and random generation for the product of two correlated standard normal variables with correlation parameter \code{rho}.
}
\details{
\code{pprodcor} does not have a closed form, so it is calculated by numerical integration of \code{dprodcor}.
Furthermore, \code{dprodcor(0)} is infinite, so in order for numerical integration to succeed, we exclude the window \code{c(-eps, eps)} for arguments near zero.  \code{eps} is the initial value, but if failure is still encountered, \code{eps} is incremented by factors of 10 until successful.  (For positive arguments integration from above is used instead, subtracted from 1.)
\code{qprodcor} also does not have a closed form, so it is calculated using a root finder on \code{pprodcor}, which makes it very slow.
}
\examples{
n <- 10
x <- rnorm( n )
p <- runif( n )
rho <- 0.8
dprodcor( x, rho )
pprodcor( x, rho )
qprodcor( p, rho )
rprodcor( n, rho )

}
\references{
Nadarajah, Saralees, and Tibor K. Pogány. “On the Distribution of the Product of Correlated Normal Random Variables.” Comptes Rendus Mathematique 354, no. 2 (2016): 201–4. \doi{10.1016/j.crma.2015.10.019}.

Gaunt, Robert E. “The Basic Distributional Theory for the Product of Zero Mean Correlated Normal Random Variables.” Statistica Neerlandica 76, no. 4 (2022): 450–70. \doi{10.1111/stan.12267}.
}
