On Sun, 27 Oct 2013, Imran Akbar wrote:
Hi,
I've got a data set with a control group and a number of experimental
groups, that have unequal sample sizes, and am measuring the number of
people in each that respond yes or no. I'd like to use a dunnett test in
R, where the syntax is supposed to be like:
library(multcomp)
test.dunnett=glht(anova_results,linfct=mcp(method="Dunnett"))
confint(test.dunnett)
plot(test.dunnett)
but:
1) How do I run a dunnett test without doing the ANOVA (which wouldn't
have its requirements satisfied, as the measurements are not independent
due to the control group)?
But the control group is a separate independent group from the three
treatments A-C, isn't it? Then independence should not be a problem.
For the binary response you need something different than an ANOVA, e.g.,
an analysis of deviance in a logistic regression.
2) Do I have to tell the test what my sample sizes are, or will it
calculate the sums itself?
If you supply a suitable fitted model, then glht() can infer the group
sizes from that:
## data and table
dat <- data.frame(
freq = c(23, 19, 27, 53, 623, 523, 823, 469),
resp = factor(rep(c("Yes", "No"), each = 4)),
method = factor(rep(1:4, 2), labels = c("Control", "A", "B", "C"))
)
tab <- xtabs(freq ~ method + resp, data = dat)
## visualization and Pearson chi-squared test
spineplot(tab[, 2:1])
mosaicplot(tab, shade = TRUE, off = c(5, 0.5))
chisq.test(tab)
## Logistic regression and analysis of deviance chi-squared test
m <- glm(resp ~ method, weights = freq, data = dat, family = binomial)
anova(m, test = "Chisq")
## Odds ratios
exp(coef(m)[-1])
## Dunnett test
library("multcomp")
m_glht <- glht(m, linfct = mcp(method = "Dunnett"))
summary(m_glht)
confint(m_glht)
plot(m_glht)
Here's my matrix:
Control A B C
Yes 23 19 27 53
No 623 523 823 469
thanks,
imran
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.