forked from quanteda/quanteda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyness.Rd
76 lines (61 loc) · 1.96 KB
/
keyness.Rd
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/textstat_keyness.R
\name{keyness}
\alias{keyness}
\alias{keyness_chi2_dt}
\alias{keyness_chi2_stats}
\alias{keyness_exact}
\alias{keyness_lr}
\alias{keyness_pmi}
\title{Compute keyness (internal functions)}
\usage{
keyness_chi2_dt(x, correction = c("default", "yates", "williams",
"none"))
keyness_chi2_stats(x)
keyness(t, f, sum_t, sum_f)
keyness_exact(x)
keyness_lr(x, correction = c("default", "yates", "williams", "none"))
keyness_pmi(x)
}
\arguments{
\item{x}{a \link{dfm} object}
\item{correction}{implement the Yates correction for 2x2 tables}
\item{t}{(scalar) frequency of target}
\item{f}{(scalar) frequency of reference}
\item{sum_t}{total of all target words}
\item{sum_f}{total of all reference words}
}
\value{
a data.frame of chi2 and p-values with rows named for each feature
}
\description{
Internal function used in textstat_keyness. Computes \eqn{chi^2} with Yates'
continuity correction for 2x2 tables.
}
\details{
\code{keyness_chi2_dt} uses vectorized computation from data.table
objects.
\code{keyness_chi2_stats} uses element-by-element application of
\link[stats]{chisq.test}.
\code{keyness_exact} computes Fisher's exact using element-by-element
application of \link[stats]{fisher.test}, returning the odds ratio.
\code{keyness_lr} computes the \eqn{G^2} likelihood ratio statistic
using vectorized computation
\code{keyness_pmi} computes the Pointwise Mutual Information stat
using vectorized computation
}
\examples{
dfmat <- dfm(c(d1 = "a a a b b c c c c c c d e f g h h",
d2 = "a a b c c d d d d e f h"))
quanteda:::keyness_chi2_dt(dfmat)
quanteda:::keyness_chi2_stats(dfmat)
quanteda:::keyness_exact(dfmat)
quanteda:::keyness_lr(dfmat)
quanteda:::keyness_pmi(dfmat)
}
\references{
\url{https://en.wikipedia.org/wiki/Yates's_correction_for_continuity}
\url{http://influentialpoints.com/Training/g-likelihood_ratio_test.htm}
}
\keyword{internal}
\keyword{textstat}