Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Templier/127138f8dd69cfbe7e956d1cfaa2c40b to your computer and use it in GitHub Desktop.

Select an option

Save Templier/127138f8dd69cfbe7e956d1cfaa2c40b to your computer and use it in GitHub Desktop.
What is the error in SS when rounding takes place prior to the calculation? A simulation to address a comment here: http://stats.stackexchange.com/questions/65220/exception-for-sum-of-deviations-from-mean-being-0/65232#comment127480_65232
sim <- function(places=3,N=20,FUN=round,...) {
SSr <- function(x) {sum((FUN(x,places)-mean(FUN(x,places)))^2)}
SS <- function(x) {sum((x-mean(x))^2)}
y <- rnorm(N,...)
return(abs(SSr(y)-SS(y)))
}
mean(replicate(20000,sim()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment