Confidence interval methods available for pairwiseCI for comparison of two independent samples. Methods for count data.
Poisson.ratio(x, y, conf.level=0.95, alternative="two.sided")
Quasipoisson.ratio(x, y, conf.level=0.95, alternative="two.sided")
Negbin.ratio(x, y, conf.level=0.95, alternative="two.sided")
vector of observations in the first sample
vector of observations in the second sample
character string, either "two.sided", "less" or "greater"
the comparisonwise confidence level of the intervals, where 0.95 is default
A list containing:
a vector containing the lower and upper confidence limit
a single named value
Poisson.ratio calculates a confidence interval for the ratio of means assuming the Poisson distribution of the response by fitting a generalized linear model with log-link using glm in package stats, constructing a likelihood profile and deriving a equal-tailed confidence interval from this profile. Please not that confidence intervals from this method produce severely misleading results, when there is extra-Poisson variation in the data.
Quasipoisson.ratio calculates a confidence interval for the ratio of means of the response by fitting a generalized linear model with family quasipoisson and log-link using glm in package stats, constructing a deviance profile and deriving a equal-tailed confidence interval from this profile.
Negbin.ratio calculates a confidence interval for the ratio of means assuming the negative binomial distribution of the response by fitting a generalized linear model with log-link using glm.nb in package MASS, constructing a likelihood profile and deriving a equal-tailed confidence interval from this profile.
Note, that for all the methods, a separate glm is fitted for each two-sample comparison! When a common model can be reasonbly assumed for all the data, there are smarter methods of constructing confidence intervals for groupwise comparisons, based on a common model, see e.g. the function confint in package stats, the function confint.glm in package MASS and the function confint.glht in package multcomp.
Note, that the code used here is slightly changed from the original code by Venables and Ripley, or Bates and Watts. An limit is imposed on the parameter space in which the profile is constructed. By that limitation, intervals can also be constructed for extreme cases with all observations in one group being zero.
Note, that the Poisson.ratio can be used when only one count is present in each group. For Quasipoisson.ratio, Negbin.ratio, repeated observations are necessary in each group.
Venables WN and Ripley BD (2002). Modern Applied Statistics using S, Fourth Edition. Springer New York. Bates, D.M. and Watts, D.G.(1988). Nonlinear Regression Analysis and Its Applications. John Wiley and Sons, New York.
# NOT RUN {
df <- data.frame(count = rpois(n=20, lambda=5), treat=rep(LETTERS[1:4], each=5))
QPCI<-pairwiseCI(count ~ treat, data=df,
alternative="two.sided", control="A", method="Quasipoisson.ratio")
QPCI
# }
Run the code above in your browser using DataLab