MyNixOS website logo
Description

Analyze Nominal Response Data with the Multinomial-Poisson Trick.

Dichotomous responses having two categories can be analyzed with stats::glm() or lme4::glmer() using the family=binomial option. Unfortunately, polytomous responses with three or more unordered categories cannot be analyzed similarly because there is no analogous family=multinomial option. For between-subjects data, nnet::multinom() can address this need, but it cannot handle random factors and therefore cannot handle repeated measures. To address this gap, we transform nominal response data into counts for each categorical alternative. These counts are then analyzed using (mixed) Poisson regression as per Baker (1994) <doi:10.2307/2348134>. Omnibus analyses of variance can be run along with post hoc pairwise comparisons. For users wishing to analyze nominal responses from surveys or experiments, the functions in this package essentially act as though stats::glm() or lme4::glmer() provide a family=multinomial option.

multpois

Jacob O. Wobbrock, University of Washington [email protected]

The goal of multpois is to use the multinomial-Poisson trick to provide for the analysis of nominal response data with or without repeated measures. Such responses, which often arise from surveys or experiments, consist of unordered categories. Although dichotomous responses can be analyzed with glm() or lme4::glmer() using the family=binomial option, there is no analogous family=multinomial option for polytomous responses. In the case of purely between-subjects data, nnet::multinom() can be used, but it cannot take random factors and therefore cannot handle repeated measures. To address this issue, the multpois package provides for the equivalent of a family=multinomial option in glm() or lme4::glmer() via the multinomial-Poisson trick, which converts nominal response data into counts of categorical alternatives and analyzes these counts using (mixed) Poisson regression. Omnibus tests of main effects and interactions are provided through analysis of variance-style output. Post hoc pairwise comparisons are also provided through contrast testing.

Installation

You can install the multpois package like so:

install.packages("multpois")

Example

This is a basic example which shows you how to solve a common problem:

library(multpois)
set.seed(123) # for repeatable results

## a generic 2x2 between-subjects example
ac = sample(c("yes","no","maybe"), size=15, replace=TRUE, prob=c(0.1, 0.6, 0.3))
ad = sample(c("yes","no","maybe"), size=15, replace=TRUE, prob=c(0.4, 0.4, 0.2))
bc = sample(c("yes","no","maybe"), size=15, replace=TRUE, prob=c(0.5, 0.1, 0.4))
bd = sample(c("yes","no","maybe"), size=15, replace=TRUE, prob=c(0.1, 0.5, 0.4))
df1 = data.frame(
  PId = factor(seq(1, 60, 1)),
  X1 = factor(c(rep("a",30), rep("b",30))),
  X2 = factor(rep(c(rep("c",15), rep("d",15)), times=2)),
  Y = factor(c(ac, ad, bc, bd), levels=c("yes","no","maybe"))
)
View(df1)
mosaicplot( ~ X1 + X2 + Y, data=df1, cex=1, col=c("lightgreen","pink","lightyellow"))
m = glm.mp(Y ~ X1*X2, data=df1)
Anova.mp(m, type=3)
glm.mp.con(m, pairwise ~ X1*X2, adjust="holm")

## a generic 2x2 within-subjects example
ac = sample(c("yes","no","maybe"), size=15, replace=TRUE, prob=c(0.2, 0.6, 0.2))
ad = sample(c("yes","no","maybe"), size=15, replace=TRUE, prob=c(0.4, 0.4, 0.2))
bc = sample(c("yes","no","maybe"), size=15, replace=TRUE, prob=c(0.5, 0.2, 0.3))
bd = sample(c("yes","no","maybe"), size=15, replace=TRUE, prob=c(0.2, 0.5, 0.3))
df2 = data.frame(
  PId = factor(rep(1:15, times=4)),
  X1 = factor(c(rep("a",30), rep("b",30))),
  X2 = factor(rep(c(rep("c",15), rep("d",15)), times=2)),
  Y = factor(c(ac, ad, bc, bd), levels=c("yes","no","maybe"))
)
View(df2)
mosaicplot( ~ X1 + X2 + Y, data=df2, cex=1, col=c("lightgreen","pink","lightyellow"))
m = glmer.mp(Y ~ X1*X2 + (1|PId), data=df2)
Anova.mp(m, type=3)
glmer.mp.con(m, pairwise ~ X1*X2, adjust="holm")
Metadata

Version

0.3.3

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • 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