Learn R Programming

VGAM (version 1.1-13)

Binom3.or: Trivariate Odds Ratio Model

Description

Density and random generation for a trivariate binary regression model using three odds ratios to measure dependencies.

Usage

dbinom3.or(mu1, mu2 = if (exchangeable) mu1 else
   stop("'mu2' not specified"), mu3 = if (exchangeable)
   mu3 else stop("'mu3' not specified"), oratio12 = 1, 
   oratio13 = 1, oratio23 = 1, exchangeable = FALSE,
   jpmethod = c("min", "mean", "median", "max", "1", "2", "3"),
   tol = 0.001, ErrorCheck = TRUE)
rbinom3.or(n, mu1, mu2 = if (exchangeable) mu1 else
   stop("'mu2' not specified"), mu3 = if (exchangeable) mu1
   else stop("'mu3' not specified"), oratio12 = 1,
   oratio13 = 1, oratio23 = 1, exchangeable = FALSE,
   jpmethod = c("min", "mean", "median", "max", "1", "2", "3"),
   threeCols = TRUE, tol = 0.001, ErrorCheck = TRUE)

Value

The function dbinom3.or returns a 8 column matrix of joint probabilities; each row adds up to unity if the parameters are in the parameter space. If not, then NaNs are returned.

The function rbinom3.or returns either a 3 or 8 column matrix of 1s and 0s, depending on the argument threeCols.

Arguments

n

Same as in dbinom2.or.

mu1, mu2, mu3

Same as in dbinom2.or.

oratio12, oratio13, oratio23

Similar to dbinom2.or, the three odds ratios.

exchangeable

Similar to dbinom2.or. If TRUE, full exchangeability is assumed.

jpmethod

Character, partial matching allowed, the first choice is the default. Joint probability method. Using the notation of binom3.or, how can \(p_{123}\) be defined? The default is to choose pmin(p23 * p1, p13 * p2, p12 * p3) which helps the \(\pi_{000}\) probabilities avoid becoming negative.

threeCols

Logical. If TRUE, then a \(n\) \(\times\) \(3\) matrix of 1s and 0s is returned. If FALSE, then a \(n\) \(\times\) \(8\) matrix of 1s and 0s is returned.

tol, ErrorCheck

Same as dbinom2.or.

Details

The function dbinom3.or does not really compute the density (because that does not make sense here) but rather returns the eight joint probabilities if the parameters are in the parameter space. Simulations have shown that if all the marginal probabilities are uniformly distributed and all the odds ratios have a standard lognormal distribution (with joint independence) then about 31 percent of the parameter space is valid. With exchangeability, it is about 33 percent. This means that binom3.or has quite some severe limitations for general use.

The function rbinom3.or generates data coming from a trivariate binary response model. Valid data from this might be fitted with the VGAM family function binom3.or. Any invalid data (because the parameters are outside the parameter space) are NaNs.

References

Yee, T. W. (2024). New regression methods for three or four binary responses. In preparation.

See Also

binom3.or, is.nan.

Examples

Run this code
dbinom3.or(0.5, 0.5, 0.5, 1, 2, 2)
# Outside the parameter space:
dbinom3.or(0.9, 0.9, 0.9, 1, 2, 2)

if (FALSE)  nn <- 100000
for (Exch in c(TRUE, FALSE)) {
  zdata <- data.frame(orat12 = rlnorm(nn), p1 = runif(nn))
  zdata <- transform(zdata,
             orat13 = if (Exch) orat12 else rlnorm(nn),
             orat23 = if (Exch) orat12 else rlnorm(nn),
             p2 = if (Exch) p1 else runif(nn),
             p3 = if (Exch) p1 else runif(nn))

  mat1 <- with(zdata, dbinom3.or(p1, p2, p3,
               orat12, orat13, orat23, exch = Exch))
# Important statistic: Pr(in the parameter space) =
print(1 - nrow(na.omit(mat1)) / nrow(mat1))
}
round(head(mat1), 4)

Run the code above in your browser using DataLab