Creates a bivariate discrete probability function based on the marginal probability functions
row
and col
. If unit
is not given then unit
will be the product of the units
used in row
and col
, otherwise it will appear as the least common multiple unit
product of
the units used in row
and col
.
If target
is NA
then the common distribution of two independent random variables
is returned, otherwise an iterative algorithm is run to approach a target
association or
correlation measure, see also assoc_data()
(called internally).
zero
allows for zero entries in the common distribution.
FUN
computes the association or correlation measures based on a
frequency table. tol
gives the maximal deviation of the association or correlation measure
and the target
value. maxit
limits the number of steps.
Please note that a solution is not guaranteed, especially for extreme values for target
, for example
for \(+1\), \(-1\) or nearby values.
If attr(joint, "iterations")==maxit
then you need
either to increase maxit
, to decrease tol
or to check if you have chosen an
appropriate target
value (for a nominal measure in \(0 <= target <= 1\), for ordinal measure in \(-1 <= target <= +1\)).
ddiscrete2(
row,
col,
unit = NULL,
zero = FALSE,
FUN = nom.cc,
target = NA,
tol = 0.001,
maxit = 500,
...
)biv_discrete_prob(
row,
col,
unit = NULL,
zero = FALSE,
FUN = nom.cc,
target = NA,
tol = 0.001,
maxit = 500,
...
)
A bivariate discrete probability function.
numeric: marginal row
distribution
numeric: marginal col
distribution
integer: reciprocal of the smallest non-zero probability (default: NULL
)
logical: zeros are allowed in the final probabilities (default: FALSE
)
function: association or correlation function (default: nom.cc
)
numeric: target association or correlation (default: NA
)
numeric: tolerance for target association or correlation (default: 0.001
)
integer: maximal number of iterations (default: 100
)
further parameters for FUN
row <- ddiscrete(runif(5))
col <- ddiscrete(runif(3))
joint <- ddiscrete2(row, col)
joint
joint <- ddiscrete2(row, col, target=0.5)
joint
nom.cc(joint*attr(joint, "unit"))
Run the code above in your browser using DataLab