Exercise

# Numerical tests of normality

The moments package contains functions for computing the **kurtosis** and **skewness** of data and well as for implementing the **Jarque-Bera test**, which is a test of normality based on these higher-order moments. In one command, it compares the skewness and kurtosis of the data with the theoretical values for the normal distribution, which are 0 and 3, respectively.

```
jarque.test(x)
skewness(x, na.rm = FALSE)
kurtosis(x, na.rm = FALSE)
```

In this exercise, you will calculate the skewness and kurtosis for the `djx`

, the Dow Jones index from 2008-2011, and apply the Jarque-Bera test of normality. You will then apply the same methods to `djreturns`

, which contains 29 of the Dow Jones stocks for the same period.

Recall that you can use `apply(X, MARGIN, FUN, …)`

to apply functions over array margins. The `MARGIN`

parameter is a vector indicating where the function will be applied; in this instance, you will use `2`

to specify that the function `FUN`

should be applied to the *columns* in matrix `X`

.

The `moments`

package has been imported for you, and the `djx`

and `djreturns`

data is in your workspace.

Instructions

**100 XP**

- Calculate the skewness and kurtosis of the Dow Jones index returns in
`djx`

using`skewness()`

and`kurtosis()`

, respectively. - Carry out a Jarque-Bera test of normality for
`djx`

using`jarque.test()`

. - Use
`apply()`

to calculate the skewness and kurtosis of the individual equity returns in`djreturns`

assigning the results to`s`

and`k`

, respectively. - Fill in
`plot()`

to plot`k`

against`s`

with parameter`type = "n"`

, and then place the stock symbols at the points with the command`text()`

(this has been done for you). - Use
`apply()`

to carry out the Jarque-Bera test for each of the Dow Jones constituents in`djreturns`

.