SHAZAM Descriptive Statistics

## Mean, Variance, Median, Quartiles

The `STAT` command computes descriptive statistics on variables.

#### Example

A data set is available with inflation rates for five industrial countries. Which country's inflation rate is the most volatile ? Higher volatility is associated with higher variance. The SHAZAM commands (filename: `IRATE.SHA`) below can be used to answer the question.

```SAMPLE 1 21
READ (IRATE.txt) YEAR USA UK JAPAN GERMANY FRANCE
STAT USA UK JAPAN GERMANY FRANCE / PMEDIAN
STOP
```

The `STAT` command computes the mean, variance, standard deviation, minimum and maximum for each variable in the variable list. The `PMEDIAN` option requests for calculation of the median, mode, quartiles and interquartile range for each variable.

The SHAZAM output can be viewed. The results show that the inflation rate of the United Kingdom is the most variable with a standard deviation of 6.3. The least variable rate is Germany's inflation rate with a standard deviation of 1.7. (Note that the numerical results have been rounded to 1 decimal place. The SHAZAM output typically reports more digits than are needed for report presentation.)

An equivalent way of preparing the above command file is to assign variable names `C1, C2, C3, C4` and `C5` for the inflation rates in the 5 countries. This notation saves typing effort. SHAZAM commands that do the same work as above are:

```SAMPLE 1 21
STAT C1-C5 / PMEDIAN
STOP
```

##### Changing the Sample Period

The world economy was affected by the Middle East War of October 1973 that was followed by an Arab oil embargo with a subsequent quadrupling in international oil prices. The SHAZAM commands that follow investigate differences in inflation rates for the pre-embargo and post-embargo period. Descriptive statistics are obtained for the two sample periods 1960 to 1973 and 1974 to 1980.

```SAMPLE 1 21
READ (IRATE.txt) YEAR USA UK JAPAN GERMANY FRANCE
* Sample period 1960 to 1973
SAMPLE 1 14
STAT USA UK JAPAN GERMANY FRANCE
* Sample period 1974 to 1980
SAMPLE 15 21
STAT USA UK JAPAN GERMANY FRANCE
STOP
```

The above commands demonstrate that the `SAMPLE` command is an important and useful command. The `SAMPLE` command is typically the first command in a SHAZAM program. The sample period can be changed by specifying a new `SAMPLE` command.

The SHAZAM output can be viewed.

[SHAZAM Guide home]

#### SHAZAM output

``` |_SAMPLE 1 21
|_READ (IRATE.txt) YEAR USA UK JAPAN GERMANY FRANCE

UNIT 88 IS NOW ASSIGNED TO: IRATE.txt
6 VARIABLES AND       21 OBSERVATIONS STARTING AT OBS       1

|_STAT USA UK JAPAN GERMANY FRANCE / PMEDIAN
NAME        N   MEAN        ST. DEV      VARIANCE     MINIMUM      MAXIMUM
USA         21   5.1238       3.6950       13.653       1.1000       13.600
UK          21   8.5476       6.3210       39.956       1.0000       24.200
JAPAN       21   7.3476       4.6330       21.465       3.6000       24.600
GERMANY     21   3.8667       1.6764       2.8103       1.5000       7.0000
FRANCE      21   6.7143       3.5791       12.810       2.6000       14.000

VARIABLE = USA
MEDIAN =    4.3000
LOWER 25%=   1.5500     UPPER 25%=   7.0000     INTERQUARTILE RANGE=  5.450
MODE =    2.8000     WITH        2 OBSERVATIONS
WARNING: MULTIPLE MODES - THE MAXIMUM IS REPORTED

VARIABLE = UK
MEDIAN =    6.5000
LOWER 25%=   3.8000     UPPER 25%=   14.650     INTERQUARTILE RANGE=  10.85
MODE NOT APPLICABLE

VARIABLE = JAPAN
MEDIAN =    6.3000
LOWER 25%=   4.4500     UPPER 25%=   8.0500     INTERQUARTILE RANGE=  3.600
MODE =    3.6000     WITH        2 OBSERVATIONS

VARIABLE = GERMANY
MEDIAN =    3.7000
LOWER 25%=   2.3000     UPPER 25%=   5.3500     INTERQUARTILE RANGE=  3.050
MODE =    7.0000     WITH        2 OBSERVATIONS
WARNING: MULTIPLE MODES - THE MAXIMUM IS REPORTED

VARIABLE = FRANCE
MEDIAN =    5.5000
LOWER 25%=   3.4000     UPPER 25%=   9.5000     INTERQUARTILE RANGE=  6.100
MODE =    5.5000     WITH        2 OBSERVATIONS
WARNING: MULTIPLE MODES - THE MAXIMUM IS REPORTED
|_STOP
```

#### SHAZAM output

``` |_SAMPLE 1 21
|_READ (IRATE.txt) YEAR USA UK JAPAN GERMANY FRANCE

UNIT 88 IS NOW ASSIGNED TO: IRATE.txt
6 VARIABLES AND       21 OBSERVATIONS STARTING AT OBS       1

|_* Sample period 1960 to 1973
|_SAMPLE 1 14
|_STAT USA UK JAPAN GERMANY FRANCE
NAME        N   MEAN        ST. DEV      VARIANCE     MINIMUM      MAXIMUM
USA         14   3.0500       1.8275       3.3396       1.1000       6.2000
UK          14   4.8000       2.3485       5.5154       1.0000       9.5000
JAPAN       14   6.0857       2.1300       4.5367       3.6000       12.000
GERMANY     14   3.4143       1.6379       2.6829       1.5000       7.0000
FRANCE      14   4.5143       1.5195       2.3090       2.6000       7.5000

|_* Sample period 1974 to 1980
|_SAMPLE 15 21
|_STAT USA UK JAPAN GERMANY FRANCE
NAME        N   MEAN        ST. DEV      VARIANCE     MINIMUM      MAXIMUM
USA          7   9.2714       2.8582       8.1690       5.8000       13.600
UK           7   16.043       4.7878       22.923       8.3000       24.200
JAPAN        7   9.8714       7.1114       50.572       3.6000       24.600
GERMANY      7   4.7714       1.4568       2.1224       2.7000       7.0000
FRANCE       7   11.114       1.9540       3.8181       9.1000       14.000
|_STOP
```