two.sample.pvals: Feature-by-feature exact binomial test between two tables

Description Usage Arguments Value Examples

View source: R/TableHC.R

Description

Align tables and use an exact binomial test (binom.test) on each feature. Alignment is done using "outer mergeing"; missing values are filled with zeros.

Usage

1
two.sample.pvals(tb1, tb2)

Arguments

tb1

A one-way table with integer counts.

tb2

A one-way table with integer counts.

Value

table of pair of counts per feature and a p-value associated with each pair.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
tb1 = table(c(1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,4,4,4,5,6,6,7,7,7))
tb2 = table(c(1,1,1,1,1,1,1,1,1,2,3,3,3,3,3,4,4,4,5,5,5,6))
PV = two.sample.pvals(tb1, tb2) # compute P-values 
HC.vals(PV$pv)  # use the Higher-Criticism to combine the P-values 
                # for a global test

# Can be used to check similarity of word-frequencies in texts:

text1 = "On the day House Democrats opened an impeachment inquiry of 
President Trump last week, Pete Buttigieg was being grilled by Iowa
voters on other subjects: how to loosen the grip of the rich on government, 
how to restore science to policymaking, how to reduce child poverty. At an
event in eastern Iowa, a woman rose to say that her four adult children
were `stuck' in life, unable to afford what she had in the 1980s when a 
$10-an-hour job paid for rent, utilities and an annual vacation."

text2 = "How can the federal government help our young people that want to
do whats right and to get to those things that their parents worked so hard
for? the voter asked. This is the conversation Mr. Buttigieg wants to have. 
Boasting a huge financial war chest but struggling in the polls, Mr.
Buttigieg is now staking his presidential candidacy on Iowa, and particularly
on connecting with rural white voters who want to talk about personal
concerns more than impeachment. In doing so, Mr. Buttigieg is also trying to
show how Democrats can win back counties that flipped from Barack Obama to 
Donald Trump in 2016 — there are more of them in Iowa than any other state — 
by focusing, he said, on “the things that are going to affect folks’ lives in
a concrete way."

tb1 = table(strsplit(tolower(text1),' '))
tb2 = table(strsplit(tolower(text2),' '))
pv = two.sample.pvals(tb1,tb2)
HC.vals(pv$pv)

TableHC documentation built on March 26, 2020, 7:11 p.m.