Reorders the entries of a frequency table to approximate a given target association or correlation.
The reordering preserves the marginal frequencies of the table. Note that the target association may not always be achievable, especially for extreme values (e.g., +1, -1, or values near these limits).
assoc_data(
tab,
zero = FALSE,
FUN = nom.cc,
target = NA,
tol = 0.001,
maxit = 500,
...
)reorder_association_data(
tab,
zero = FALSE,
FUN = nom.cc,
target = NA,
tol = 0.001,
maxit = 500,
...
)
dassoc(
tab,
zero = FALSE,
FUN = nom.cc,
target = NA,
tol = 0.001,
maxit = 500,
...
)
A frequency table reordered to approximate the target association. The returned object includes attributes:
iterations
Number of iterations performed.
target
Achieved association or correlation value.
table A contingency table of absolute frequencies.
logical Whether zeros are allowed in the resulting table (default: FALSE
).
function A function that computes the association or correlation from a frequency table (default: nom.cc).
numeric Desired association or correlation value (default: NA
, which returns the original table).
numeric Maximum allowed deviation between the achieved and target association (default: 0.001
).
integer Maximum number of iterations to reach the target (default: 500
).
Additional parameters passed to FUN
.
The function attempts to reorder the table entries to reach the target association. If the target is extreme
(e.g., +1, -1, or values near these limits), a solution may not be possible.
If attr(joint, "iterations")
equals maxit
, consider increasing maxit
,
reducing tol
, or choosing a more feasible target
value:
Nominal measures: \(0 \le target \le 1\)
Ordinal measures: \(-1 \le target \le +1\)
tab <- table_data(3, 2)
tab
tab2 <- assoc_data(tab, target = 0.5)
tab2
Run the code above in your browser using DataLab