binom3.orUC.RdDensity and random generation for a trivariate binary regression model using three odds ratios to measure dependencies.
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)Same as in dbinom2.or.
Same as in dbinom2.or.
Similar to dbinom2.or,
the three odds ratios.
Similar to dbinom2.or.
If TRUE, full exchangeability is assumed.
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.
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.
Same as dbinom2.or.
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.
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.
Yee, T. W. (2024). New regression methods for three or four binary responses. In preparation.
dbinom3.or(0.5, 0.5, 0.5, 1, 2, 2)
#> 000 001 010 011 100 101 110 111
#> [1,] 0.2107864 0.03921356 0.1035534 0.1464466 0.1035534 0.1464466 0.125 0.125
# Outside the parameter space:
dbinom3.or(0.9, 0.9, 0.9, 1, 2, 2)
#> 000 001 010 011 100 101 110 111
#> [1,] NaN NaN NaN NaN NaN NaN NaN NaN
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))
}
#> Error: object 'nn' not found
round(head(mat1), 4)
#> Error: object 'mat1' not found
# \dontrun{}