# Why does weights argument in glm change the outcome of lsd?

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?

• A larger sample size impacts significance. Otherwise we would do studies with $n=1$ and save money. Commented Nov 30, 2023 at 19:43
• So it takes the sample size within each replicate into account to calculate significant rather than how many replicates? What does the default NULL  use? Commented Nov 30, 2023 at 19:49
• Basically. You can test by replicating each row of the data m times (via df[rep(1:nrow(df), each = m), ]) and fit a "simple" logistic regression. This should give you the same inference as the aggregated approach. Commented Nov 30, 2023 at 19:57
• I guess my question is: If the difference is because of low sub sample size, what does the model do when I don’t pass the optional argument weights ? Is it wrong if I don’t? Commented Nov 30, 2023 at 20:09
• I think @MichaelM has already clarified this but - the two GLMs are different. From ?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. Commented Nov 30, 2023 at 21:57