var, sd, cor functions that have n as denominator

1.6k views Asked by At

var, sd, cor functions in {stats} use n-1 as a denominator (where n the number of observations). Out of curiosity, are there equivalent function that use n as a denominator?

1

There are 1 answers

0
G. Grothendieck On BEST ANSWER

Try this:

library(RH2) # needs Java
library(sqldf)

n <- length(BOD$demand)

sd(BOD$demand)
sqrt((n-1)/n) * sd(BOD$demand)
sqldf("select stddev_samp(demand) as samp, stddev_pop(demand) as pop from BOD")

var(BOD$demand)
(n-1)/n * var(BOD$demand)
sqldf("select var_samp(demand) as samp, var_pop(demand) as pop from BOD")