Skip to content

Commit

Permalink
Fixed estimate of residual variance in mean model
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Oct 10, 2023
1 parent 77a561b commit a331f90
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/mean.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ train_mean <- function(.data, specials, ...) {
fits <- dplyr::lag(fits)
}
res <- y - fits
sigma <- sd(res, na.rm = TRUE)
sigma <- sqrt(mean(res^2, na.rm = TRUE))

structure(
list(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-mean.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("MEAN", {
)

expect_equivalent(
glance(fit)$sigma2, var(scale(USAccDeaths_tbl$value, scale = FALSE))
glance(fit)$sigma2, mean(scale(USAccDeaths_tbl$value, scale = FALSE)^2)
)

expect_identical(
Expand Down

0 comments on commit a331f90

Please sign in to comment.