This heathmap displays the values of a skew-symmetric matrix by colors. The order of the rows and columns is given by the row sums of the matrix. The order is calculated from the signs obtained from the skew-symmetric matrix; it is the number of positive elements in a row of the matrix. If the matrix has no circular triads all values in the uppertriangle are positive and all values in the lower triangle are negative. The option dominance gives the signs of the skew-symmetric matrix, otherwise the values are shown.

The data are migration data of students participating in the Erasmus program. The Erasmus program is a student exchange program from the European Union. Three million students had taken part since the start of the program in 1987. To join this program a student has study at least three months or do an internship of at least two months in another country. The table lists the home and destination country of 268.142 students in the academic year 2012- 2013. The 33 rows of this table refer to the home country whereas the 33 columns refer to the destination countries. The entries in the table are read as follows: 32 students from Bulgaria studied in The Netherlands, 18 students from the Netherlands studied in Bulgaria. Macedonia (MK) was excluded from the published table because only one student from Macedonia studied abroad and this country did not receive any students.

The decomposition of an asymmetric matrix into a symmetric matrix and a skew-symmetric matrix is an elementary result from mathematics that is the cornerstone of this package. The decomposition into a skew-symmetric and a symmetric component is written as: \[ Q = S + A, \] where \(S\) is a symmetric matrix with averages \((q_{ij}+q_{ji})/2\), and \(A\) is a skew-symmetric matrix with elements \((q_{ij}-q_{ji})/2\). The skew-symmetry property is \(a_{ij}=-a_{ji}\), that is, if we interchange the subscripts the sign changes.

```
library(xtable)
library(asymmetry)
data(studentmigration)
idx <- c(18,22,27,2,13,31) #select 6 countries
print(xtable(studentmigration[idx,idx]), type = "html")
```

NL | RO | UK | BG | LV | TR | |
---|---|---|---|---|---|---|

NL | 0 | 20 | 1621 | 18 | 28 | 479 |

RO | 106 | 0 | 127 | 16 | 14 | 164 |

UK | 637 | 25 | 0 | 34 | 14 | 95 |

BG | 32 | 22 | 133 | 0 | 21 | 119 |

LV | 79 | 11 | 60 | 51 | 0 | 58 |

TR | 558 | 383 | 617 | 64 | 179 | 0 |

The skew symmetric part \(A\) of the data is generated by the following script

```
library(xtable)
library(asymmetry)
data(studentmigration)
print(xtable(.5*(studentmigration[idx,idx] - t(studentmigration[idx,idx]))), type = "html")
```

NL | RO | UK | BG | LV | TR | |
---|---|---|---|---|---|---|

NL | 0.00 | -43.00 | 492.00 | -7.00 | -25.50 | -39.50 |

RO | 43.00 | 0.00 | 51.00 | -3.00 | 1.50 | -109.50 |

UK | -492.00 | -51.00 | 0.00 | -49.50 | -23.00 | -261.00 |

BG | 7.00 | 3.00 | 49.50 | 0.00 | -15.00 | 27.50 |

LV | 25.50 | -1.50 | 23.00 | 15.00 | 0.00 | -60.50 |

TR | 39.50 | 109.50 | 261.00 | -27.50 | 60.50 | 0.00 |

A heat map of this skew-symmetric table is generated by the following script

```
library(asymmetry)
library(RColorBrewer)
# creates a color palette from red to blue
my_palette <- colorRampPalette(c("red", "white", "blue"))(n = 299)
col_breaks = c(seq(-4000,-.001,length=100), # negative values are red
seq(-.001,0.01,length=100), # zeroes are white
seq(0.01,4000,length=100)) # positive values are blue
data(studentmigration)
hmap(studentmigration[idx,idx], dominance = FALSE, col = my_palette, key = FALSE, xlab = "Destination country", ylab = "Home country", colsep = c(1:6), rowsep = c(1:6))
```

Blue values correspond to positive values, whereas red values correspond to negative values. The intensity of the colors show the magnitude. Because the values in the column UK are blue, which point to positive net migration, the UK attracts more students from abroad than any other country. Most of the students moving to the UK are students from the Netherlands and Turkey. The colors corresponding to these countries in the column labeled UK are dark blue. ## Erasmus Student Migration

```
library(asymmetry)
library(RColorBrewer)
# creates a color palette from red to blue
my_palette <- colorRampPalette(c("red", "white", "blue"))(n = 299)
col_breaks = c(seq(-4000,-.001,length=100), # for red
seq(-.001,0.01,length=100), # for white
seq(0.01,4000,length=100)) # for blue
data(studentmigration)
hmap(studentmigration, dominance = FALSE, col = my_palette, key = FALSE, xlab = "Destination country", ylab = "Home country", colsep = c(1:32), rowsep = c(1:32))
```