Calculate Chi-squared-based measure

Description

Computes Chi-squared-based measure between features and target vector.

Usage

1
calc_cs(feature, target_b, len_target, pos_target)

Arguments

feature

feature vector.

target_b

target in bits (as per as.bit).

len_target

length of the target vector.

pos_target

number of positive cases in the target vector.

Value

A numeric vector of length 1 representing computed Chi-square values.

Note

Both target and features must be binary, i.e. contain only 0 and 1 values.

The function was designed to be as fast as possible subroutine of calc_criterion and might be cumbersome if directly called by a user.

See Also

test_features.

chisq.test - Pearson's chi-squared test for count data.

Examples

1
2
3
4
tar <- sample(0L:1, 100, replace = TRUE)
feat <- sample(0L:1, 100, replace = TRUE)
library(bit) # used to code vector as bit
calc_cs(feat, as.bit(tar), 100, sum(tar))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.