frequency_matching: Frequency Matching

View source: R/KOD.R

frequency_matchingR Documentation

Frequency Matching

Description

A method to select unbalanced groupd in a cohort.

Usage

frequency_matching (data,label,times=5,seed=1234)

Arguments

data

a data.frame of data.

label

a classification of the groups.

times

The ratio between the two groups.

seed

a single number for random number generation.

Value

The function returns a list with 2 items or 4 items (if a test data set is present):

data

the data after the frequency matching.

label

the label after the frequency matching.

selection

the rows selected for the frequency matching.

Author(s)

Stefano Cacciatore

References

Cacciatore S, Luchinat C, Tenori L
Knowledge discovery by accuracy maximization.
Proc Natl Acad Sci U S A 2014;111(14):5117-22. doi: 10.1073/pnas.1220873111. Link

Cacciatore S, Tenori L, Luchinat C, Bennett PR, MacIntyre DA
KODAMA: an updated R package for knowledge discovery and data mining.
Bioinformatics 2017;33(4):621-623. doi: 10.1093/bioinformatics/btw705. Link

Examples

data(clinical)


A=categorical.test("Gender",clinical[,"Gender"],clinical[,"Hospital"])
B=categorical.test("Gleason score",clinical[,"Gleason score"],clinical[,"Hospital"])

C=continuous.test("BMI",clinical[,"BMI"],clinical[,"Hospital"],digits=2,pos=2)
D=continuous.test("Age",clinical[,"Age"],clinical[,"Hospital"],digits=1,pos=2)


# Analysis without matching
rbind(A,B,C,D)



# The order is important. Right is more important than left in the vector
# So, Ethnicity will be more important than Age
var=c("Age","BMI","Gleason score")
t=frequency_matching(clinical[,var],clinical[,"Hospital"],times=1)

newdata=clinical[t$selection,]

A=categorical.test("Gender",newdata[,"Gender"],newdata[,"Hospital"])
B=categorical.test("Gleason score",newdata[,"Gleason score"],newdata[,"Hospital"])

C=continuous.test("BMI",newdata[,"BMI"],newdata[,"Hospital"],digits=2,pos=2)
D=continuous.test("Age",newdata[,"Age"],newdata[,"Hospital"],digits=1,pos=2)

# Analysis with matching
rbind(A,B,C,D)


KODAMA documentation built on April 1, 2022, 5:06 p.m.