MyNixOS website logo
Description

Keyword Analysis Using Permutation Tests.

Efficient implementation of permutation tests for keyword analysis in corpus linguistics as described in Mildenberger (2023) <arXiv:2308.13383>.

keyperm: Keyword Analysis Using Permutation Tests

Implementation of permutation-based keyword analysis for corpus linguistics.

We propose a new approach for assessing keyness in corpus linguistics. Traditional approaches based on hypothesis tests (e.g. Likelihood Ratio Test) model the copora as independent identically distributed samples of tokens. This model does not account for the often observed uneven distribution of occurrences of a word across a corpus. When occurrences of a word are concentrated in few documents, large values of LLR and similar scores are in fact much more likely than accounted for by the token-by-token sampling model, leading to false positives.

We replace the token-by-token sampling model by a model where corpora are samples of documents rather than tokens, which is much closer to the way corpora are actually assembled. We then use a permutation approach to approximate the distribution of a given keyness score under the null hypothesis of equal frequencies and obtain p-values for assessing significance. We do not need any assumption on how the tokens are organized within or across documents, and the approach works with basically any keyness score. The package currently implements LLR, Chi-Square and Logratio scores, the latter with a Laplace-type modification to avoid dividing by zero.

The permutations test has been implemented in C++ using Rcpp, and the data are stored in a format that allows for fast calculations.

The package is not yet on CRAN but can be installed by

library(devtools)
install_github("thmild/keyperm")

The package includes C++ code that needs to be compiled during installation, so compilers etc. are needed. Especially on Windows, these might be tedious to install.

The main function ist keyperm(), see documentation. Before running keyperm(), the frequency counts have to be converted to a special format we call an indexed frequency list by calling create_ifl(). Currently, only term-document matrices in form of tdm objects from package tm are supported. Other input formats may be included in later versions.

demo("example_reuters", package = "keyperm")

runs a commented toy example.

A paper describing the methodology in detail is currently in preparation.

Metadata

Version

0.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows