R/estimateNoise.R

Defines functions estimateNoise

# Compute the usual unbiased estimate of the variance in a linear model.
estimateNoise <- function(x, y, intercept = TRUE) {
  n <- NROW(x)
  p <- NCOL(x)

  stopifnot(n > p)

  fit <- stats::lm.fit(x, y)
  sqrt(sum(fit$residuals^2) / (n - p + intercept))
}

Try the SLOPE package in your browser

Any scripts or data that you put into this service are public.

SLOPE documentation built on June 10, 2022, 1:05 a.m.