1

I'm using R along with library moments to generate a small dataset and compute the four initial moments of my data:

  1. Mean
  2. Variation
  3. Skewness
  4. Kurstosis

The code is shown below. I set a random seed for my PRNG and generates 1000 data points using a normal distribution.
Then, I print four moments two ways. First, I print then individually. Then, I print them using the method all.moments.

library(moments)

set.seed(123)
x = rnorm(1000, sd = 0.02)

print(mean(x));
print(var(x));
print(skewness(x))
print(kurtosis(x))

print(moments::all.moments(x, order.max = 4))

The outputs are shown below.

print(mean(x));
0.0003225573

print(var(x));
0.0003933836

print(skewness(x));  
0.06529391

print(kurtosis(x));  
2.925747

print(moments::all.moments(x, order.max = 4));  
1.000000e+00 3.225573e-04 3.930942e-04 8.889998e-07 4.527577e-07

One may note that both the skewness and the kurtosis of both methods are different.

My question is: Why they give different results? Which result is the right one?

r2evans
  • 141,215
  • 6
  • 77
  • 149
Iago Carvalho
  • 410
  • 1
  • 5
  • 15

1 Answers1

1

Note that the third and fourth moments are NOT the skewness and kurtosis. These should be calculated afterwards

Jago
  • 11
  • 3