Skip to content

Instantly share code, notes, and snippets.

@lucidfrontier45
Created January 6, 2020 10:58
Show Gist options
  • Select an option

  • Save lucidfrontier45/45ba3a3c9359118c5380fd1445bb8572 to your computer and use it in GitHub Desktop.

Select an option

Save lucidfrontier45/45ba3a3c9359118c5380fd1445bb8572 to your computer and use it in GitHub Desktop.
Testing Dunnett's test
library(reshape2)
library(multcomp)
n <- 10
ctrl <- rnorm(n, 0, 0.5)
a <- rnorm(n, 0.1, 0.5)
b <- rnorm(n, 2, 0.5)
df <- melt(data.frame(ctrl = ctrl, a = a, b=b))
names(df) <- c("cat", "val")
df$cat <- factor(df$cat, levels=c("ctrl", "a", "b"), ordered=TRUE)
res.aov <- aov(val~cat, data=df)
res.glht <- glht(res.aov, linfct=mcp(cat="Dunnett"))
summary(res.glht)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment