| ddiscrete2 {exams.forge} | R Documentation |
Bivariate Discrete Probability Function
Description
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).
Usage
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,
...
)
Arguments
row |
numeric: marginal |
col |
numeric: marginal |
unit |
integer: reciprocal of the smallest non-zero probability (default: |
zero |
logical: zeros are allowed in the final probabilities (default: |
FUN |
function: association or correlation function (default: |
target |
numeric: target association or correlation (default: |
tol |
numeric: tolerance for target association or correlation (default: |
maxit |
integer: maximal number of iterations (default: |
... |
further parameters for |
Value
A bivariate discrete probability function.
Examples
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"))