[R] Standard Deviation in R

Greg Snow 538280 at gmail.com
Wed Jun 11 21:05:10 CEST 2014

```The help page ?sd (I only checked version 3.1.0) has as the 1st
sentence in the details section: "Like ‘var’ this uses denominator n -
1." and on the help page ?var in the details section (though down in
the 3rd paragraph from the end) there is this sentence: "The
denominator n - 1 is used which gives an unbiased estimator of the
(co)variance for i.i.d. observations."

How can the R documentation state it more explicitly than that?

On Wed, Jun 11, 2014 at 4:04 AM, arun <smartpink111 at yahoo.com> wrote:
> Hi Bob,
> You may check:
> library(multicon)
> ?popsd()
>
> sd(1:3)
> #[1] 1
>  popsd(1:3)
> #[1] 0.8164966
>  sd(1:3)*sqrt(2/3)
> #[1] 0.8164966
> A.K.
>
>
>
> The formula I generally use to compute the standard deviation is the square root of the variance where the variance is E(X^2) - (E(x))^2. That is, the divisor is n , not n-1. I think it would have been better if the R documentation would have explicitly told me that it was using n-1 not n. By the way, is there another standard function in R, that will compute either the variance or the standard deviation by dividing by n instead of n-1?
>
> Thanks
>
> Bob
>
>
>
>
> On Sunday, June 8, 2014 10:33 PM, Greg Snow <538280 at gmail.com> wrote:
> Which formula for standard deviation are you using?
>
> If you know the population mean then you should divide by n (3 in this
> case), but if you don't know the population mean and use the mean
> calculated from the sample then it is more usual to use n-1 as the
> denominator (this makes the variance an unbiased estimator of the
> population variance).  That is what the R sd function does since it is
> much more common to use it on a sample rather than an entire
> population.
>
>
>
>
> On Sun, Jun 8, 2014 at 1:17 AM, arun <smartpink111 at yahoo.com> wrote:
>> Hi,
>> http://stats.stackexchange.com/questions/25956/what-formula-is-used-for-standard-deviation-in-r
>>
>> A.K.
>>
>>
>> It is my understanding that the R function SD finds the standard deviation of a random variable or a list. Please consider the following list: { 1, 2, 3 }. I claim that the standard deviation of this list is not 1. However, the following R statement returns 1:
>>          sd ( seq(1:3) )
>> What am I missing?
>>
>> I thank the group in advance for their responses.
>>
>> Bob
>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Gregory (Greg) L. Snow Ph.D.
> 538280 at gmail.com

--
Gregory (Greg) L. Snow Ph.D.
538280 at gmail.com

```