r-devel / r-dev-day

Repo to organize tasks for R Dev Days
7 stars 2 forks source link

Bug 18282: Description of var.test for lm objects could be improved. #45

Open shannonpileggi opened 3 months ago

shannonpileggi commented 3 months ago

Bug 18282: Description of var.test for lm objects could be improved.

Initial submission below, see bugzilla for further documentation.

The Description of var.test reads (emphasis via * is mine):

The null hypothesis is that the ratio of the variances of the populations from which x and y were drawn, or in the data to which the linear models x and y were fitted, is equal to ratio.

The relevant part of the source code of var.test.default is:

if (inherits(x, "lm") && inherits(y, "lm")) {
DF.x <- x$df.residual
DF.y <- y$df.residual
V.x <- sum(x$residuals^2)/DF.x
V.y <- sum(y$residuals^2)/DF.y
}
ESTIMATE <- V.x/V.y
STATISTIC <- ESTIMATE/ratio
PARAMETER <- c(num df = DF.x, denom df = DF.y)
PVAL <- pf(STATISTIC, DF.x, DF.y)

(the default being ratio = 1)

I would suggest changing the emphasized part of the description to "or of the residual error terms of the data to which the linear models x and y were fitted".

I suggest this change because I believe it to be more comprehensive than "the variances in the data to which the linear models x and y were fitted".