Open In App

How to Calculate Pooled Standard Deviation in R

Last Updated : 26 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will learn How to Calculate Pooled Standard Deviation in R.

Pooled Standard Deviation

This is a weighted average of standard deviations of two or more groups which are independent.

In statistics, it is used to test whether or not the means of two populations are equal.

Mathematically, it is defined as

Pooled standard deviation =

\sqrt{(n_1-1)s_1^2 +  (n_2-1)s_2^2 /  (n_1+n_2-2)}

where:

  • n1, n2: Sample size for both groups
  • s1, s2: Standard deviation for both groups

Method 1: Calculate Pooled Standard Deviation Manually

Step 1: Creating Dataset

data1 <- c(21, 19, 19, 8, 8, 10, 11, 13, 15, 15, 16, 17, 7, 6, 6)
data2 <- c(10, 11, 13, 13, 15, 17, 17, 19, 20, 22, 24, 25, 27, 29, 29)

Step 2: Finding standard deviation

s1 <- sd(data1)
s2 <- sd(data2)

Step 3: Finding sample size

n1 <- length(data1)
n2 <- length(data2)

Step 4: Calculate pooled standard deviation

pooled <- sqrt(((n1-1)*s1^2 + (n2-1)*s2^2) / (n1+n1-2))

Code

R
#Step 1: Creating Dataset
data1 <- c(21, 19, 19, 8, 8, 10, 11, 13, 15, 15, 16, 17, 7, 6, 6)
data2 <- c(10, 11, 13, 13, 15, 17, 17, 19, 20, 22, 24, 25, 27, 29, 29)

#Step 2: Finding standard deviation 
s1 <- sd(data1)
s2 <- sd(data2)

#Step 3: Finding sample size 
n1 <- length(data1)
n2 <- length(data2)

#Step 4: Calculate pooled standard deviation
pooled <- sqrt(((n1-1)*s1^2 + (n2-1)*s2^2) / (n1+n1-2))


Output

5.789564


Method 2: Using effectsize library

Step 1: Installing Package

install.packages("effectsize")
library(effectsize)

Step 2: Creating Dataset

data1 <- c(21, 19, 19, 8, 8, 10, 11, 13, 15, 15, 16, 17, 7, 6, 6)
data2 <- c(10, 11, 13, 13, 15, 17, 17, 19, 20, 22, 24, 25, 27, 29, 29)

Step 3: Calculate pooled standard deviation

sd_pooled(data1, data2)

Code

R
#Step 1: Installing Package
install.packages("effectsize")
library(effectsize)

#Step 2: Creating Dataset
data1 <- c(21, 19, 19, 8, 8, 10, 11, 13, 15, 15, 16, 17, 7, 6, 6)
data2 <- c(10, 11, 13, 13, 15, 17, 17, 19, 20, 22, 24, 25, 27, 29, 29)

#Step 3: Calculate pooled standard deviation 
sd_pooled(data1, data2)


Output

5.789564

Conclusion

In this article, we learnt about How to Calculate Pooled Standard Deviation in R. This is a weighted average of standard deviations of two or more groups which are independent. In statistics, it is used to test whether or not the means of two populations are equal.




Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads