---
title: "Example: European Iron Age"
output: rmarkdown::html_vignette
bibliography: ../inst/REFERENCES.bib
vignette: >
  %\VignetteIndexEntry{Example: European Iron Age}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

## Münsingen

### Archaeological background

The cemetery of Münsingen-Rain was discovered in 1904 during quarrying and then extensively excavated in 1906. The dead were buried singly and supine in wodden coffins, often lavishly equipped with jewelry or weapons. The documentation and subsequent publication of the graves in 1908 [@wiedmer-stern_graeberfeld_1908] was outstanding for that time. This and the fact that Münsingen-Rain with 220--230 individuals and its occupation of roughly 300 years covers much of the Latène period secured it one of the most important places in typological and chronological studies of that period [@hodson_cemetery_1968; see also @mueller_muensingen_1998].  

Recently, in a number of studies, the anthropological and archaeological material has been reanalysed from different angles [@jud_untersuchungen_1998; @alt_et_al_verwandtschaft_2005; @mueller_et_al_artefacts_2008; @scheeres_et_al_investigations_in_press; @moghaddam_et_al_muensingen_2016]. Though some papers explicitly dealt with the age and sex structure of the cemetery [e.g., @hinton_analysis_1986; @jud_untersuchungen_1998, 125ff.], interestingly, none has yet presented a thorough demographic analysis of the individuals from Münsingen-Rain.  

### The data set

The data originates from a published report of recent scientific analyses of the surviving skeletal material [@moghaddam_et_al_muensingen_2016] of 71 individuals. The data is available as supplemental online material and was directly taken from the respective xlsx-file. Beside the age-range of each individuals the sex, the archaeological phase and the binary information if grave goods, if existing, are included. Further columns that are not of interest in the present context were omitted. The authors do not compare their results with those of an older investigation of the same individuals. However, a comparison with Hug [-@hug_sammlung_1956] shows that generally there is a very good agreement in age as well as sex determination.  

### Constructing the life table

```{r, message=FALSE}
# load package dependencies
library(mortAAR)
library(magrittr)
```

```{r}
# load dataset muensingen
muen <- mortAAR::muensingen  
```
  
First of all, we have to get an overview of the age classes that were used. The easiest way would be `muen$age`. However, this results in roughly formatted row of strings. We used the following code to get an ordered and well-arranged list without duplicated age classes.  

```{r}
muen %>% dplyr::select(age) %>% dplyr::arrange(nchar(age), age) %>% unique()
```

As can be easily seen, the data set is comprised of 31 different age ranges. Skimming through the lines it is obvious that the anthropologists were not completely consequent in their age ranges. While „20--40“ clearly should be read as „from 20 to 39 years“ this is certainly not the case with for example „7--8“. The first one is in our terminology exclusive of the maximal age range, the second inclusive. Less clear are cases like „12--14“ or „13--15“. If we want to define 5-year-classes the differentiation does not really matter in the first case, as the individual would fall completely in the age range of 10 to 14. In the second case, the differentiation is unfortunately of importance. Taking it as inclusive, the individual would count with 1/4 to the age class of 15 to 19 while reading it as exclusive the individual would be associated with the younger age class.  

Unfortunately, we cannot solve this issue but for future reports we can only ask the authors to be more precise in their terminology. For the sake of the example, we assumed that age ranges only one year apart (e.g., „7-8“) are meant as inclusive and had to be adapted, but otherwise treated the age ranges as exclusive. For those individuals with an open end, we assume a maximal age of 70.  

In the next step, not only the aforementioned inconsistencies have to be corrected, but also non-numerical characters (e.g., ">") must be replaced to be able to feed the data into mortAAR.

```{r}
# correct inconsistencies
muen <- muen %>%
  dplyr::mutate(
    age = dplyr::case_when(
      .$age == ">50"    ~ "50-70",
      .$age == ">60"    ~ "60-70",
      .$age == "10+/-1" ~ "9-12",
      .$age == "10"     ~ "10-11",
      .$age == "7-8"    ~ "7-9",
      .$age == "9-10"   ~ "9-11",
      TRUE            ~  .$age
    )
  )
```

After adjusting the age class categories, the column "age" can be split into two separate columns "from" and "to", which mark the age span. These are then further transformed into numeric columns.  

```{r}
# split string column
muen <- muen %>% 
  tidyr::separate(age, c("from", "to")) %>%  
  transform(from = as.numeric(from), to = as.numeric(to))  
```

All the steps above were necessary to prepare the raw data. We are now ready to feed it into the function `prep.life.table` that rearranges it for the actual life table function.  
We want to have 5-year-age categories, except for the first 5 years which are further split into the first and the subsequent 4 years. Therefore, we choose "Standard" as a `method`. As explained above, we assume that the age ranges are meant to be exclusive of the closing year (e.g., "20--40" as "20--39"). We regulate this by choosing "excluded" for `agerange`. The beginning and ending of the age classes is framed by "from" (= `agebeg`) and "to" (= `ageend`) respectively. For the first run, we choose "sex" as the grouping variable `group` but we could also have selected "latene_phase" (the archaeological phasing) or "grave_goods" (existence or non-existence of grave goods).  

```{r}
# apply data preparation function 
muen_prep <- muen %>% 
    prep.life.table(
    group = "sex", 
    agebeg = "from", 
    ageend = "to", 
    method = "Standard", 
    agerange = "excluded" 
  )  
```

The resulting data frame `muen_prep` is then fed into the life table function `life.table`.  

```{r}
# calculate life.table
muen_result <- muen_prep %>% 
  life.table() 
```

```{r, echo=FALSE}
options(width = 999)
```

First, the tabular output is created.  

```{r}
muen_result 
```

The visual inspection can be of great help, especially when the comparison of two or more groups is involved.  

```{r}
muen_result %>% 
  plot(display = c("dx","qx", "lx", "ex", "rel_popx"))  
```

### Mortality patterns

The maximum within the proportion of deaths (dx) of all individuals from Münsingen-Rain is around 40 years. Largely missing are younger individuals below 20, but also the age of 50 and above is only slightly present. Especially the apparent lack of the subadult individuals generates questions concerning the representation of the data. Already a superficial look at any modern life tables leads to the expectation of far higher numbers of younger individuals. Therefore, the obvious conclusion seems that not everybody was buried within the cemetery.  

However, there are also differences between the adult individuals. The maximum in females was in their 40s, while male individuals apparently died somehow later in their 50s. There are virtually no female individuals older than 55, but many males above 60. Accordingly female individuals suffered a much higher probability of death (qx), had less survivorship (lx) within all age categories. The life expectancy differs as much as nearly 13 years (35.0 for females vs. 47.9 for males), but this is also due to the fact that it was obviously possible to sex six subadult females, but nearly no subadult males.  

As a result the analysis leaves more open questions than answers: Representation is obviously not given, as is demonstrated by the largely missing subadult individuals. However, even with adult individuals, the highly differing mortality pattern between males and females elicits the question if this was really due to the differing life expectancy or differing cultural preferences in burying males and females.

We invite the reader to regroup the data with the variables "latene_phase" and "grave_goods" and compare her results with the conclusions by P. Hinton [-@hinton_analysis_1986].
  


## Magdalenenberg

### Archaeological Background

One of the largest burial mounds in Central Europe is the so-called [‘Magdalenenberg‘](https://en.wikipedia.org/wiki/Magdalenenberg) near Villingen-Schwenningen in Baden-Württemberg. Within the Early Iron Age it dates into the beginning of the Upper Hallstatt Period (c. 620--450 calBC). It had a diameter of over 100 metres and has still a height of 6,5 metres. For complete excavation 45000 cubic metres of earth and stone had to be moved. The first excavations took place in 1887 and 1890 and are in an excellent state of preservation. A modern excavation was done between 1970 and 1973 by Konrad Spindler.  

The central grave was probably erected in 616 BC, as established by dendrochronology [@billamboz_neyses_fuerstengrab_1999]; it had already been reopened in ancient times, but the wooden chamber was still in pristine condition when excavated. Furthermore, more than 100 additional burials were found which were dug into the burial mound a relatively short period after the installation of the central grave. These proved to be of great importance for relative chronology as well as for the social interpretation of the Hallstatt period.  

The importance of the ‘Magdalenenberg‘ does not only derived from the excellent preservation and the many burials that were uncovered, but also from the fact that the excavator Spindler did not choose to wait for the publication until everything was excavated or studied. He started to publish the raw results already in 1971 when the excavation was still under way. By 1980 all graves were published in six volumes [@spindler_magdalenenberg_i; -@spindler_magdalenenberg_ii; -@spindler_magdalenenberg_iii; -@spindler_magdalenenberg_iv; -@spindler_magdalenenberg_v; -@spindler_magdalenenberg_vi].  

In recent years the anthropological material has been subjected to stable isotope analyses [@oelze_et_al_analysis_2012]. In this context the whole material was analysed again by established anthropological methods to get more information on the age and sex of the deceased. This resulted into a paper on the demographic structure of the population of 'Magdalenenberg' [@zaeuner_wahl_magdalenenberg_2013]. The new analyses were able to specify the results in some respects done in the 1970s, but for the sake of this paper it is important to emphasize that in general, they are both congruent.  


### The data set

The aforementioned paper [@zaeuner_wahl_magdalenenberg_2013] provides a complete table of the findings, but as this is very detailed, it is easier to refer to the life table the authors generated. They refrained from including an age range of 0--1, so we followed them in this. As explained above, mortAAR allows this easily. For the oldest age, we assumed, similar to Münsingen, a maximal age of 69 (because the age ranges are in this case inclusive). 

Because of one peculiarity their life table differs from the one mortAAR generates: they estimated the lived years of the oldest age group, 4.72 individuals, with 0, which means that they assumed that the individuals died after reaching their 60th birthday. This does not seem very plausible to us, and we think that the result of mortAAR is more realistic (average death in the middle of the age class). The differences apply specifically to the sum of lived years (Lx) and thus also to Tx, ex and the relative population measure (rel_popx).  


### Constructing the life table

The preparing steps for the construction of the life table of the population from 'Magdalenenberg' are less extensive than from Münsingen-Rain because the data already came from a life table and is thus better prepared.  

```{r}
mag <- magdalenenberg  
```

The only replacement necessary concerns the oldest age group.

```{r}
mag <- mag %>% 
  replace(mag == "60-x", "60-69")  
```

```{r}
mag <- mag %>% 
  tidyr::separate(a, c("from", "to")) %>%  
  transform(from = as.numeric(from), to = as.numeric(to))  
```

As `method` we choose this time "Equal5". This way we get 5-year-intervals throughout, as in the original life table. The closing year is meant to be counted as well, therefore `agerange` is set to "included". The biggest difference to the Münsingen example concerns the number of deceased. Within the Münsingen data each line concerns one individual, while within the Magdalenenberg data each line (= age range) concerns more than one individual. This is why it is mandatory this time to define `dec`. Because we analyze all individuals together, no grouping variable is specified and therefore only one life table will be computed.

```{r}
mag_prep <- mag %>% 
  prep.life.table( 
    dec = "Dx", 
    agebeg = "from", 
    ageend = "to", 
    method = "Equal5",
    agerange = "included"
  )  
```

Finally, the prepared table is fed into the function `life.table`, and the result printed as well as plotted.  

```{r}
mag_result <- mag_prep %>% 
  life.table()  

mag_result 
```

For the purpose of this example, we limit the graphical output to the proportion of deaths (dx), probability of death (qx) and life expectancy (ex).  

```{r}
mag_result %>% 
  plot(display = c("dx","qx","ex"))  
```

### Mortality patterns

Very similar to the Münsingen example, the maximum within the proportion of deaths (dx) of all individuals is in early grown up years, this time around 30 years. Again, largely missing are younger individuals below 20, but also the age of 50 and above. Because of the lack of younger individuals, life expectancy at birth is relatively high at 32.2 years. Already observed by Zäuner and Wahl, the fact that life expectancy is steadily declining from birth onwards is completely atypical. Remarkable, but certainly an artefact due to the necessary artificial age ranges, is the steep decline of the probability of death (qx) after 40 and 60, respectively.



## Comparing Early Iron Age (Magdalenenberg) and Middle/Late Iron Age (Münsingen-Rain)

As a last step for our analysis, we will compare the curves of the life tables of the cemeteries from the 'Magdalenenberg' and Münsingen-Rain.  


### Constructing the life table

The output of the function `prep.life.table` can be addressed separately by their grouping names. We use this option to collect the results of the above examples Münsingen-Rain and Magdalenenberg. For 'Magdalenenberg' with no grouping variable the name of the corresponding `data.frame` within the list of results is "Deceased" by default. Because we want to have comparable data from Münsingen-Rain we choose the output for all individuals (`data.frame` named "All" by default).  

```{r}
comp <- list(mag_prep$Deceased, muen_prep$All)  
```

To have meaningful names for the graphical output, we change these.  

```{r}
names(comp) <- c("Magdalenenberg", "Muensingen")  
```

Again, the newly formed and renamed list is then fed into the function `life.table`.

```{r}
comp_result <- comp %>% 
  life.table()  
```

We can skip the tabular output because this has already been provided above and go straight to the diagrams.  

```{r}
comp_result %>% 
  plot(display = c("dx","qx", "lx","ex"))  
```

### Mortality patterns

The similarities, but also the differences between the data sets are striking. On the one hand, the general shape of the curves of the probability of death (dx) is the same with very low values in the younger and older age classes. By far the most prominent age group in both data sets are the middle aged individuals. However, it seems that the peak for the Magdalenenberg individuals are in the 30s, while for the Münsingen population it is 10 years later. This difference is also reflected in the other diagrams: The probability of death (qx) of the Magdalenenberg individuals is higher in nearly all age categories within 20+, and their rate of survivorship (lx) is decreasing faster. Consequently, while the Münsingen have a life expectancy of 38.0 years when born, the one for the population interred in Magdalenenberg is only at 32.2 years. This difference in the remaining life expectancy remains more or less the same till the highest age group.  

The differences are difficult to explain. First, of course, we have to assess the possibility that the age difference reflects differences present in real life. However, as such a selection is obvious with the subadult individuals it seems hard to exclude a similar preference for older individuals.  

Therefore, another possible reason for the differences could be different cultural preferences in selecting the individuals to be interred in the cemetery. This would mean that they have preferred to inter younger adult individuals during the Upper Hallstatt period and older ones during the Latène period.

Finally, for both data sets it has been emphasized that the skeletal material underwent repeated studies, which reached very similar results, it seems hard to justify fundamental differences in aging by different anthropologists. However, a possible reason could be the varying material that survived. For Münsingen, due to selection processes after excavation, only skulls are available for analysis, while for the Magdalenenberg whole skeletons are existent.  

In the past scholars have taken very different stances to these peculiar age distributions and differences. Already P. Jud [-@jud_untersuchungen_1998, 129] in reference to the population from Magdalenenberg regarded the male individuals from Münsingen-Rain as too old. However, from a paleodemographic perspective the opposite could also be argued, that is that the population of Magdalenenberg is too young.

It is neither the aim nor the scope of this paper to solve this issue. However, in line with a recent overview by Eggl [-@eggl_ueberlegungen_2009] we would like to emphasize the need for more systematic studies that also take not only the paleodemographic, but also the archaeological uncertainties into account.

---

## References
