New Version of R Package agrmt

This week, a new version of the R package agrmt saw the light of day. I have been contacted because one of the functions in the package didn’t produce the right answers. I really appreciate this (the contacting), because it allowed me to fix the code. It was a matter of mixing up i and j. The first reaction in this case is always the worst: what if I got it all wrong? What if I can’t find the bug? To me, fixing code in my packages is important — not because of the undeniable satisfaction from getting it right — but because it is a small way to give back to the (virtual) community that gave us R and the many packages that come along with it.

The package, by the way, implements measures of agreement (consensus) in ordered rating scales, especially Cees van der Eijk’s (2001) measure of agreement A, but also measures of consensus (dispersion) by Leik, Tatsle and Wierman, Blair and Lacy, Kvalseth, and Berry and Mielke. Moreover, it implements Galtung’s AJUS for R.

Galtung’s ISD System

A while ago, I introduced Galtung’s (1967) AJUS system to classify distributions according to shape. The AJUS system can be used to reduce complexity.

Galtung also introduced the ISD system to describe changes over time in a similar manner. It can be applied to any situation where we have three points in time to characterize two periods during which changes may have happened. As with the AJUS system, the intuition is to ignore small and unimportant differences to focus on the bigger changes. While Galtung developed the ISD system for eye-balling, it remains relevant in the age of computers; the system just becomes more systematic.

The ISD system is available in my R package agrmt. Taking a vector representing the values at the three points in time, the isd() function gives the type and a description of the type as follows:

    Type 1: increase in both periods
    Type 2: increase in first period, flat in second period
    Type 3: increase in first period, decrease in second period
    Type 4: flat in first period, increase in second period
    Type 5: flat in both periods
    Type 6: flat in first period, decrease in second period
    Type 7: decrease in first period, increase in second period
    Type 8: decrease in first period, flat in second period
    Type 9: decrease in both periods

Reference: Galtung, J. 1969. Theory and Methods of Social Research. Oslo: Universitetsforlaget.

Sensitivity of AJUS to tolerance parameter

Last week I introduced Galtung’s AJUS system and its implementation in R. As noted, the tolerance parameter is not a trivial matter, but we can use the provided function ajusCheck to explore how different tolerance parameters affect the outcome. Basically we throw a number of tolerance parameters at the ajus function, and see what happens.

In this example, the default values give type “S” (i.e. multi-peaked). Next, we visually inspect the distribution using ajusPlot:


So maybe the last increase is not significant, so we can try a different tolerance value (e.g. 0.2). We can continue this, or just try them all (e.g. between 0.1 and 2):

library(agrmt) # install from R-Forge
# Data:
V <- c(0,0,1,2,1.5,1.6)
ajus(V) # using default tolerance = 0.1
ajusPlot(V) # visual inspection
ajus(V, tolerance=0.2) # exploring
ajusCheck(V, t=seq(0.1,2,0.1)) # let's try them all

[1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
[20] 2.0

[1] “S” “A” “A” “A” “J” “J” “J” “J” “J” “J” “J” “J” “J” “J” “J” “F” “F” “F” “F”
[20] “F”

Which is it? Usually the substantive meaning of our numbers is the guide but sometimes we deal with constructs that are more difficult to assess. Using ajusCheck we can easily check whether we should spend hours thinking about whether 0.2 or 0.3 is more appropriate – or whether we get the same result.

Galtung’s AJUS System

Galtung (1967) introduced the AJUS system as a way to classify distributions according to shape. This is a means to reduce complexity. The underlying idea is to classify distributions by ignoring small differences that are not important. The system was originally developed for eye-balling, but having it done by a computer makes the classification more systematic.

All distributions are classified as being one of AJUS, and I have added a new type “F” to complement the ones identified by Galtung.

  • A: unimodal distribution, peak in the middle
  • J: unimodal, peak at either end
  • U: bimodal, peak at both ends
  • S: bimodal or multi-modal, multiple peaks
  • F: flat, no peak; this type is new

The skew is given as -1 for a negative skew, 0 for absence of skew, or +1 for a positive skew. The skew is important for J-type distributions: it distinguishes monotonous increase from monotonous decrease.

I have implemented the AJUS system in my R package agrmt. By setting the tolerance, we can determine what size of differences we consider small enough to be ignored. The default tolerance is 0.1, equivalent to 10% if using 0 to 1. AJUS implemented in R sets a systematic threshold, something we do not do when eye-balling differences.

The tolerance parameter is not a trivial choice, but a test is included in the R package to directly test sensitivity to the tolerance parameter (ajusCheck).

Here are some examples (using the experimental ajusPlot function and tolerance = 10):
Differences smaller than the tolerance set (10) are ignored.

Reference: Galtung, J. 1969. Theory and Methods of Social Research. Oslo: Universitetsforlaget.