Var, sd, cor, which have n as the denominator

var, sd, corFunctions {stats}are used n-1as the denominator (wherein nthe number of observations). Out of curiosity, is there an equivalent function that uses nas a denominator?

+4
source share
1 answer

Try the following:

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")    
+3
source

Source: https://habr.com/ru/post/1523737/


All Articles