I have dataframe df
.
df <- structure(list(t = c("T1", "T1", "T1", "T1", "T1", "T1", "T1",
"T1", "T1", "T1", "T2", "T2", "T2", "T2", "T2", "T2", "T2", "T2",
"T2", "T2", "T3", "T3", "T3", "T3", "T3", "T3", "T3", "T3", "T3",
"T3", "T4", "T4", "T4", "T4", "T4", "T4", "T4", "T4", "T4", "T4"
), n = c(10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L), m = c(4L, 5L, 4L, 5L, 6L, 4L, 5L, 3L, 5L, 4L,
2L, 1L, 2L, 3L, 4L, 2L, 1L, 2L, 3L, 1L, 9L, 9L, 9L, 10L, 8L,
7L, 8L, 9L, 10L, 8L, 5L, 6L, 5L, 6L, 5L, 6L, 4L, 5L, 6L, 5L)), class = "data.frame", row.names = c(NA,
-40L))
t
is the treatment group; the independent variable.
n
is the sample size of each subsample.
m
is the response; the number of successes out of the possible n
; the dependent variable.
m
/n
is bounded between 0 and 1, therefore I use binomial
glm.
mdf <- aov(glm(m/n~t, weights=n, data=df, family=binomial)) #with weights
mdf2 <- aov(glm(m/n~t, data=df, family=binomial)) #without weights
Then I use agricolae::LSD.test
to run Fisher's LSD to test for significant differences in mean m/n
among t
.
However, I get different results with and without using the weights
argument, even though all subsamples have 10 individuals
ldf <- LSD.test(mdf, 't')
ldf2 <- LSD.test(mdf2, 't')
output:
> ldf$groups
m/n groups
T3 0.87 a
T4 0.53 b
T1 0.45 bc
T2 0.21 c
> ldf2$groups
m/n groups
T3 0.87 a
T4 0.53 b
T1 0.45 c
T2 0.21 d
In some cases, the differences are even more extreme. Which, is very unexpected to me. Any idea what is happening?
NULL
use? $\endgroup$df[rep(1:nrow(df), each = m), ]
) and fit a "simple" logistic regression. This should give you the same inference as the aggregated approach. $\endgroup$weights
? Is it wrong if I don’t? $\endgroup$?glm
, "For a binomial GLM prior weights are used to give the number of trials when the response is the proportion of successes". So basically,mdf
is correct,mdf2
is not. $\endgroup$