Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Compute Raw and Central Moments Using R

Improve Article
Save Article
Like Article
  • Difficulty Level : Medium
  • Last Updated : 09 Oct, 2022
Improve Article
Save Article
Like Article

In this article, we are going to compute raw and central moments using R Programming Language. The moments of data used to describe the nature of the dataset are Variation, Skewness, and Kurtosis.

  • Raw Moments – The moments about zero distribution are known as Raw moments.
  • Central Moments – The moments about the mean of distribution are known as Central Moments.

Using R we can easily find the raw moments with the predefined package “moments”

In a moment’s package, we have all.moments() function which is used to calculate raw moments and central moments.

Syntax: all.moments(x,order.max,central=FALSE)


  • x: a numeric vector of data
  • order.max: the maximum order of the moments to be computed (default value is 2).
  • Central: a logical value (FALSE for raw moments or TRUE for central moments)

Below is the implementation:


# install required packages
# load installed package
# create a vector which represent marks 
# of student marks
# Raw Moments
print('Raw Moments')
# Central Moments
print('Central Moments')




If we observe the above R code to calculate central moments we need to make sure the third attribute of all.moments() function should be set to True because by default it’s False.

Raw Moments:-

                         μ′0 = 1.0 

                         μ′1 = 92.0 

                         μ′2 = 8487.8

Central Moments:-

                        μ1 = 1.0

                        μ2 = 0.0

                        μ3 = 23.8

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!