assoc_data: assoc_data

View source: R/assoc_data.R

assoc_dataR Documentation

assoc_data

Description

Given a frequency table the function reorders the observations such that the given target association will be approximated and the marginal frequencies are unchanged. Note that the target association may not be reached! zero allows for zero entries in the common distribution. If target is NA then the table is simply returned. FUN computes the association (or correlation) measure 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. Note that a solution is not guaranteed, especially for extreme values for target, for example for +1 or -1 or values nearby. If attr(joint, "iterations")==maxit then you need either to increase maxit, to decrease tol or to check if you have choosen an appropriate target value (for a nominal measure in 0 <= target <= 1, for ordinal measure in -1 <= target <= +1). attr(joint, "target") contains the achieved association.

Usage

assoc_data(
  tab,
  zero = FALSE,
  FUN = nom.cc,
  target = NA,
  tol = 0.001,
  maxit = 500,
  ...
)

Arguments

tab

table: table of absolute frequencies

zero

logical: zeros in the final probabilities allowed (default: FALSE)

FUN

function: association or correlation function (default: nom.cc)

target

numeric: target association or correlation (default: NA)

tol

numeric: tolerance for target association or correlation (default: 0.001)

maxit

integer: maximal number of iterations (default: 100)

...

further parameter for FUN

Value

a modified frequency table

Examples

tab <- table_data(3, 2)
tab
tab2 <- assoc_data(tab, target=0.5)
tab2

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.