Section 1 - Introduction

This report presents a survival analysis of the characters from George R. R. Martin’s “The Song of Ice and Fire” book series. The dataset I utilized for the investigation is called “character_deaths” and contains all the deaths of the personages included in the abovementioned novels and can be found on the following page: https://www.kaggle.com/datasets/mylesoneill/game-of-thrones.

Hereby I would like to explain my motivation for choosing to investigate this topic.

First of all, I believe that one of the key components of world-building in George R. R. Martin’s books is its political complexity. The event that begins the “Song of Ice and Fire” is the death of king Robert Baratheon and leads to fatal consequences in several plotlines. Robert Baratheon’s demise, as well as the death of many other characters, such as Eddard Stark, has a strong impact on the geopolitical and sociodemographic composition of Westeros. Thus, the political complexity of the book series, as well as the relationships between various houses and characters, creates the essence of this fantasy novel. Therefore, I wanted to investigate the overall chances of characters’ survival based on their characteristics, such as gender or nobility status.

Secondly, I am a die-hard fan of the series. I read all of the books many times and I participate in the online (Reddit) discussions about the lore of “The Song of Ice and Fire” on a weekly basis. Because I am personally invested in the topic, I decided to analyze the dataset statistically in my report.

In this work, I used descriptive statistics to investigate the sociodemographic characteristics of the sample. Furthermore, I chose to answer the following research questions:

  1. Are female or male characters more likely to survive longer?

  2. Are noble characters or common folk likely to survive longer?

  3. What are the differences between the survival time of characters from House Lannister, House Stark, and Night’s Watch allegiances?

First, I began the project by loading the R packages that I needed along the way. Furthermore, I downloaded the “character_deaths” dataset and uploaded it to my posit.cloud. Finally, I loaded the chosen dataset in R.

library(readr)
library(tidyverse)
library(dplyr)
library(table1)
library(ggplot2)
library(survival)
library(ggsurvfit)
library(survminer)
library(ggpubr)

character_deaths <- read_csv("data/character-deaths.csv")

As I wanted to get a better overview of the dataset, I used the glimpse() function. This allowed me to check how many variables and observations belong to the set.

glimpse(character_deaths)
## Rows: 917
## Columns: 13
## $ Name                 <chr> "Addam Marbrand", "Aegon Frey (Jinglebell)", "Aeg…
## $ Allegiances          <chr> "Lannister", "None", "House Targaryen", "House Gr…
## $ `Death Year`         <dbl> NA, 299, NA, 300, NA, NA, 300, 300, NA, NA, 299, …
## $ `Book of Death`      <dbl> NA, 3, NA, 5, NA, NA, 4, 5, NA, NA, 2, NA, 5, NA,…
## $ `Death Chapter`      <dbl> NA, 51, NA, 20, NA, NA, 35, NA, NA, NA, 56, NA, 4…
## $ `Book Intro Chapter` <dbl> 56, 49, 5, 20, NA, NA, 21, 59, 11, 0, 50, 54, 18,…
## $ Gender               <dbl> 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1…
## $ Nobility             <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0…
## $ GoT                  <dbl> 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0…
## $ CoK                  <dbl> 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1…
## $ SoS                  <dbl> 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0…
## $ FfC                  <dbl> 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0…
## $ DwD                  <dbl> 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0…

WOW! The dataset contains a stunning number of 914 rows/observations! Very impressive! As one can see, there are 13 columns/variables in the dataset. With the code below, I created a data_dictionary data frame that elaborates on the names of the variables.

data_dictionary <- data.frame(
  Variable_Name = c("Name", "Allegiances", "Death Year", "Book of Death", 
                    "Death Chapter", "Book Intro Chapter", "Gender", 
                    "Nobility", "GoT", "CoK", "SoS", "FfC", "DwD"),
  Description = c("Character's name",
                  "Character's allegiances",
                  "Year of death (if applicable)",
                  "Book of death (if applicable)",
                  "Chapter of death (if applicable)",
                  "Chapter of character introduction",
                  "Character's gender",
                  "Nobility status",
                  "Appearance in 'A Game of Thrones'",
                  "Appearance in 'A Clash of Kings'",
                  "Appearance in 'A Storm of Swords'",
                  "Appearance in 'A Feast for Crows'",
                  "Appearancein 'A Dance with Dragons'"),
  stringsAsFactors = FALSE
)

print(data_dictionary)
##         Variable_Name                         Description
## 1                Name                    Character's name
## 2         Allegiances             Character's allegiances
## 3          Death Year       Year of death (if applicable)
## 4       Book of Death       Book of death (if applicable)
## 5       Death Chapter    Chapter of death (if applicable)
## 6  Book Intro Chapter   Chapter of character introduction
## 7              Gender                  Character's gender
## 8            Nobility                     Nobility status
## 9                 GoT   Appearance in 'A Game of Thrones'
## 10                CoK    Appearance in 'A Clash of Kings'
## 11                SoS   Appearance in 'A Storm of Swords'
## 12                FfC   Appearance in 'A Feast for Crows'
## 13                DwD Appearancein 'A Dance with Dragons'

Above the printed data_dictionary frame can be seen.

Section 2 - Exploratory Data Analysis (EDA)

In this section, I chose to explore the sociodemographic characteristics of the dataset. I decided to conduct this analysis by creating a table with summary statistics. Furthermore, I visualized the obtained outcomes

Section 2.1 - Preparation

I began by reducing the number of possible inputs in the Allegiances variable. I noticed that in the dataset many characters were assigned to Allegiances such as “Arryn” instead of “House Arryn”. To aid my analysis, I assigned observations with “Arryn” Allegiance to “House Arryn”, “Baratheon” to “House Baratheon” etc.

Lastly, I created a Status variable which represents wether the character is “Alive” (0) or “Dead” (1).

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Arryn", Allegiances), "House Arryn", Allegiances))

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Baratheon", Allegiances), "House Baratheon", Allegiances))

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Greyjoy", Allegiances), "House Greyjoy", Allegiances))

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Lannister", Allegiances), "House Lannister", Allegiances))

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Martell", Allegiances), "House Martell", Allegiances))

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Stark", Allegiances), "House Stark", Allegiances))

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Targaryen", Allegiances), "House Targaryen", Allegiances))

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Tully", Allegiances), "House Tully", Allegiances))

character_deaths <- character_deaths %>%
                    mutate(Allegiances = ifelse(grepl("Tyrell", Allegiances), "House Tyrell", Allegiances))

character_deaths$Status <- ifelse(!is.na(character_deaths$`Death Year`), 1, 0)

Section 2.2 - Table 1: Descriptive Statistics

In the next steps, I factored the variables Allegiances, Gender, Nobility, and Status variables and created a table with summary statistics. I stratified the table based on the Allegiances.

 character_deaths$Allegiances <- factor(character_deaths$Allegiances, labels = c(
    "House Arryn", "House Baratheon","House Greyjoy", "House Lannister", "House Martell", "House Stark",
    "House Targaryen", "House Tully", "House Tyrell", "Night's Watch", "None", "Wildling"
  ))


character_deaths$Gender <- factor(character_deaths$Gender, levels = c(0, 1), labels = c("Female", "Male"))

character_deaths$Nobility <- factor(character_deaths$Nobility, levels = c(0, 1), labels = c("Common Folk", "Nobility"))

character_deaths$Status <- factor(character_deaths$Status, levels = c(0, 1), labels = c("Alive", "Dead"))


table1(~ Gender + Nobility + Status | Allegiances, data = character_deaths)
House Arryn
(N=30)
House Baratheon
(N=64)
House Greyjoy
(N=75)
House Lannister
(N=102)
House Martell
(N=37)
House Stark
(N=108)
House Targaryen
(N=36)
House Tully
(N=30)
House Tyrell
(N=26)
Night's Watch
(N=116)
None
(N=253)
Wildling
(N=40)
Overall
(N=917)
Gender
Female 6 (20.0%) 6 (9.4%) 5 (6.7%) 14 (13.7%) 14 (37.8%) 27 (25.0%) 6 (16.7%) 2 (6.7%) 10 (38.5%) 0 (0%) 51 (20.2%) 16 (40.0%) 157 (17.1%)
Male 24 (80.0%) 58 (90.6%) 70 (93.3%) 88 (86.3%) 23 (62.2%) 81 (75.0%) 30 (83.3%) 28 (93.3%) 16 (61.5%) 116 (100%) 202 (79.8%) 24 (60.0%) 760 (82.9%)
Nobility
Common Folk 10 (33.3%) 17 (26.6%) 38 (50.7%) 36 (35.3%) 12 (32.4%) 39 (36.1%) 26 (72.2%) 9 (30.0%) 5 (19.2%) 105 (90.5%) 160 (63.2%) 30 (75.0%) 487 (53.1%)
Nobility 20 (66.7%) 47 (73.4%) 37 (49.3%) 66 (64.7%) 25 (67.6%) 69 (63.9%) 10 (27.8%) 21 (70.0%) 21 (80.8%) 11 (9.5%) 93 (36.8%) 10 (25.0%) 430 (46.9%)
Status
Alive 25 (83.3%) 40 (62.5%) 53 (70.7%) 72 (70.6%) 34 (91.9%) 62 (57.4%) 27 (75.0%) 21 (70.0%) 24 (92.3%) 60 (51.7%) 177 (70.0%) 17 (42.5%) 612 (66.7%)
Dead 5 (16.7%) 24 (37.5%) 22 (29.3%) 30 (29.4%) 3 (8.1%) 46 (42.6%) 9 (25.0%) 9 (30.0%) 2 (7.7%) 56 (48.3%) 76 (30.0%) 23 (57.5%) 305 (33.3%)

Thanks to the table we can see the number and percentages of characters belonging to various allegiances who are:

  1. Female or Male;

  2. Noble or Common Folk;

  3. Alive or Dead.

Based on the table, therefore, we can draw a couple of interesting conclusions:

  1. In each Allegiance, there are more Male than Female characters;

  2. In most Allegiances, other than “House Greyjoy”, “House Targaryen”, the “Night’s Watch”, and “None”, there are more “Noble” than “Common Folk” characters;

  3. In all Allegiances, the number of “Alive” characters is greater than that of “Dead” characters. However, in the “Night’s Watch” Allegiance these figures are nearly equal.

Section 2.3 - Visualization of the Descriptive Statistics

Next, I created a code to visually present the outcomes to aid with their interpretation. The script counted the number of observations of the Status and Nobility interaction term in each Allegiances category. The data was faceted by gender.

ggplot(character_deaths, aes(x = Allegiances, fill = interaction(Status, Nobility))) +
  geom_bar(stat = "count", width = 0.7) + 
  labs(x = "Allegiances", y = "Count", title = "Character Deaths by Allegiances, Nobility, and Death Status") +
  facet_wrap(~ Gender, scales = "free") + 
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  scale_fill_manual(values = c("Dead.Common Folk" = "#FF6666",
                              "Dead.Nobility" = "#800000",
                              "Alive.Common Folk" = "#9999FF",
                              "Alive.Nobility" = "#000080"))

The plot allows for an easier interpretation of the figures seen in Table 1. Notice, however, the different scales on the y-axes for Female and Male characters. It also reveals more information about the dataset. Among others, these were::

  1. Among Male characters who belong to the “Night’s Watch” Allegiance, a greater proportion of Noble characters are “Dead” in comparison to “Common Folk” characters;

  2. All Female characters belonging to “House Tyrell” Allegiance are “Noble” and “Alive”;

  3. A greater proportion of “Noble” Female characters who are a part of “None” Allegiance are “Alive” in comparison to their male counterparts.

Section 3 - Survival Analysis

Section 3.1 - Preparation

To test my research questions I decided to analyse the overall survival probability of the characters with Kaplain-Meier Survival Curves. In this section, I decided to use the Book of Death as an indicator of when the event (Status = 1) occurred.

While working on the codes I encountered an issue. Due to the word “of” in the name of the “Book of Death” variable, I encountered problems in computing the data. Thus, I changed the name of the variable to “Book_of_Death”.

character_deaths <- character_deaths %>%
  rename(Book_of_Death = `Book of Death`)

character_deaths$Book_of_Death <- as.integer(character_deaths$Book_of_Death)

Section 3.2 - Kaplain-Meier Survival Curves - Version 1

Are female or male characters more likely to survive longer?
character_deaths$Status <- ifelse(!is.na(character_deaths$`Death Year`), 1, 0)

surv_gender <- survfit(Surv(Book_of_Death, Status) ~ Gender, data = character_deaths)

ggsurvplot(surv_gender,
           data = character_deaths,
           xlab = "Time",
           ylab = "Overall survival probability",
           title = "Kaplan-Meier Survival Curve by Gender",
           conf.int = TRUE,
           ggtheme = theme_minimal())

In the plot, we can observe that Male characters have lower chances of overall survival in comparison to Female characters. The trend is sustained throughout all the books.

Are noble characters or common folk likely to survive longer?
surv_nobility <- survfit(Surv(Book_of_Death, Status) ~ Nobility, data = character_deaths)

ggsurvplot(surv_nobility,
           data = character_deaths,
           xlab = "Time",
           ylab = "Overall survival probability",
           title = "Kaplan-Meier Survival Curve by Nobility",
           conf.int = TRUE,
           ggtheme = theme_minimal())

In the plot, we can observe that Noble characters are more likely to survive than Common folk Characters throughout the books 1 to 4. This trend is, however, reversed in book 5.

What are the differences between the survival time of characters from the most numerous allegiances?
character_deaths_filtered <- character_deaths %>%
  filter(Allegiances %in% c( "House Stark", "Night's Watch", "House Lannister"))

character_deaths_filtered$Allegiance_Group <- factor(character_deaths_filtered$Allegiances)

surv_allegiances <- survfit(Surv(Book_of_Death, Status) ~ Allegiance_Group, data = character_deaths_filtered)

ggsurvplot(surv_allegiances,
           data = character_deaths_filtered,
           xlab = "Time of Death",
           ylab = "Overall survival probability",
           title = "Kaplan-Meier Survival Curve by Selected Allegiances",
           conf.int = TRUE,
           ggtheme = theme_minimal()) 

In the plot, we can observe that the characters of “House Stark” Allegiance are overall the least likely to survive. On the contrary, those with “Night’s Watch” Allegiance are overall the most likely to survive… These results are very surprising considering he high proportion of “Dead” characters belonging to this Allegiance. The characters of “House Lannister” Allegiance are more likely to survive than those of “House Stark” but less likely than “Night’s Watch”.

Section 3.3 - Calculation of Characters’ Lifespan in Chapters

I decided I wanted to obtain a more detailed timeline of the Status event in the books. In this section, I calculated the lifespan of each character in chapters.

First, for an easier comparison, I decided to compute a Book_Intro variable representing the first book in which the character has been introduced.

character_deaths$Book_Intro <- ifelse(character_deaths$GoT == 1, 1,
                                     ifelse(character_deaths$CoK == 1 & character_deaths$GoT == 0, 2,
                                            ifelse(character_deaths$SoS == 1 & character_deaths$GoT == 0 & character_deaths$CoK == 0, 3,
                                                   ifelse(character_deaths$FfC == 1 & character_deaths$GoT == 0 & character_deaths$CoK == 0 & character_deaths$SoS == 0, 0,
                                                          ifelse(character_deaths$DwD == 1 & character_deaths$GoT == 0 & character_deaths$CoK == 0 & character_deaths$SoS == 0 & character_deaths$FfC == 0, 5, NA)))))

I created a variable Total_chapters. I looked up the number of chapters for each book and updated the Total_chapters based on their conditions. Hide

character_deaths$Total_chapters <- 0

character_deaths$Total_chapters <- character_deaths$Total_chapters +
  (character_deaths$GoT * 73) +
  (character_deaths$CoK * 70) +
  (character_deaths$SoS * 82) +
  (character_deaths$FfC * 46) +
  (character_deaths$DwD * 73)

Here, I calculated how many chapters each character survived IF they appeared and died in only 1 of the books. I created a new variable total_chapters2 initialized with the values of Total_chapters. I updated total_characters2 on the abovementioned condition.

character_deaths$total_chapters2 <- character_deaths$Total_chapters

character_deaths$total_chapters2 <- ifelse(character_deaths$GoT == 1 &
                                           character_deaths$CoK == 0 &
                                           character_deaths$SoS == 0 &
                                           character_deaths$FfC == 0 &
                                           character_deaths$DwD == 0,
                                           character_deaths$"Death Chapter" - character_deaths$"Book Intro Chapter",
                                           ifelse(character_deaths$GoT == 0 &
                                                  character_deaths$CoK == 1 &
                                                  character_deaths$SoS == 0 &
                                                  character_deaths$FfC == 0 &
                                                  character_deaths$DwD == 0,
                                                  character_deaths$"Death Chapter" - character_deaths$"Book Intro Chapter",
                                                  ifelse(character_deaths$GoT == 0 &
                                                         character_deaths$CoK == 0 &
                                                         character_deaths$SoS == 1 &
                                                         character_deaths$FfC == 0 &
                                                         character_deaths$DwD == 0,
                                                         character_deaths$"Death Chapter" - character_deaths$"Book Intro Chapter",
                                                         ifelse(character_deaths$GoT == 0 &
                                                                character_deaths$CoK == 0 &
                                                                character_deaths$SoS == 0 &
                                                                character_deaths$FfC == 1 &
                                                                character_deaths$DwD == 0,
                                                                character_deaths$"Death Chapter" - character_deaths$"Book Intro Chapter",
                                                                ifelse(character_deaths$GoT == 0 &
                                                                       character_deaths$CoK == 0 &
                                                                       character_deaths$SoS == 0 &
                                                                       character_deaths$FfC == 0 &
                                                                       character_deaths$DwD == 1,
                                                                       character_deaths$"Death Chapter" - character_deaths$"Book Intro Chapter",
                                                                       character_deaths$total_chapters2
                                                                       )
                                                                )
                                                         )
                                                  )
                                           )

Next, I calculated how many chapters each character survived IF they appeared in book A but died in book B. I created a new variable total_chapters3 initialized with the values of total_chapters2. I updated total_characters3 on the abovementioned condition.

character_deaths$total_chapters3 <- character_deaths$total_chapters2

character_deaths$total_chapters3 <- ifelse(character_deaths$GoT == 1 &
                                           (character_deaths$CoK == 1 | character_deaths$SoS == 1 | character_deaths$FfC == 1 | character_deaths$DwD == 1),
                                           character_deaths$total_chapters3 - character_deaths$Book_Intro,
                                           ifelse(character_deaths$GoT == 0 & 
                                                  (character_deaths$SoS == 1 | character_deaths$FfC == 1 | character_deaths$DwD == 1) & 
                                                  character_deaths$CoK == 1,
                                                  character_deaths$total_chapters3 - character_deaths$Book_Intro,
                                                  ifelse((character_deaths$GoT == 0 | character_deaths$CoK == 0) & 
                                                         (character_deaths$FfC == 1 | character_deaths$DwD == 1) & 
                                                         character_deaths$SoS == 1,
                                                         character_deaths$total_chapters3 - character_deaths$Book_Intro,
                                                         ifelse((character_deaths$GoT == 0 | character_deaths$CoK == 0 | character_deaths$SoS == 0) &
                                                                (character_deaths$FfC == 1 | character_deaths$DwD == 0),
                                                                character_deaths$total_chapters3 - character_deaths$Book_Intro,
                                                                character_deaths$total_chapters3
                                                         )
                                                  )
                                           )
)

Finally, I calculated how many chapters each character survived IF they appeared in book A but died in book B under the conditions of total_chapters2. I created a new variable total_chapters4 initialized with the values of total_chapters2. I updated total_characters4 on the abovementioned condition.

character_deaths$total_chapters4 <- character_deaths$total_chapters2

character_deaths$total_chapters4 <- ifelse(character_deaths$GoT == 1 &
                                           character_deaths$CoK == 0 &
                                           character_deaths$SoS == 0 &
                                           character_deaths$FfC == 0 &
                                           character_deaths$DwD == 0,
                                           character_deaths$"Death Chapter" - character_deaths$"Book Intro Chapter",
                                           ifelse(character_deaths$GoT == 0 &
                                                      character_deaths$SoS == 1 &
                                                      character_deaths$FfC == 1 &
                                                      character_deaths$DwD == 1 &
                                                      character_deaths$CoK == 0,
                                                  character_deaths$total_chapters4 - character_deaths$Book_Intro,
                                                  ifelse(character_deaths$GoT == 0 &
                                                             character_deaths$CoK == 1 &
                                                             character_deaths$FfC == 1 &
                                                             character_deaths$DwD == 1 &
                                                             character_deaths$SoS == 0,
                                                          character_deaths$total_chapters4 - character_deaths$Book_Intro,
                                                          ifelse(character_deaths$GoT == 0 &
                                                                     character_deaths$CoK == 0 &
                                                                     character_deaths$SoS == 1 &
                                                                     character_deaths$FfC == 0 &
                                                                     character_deaths$DwD == 1,
                                                                  character_deaths$total_chapters4 - character_deaths$Book_Intro,
                                                                  ifelse(character_deaths$GoT == 0 &
                                                                             character_deaths$CoK == 0 &
                                                                             character_deaths$SoS == 0 &
                                                                             character_deaths$FfC == 1 &
                                                                             character_deaths$DwD == 0,
                                                                          character_deaths$total_chapters4 - character_deaths$Book_Intro,
                                                                          character_deaths$total_chapters4
                                                                  )
                                                          )
                                                  )
                                           )
)

Section 3.4 - Kaplain-Meier Survival Curves - Version 2

In this section, I plotted the Kaplan-Meier Survival curved by Gender, Nobility, and House Lannister, House Stark, and Night’s Watch allegiances with total_chapters4 as an indication of when the event (Status = 1) occurred.

Are female or male characters more likely to survive longer?
surv_gender <- survfit(Surv(total_chapters4, Status) ~ Gender, data = character_deaths)
ggsurvplot(surv_gender,
           data = character_deaths,
           xlab = "Time",
           ylab = "Overall survival probability",
           title = "Kaplan-Meier Survival Curve by Gender",
           conf.int = TRUE,
           ggtheme = theme_minimal())

In the plot, we can observe that Male characters have lower chances of overall survival in comparison to Female characters. The trend is sustained throughout all the books.

This plot is identical to its counterpart in Section 3.2.

Are noble characters or common folk likely to survive longer?
surv_nobility <- survfit(Surv(total_chapters4, Status) ~ Nobility, data = character_deaths)
ggsurvplot(surv_nobility,
           data = character_deaths,
           xlab = "Time",
           ylab = "Overall survival probability",
           title = "Kaplan-Meier Survival Curve by Nobility",
           conf.int = TRUE,
           ggtheme = theme_minimal())

In the plot, we can observe that Noble characters are more likely to survive in comparison to Common folk characters. The trend is sustained throughout all the books.

This plot is not identical to its counterpart in Section 3.2., where in Book 5 the trend where common folk had a higher probability of overall survival. ##

What are the differences between the survival time of characters from the most numerous allegiances?
character_deaths_filtered <- character_deaths %>%
  filter(Allegiances %in% c("House Stark", "Night's Watch", "House Lannister"))
character_deaths_filtered$Allegiance_Group <- factor(character_deaths_filtered$Allegiances)


surv_allegiances <- survfit(Surv(total_chapters4, Status) ~ Allegiance_Group, data = character_deaths_filtered)
ggsurvplot(surv_allegiances,
           data = character_deaths_filtered,
           xlab = "Time of Death",
           ylab = "Overall survival probability",
           title = "Kaplan-Meier Survival Curve by Selected Allegiances",
           conf.int = TRUE,
           ggtheme = theme_minimal()) 

In the plot, we can observe that “House Lannister” Allegiance is overall the most likely to survive. On the contrary, those with “Night’s Watch” and “House Stark” Allegiance are overall the less likely to survive. It is difficult to state, however, which one of these houses has the lowest chances of survival as their curves are nearly identical. One distinction between “House Stark” and “Night’s Watch” is that in that until chapter 50, characters of “Night’s Watch’ Allegiance die much faster than those of House Stark”.

This plot is not identical to its counterpart in Section 3.2., where the characters of “Night’s Watch” Allegiance were most likely to survive. cha This plot is not identical to its counterpart in Section 3.2., where chharacters of “Night’s Watch” Allegiance were most likely to survive.

Section 4: Discussion & Conclusion

In this report, I conducted a survival analysis of characters from George R. R. Martin’s “The Song of Ice and Fire” book series using the “character_deaths” dataset. I aimed to investigate the overall chances of characters’ survival based on their characteristics, namely gender, nobility status, and allegiance.

Section 4.1 - Predictions and Conclusions

My analysis revealed several interesting findings.

Firstly, male characters were consistently found to have lower overall survival probabilities compared to female characters throughout all the books.

Secondly, noble characters tended to have higher survival probabilities than common folk, except for in book 5 where common folk had a higher probability of overall survival. However, it’s worth mentioning that chapters were considered an indication of when the event (Status = 1) occurred, the noble had higher overall survival probabilities throughout all the books.

Thirdly, characters from House Lannister were overall the most likely to survive, while characters from House Stark and Night’s Watch were the least likely. This was the case the chapters were considered an indication of when the event (Status = 1) occurred. However, it’s worth noting that the survival curves for House Stark and Night’s Watch were very similar, indicating a similar likelihood of survival for characters from these allegiances.

Section 4.2 - Limitations

While my analysis provided valuable insights, there are several limitations to consider.

First, the initial analysis relies on the assumption that the “Book of Death” variable accurately reflects the timing of character deaths. However, it’s possible that some deaths were not explicitly mentioned in the books or occurred between chapters, leading to potential inaccuracies in our survival analysis. Although “total_chapters4” provides (most probably) a more accurate picture of the survival analysis, my report lacks comparison between these two models.

Furthermore, my analysis focuses on descriptive statistics and survival curves. Prhaps comparing the results to more advanced modeling techniques like Cox proportional hazards regression could provide more accurate insights.

To improve my report, I could incorporate additional variables such as character age or relationships with other characters. Moreover, it would be interesting to include predictions of the specific character’s survival, such as Arya Stark or Cersei Lannister in Books 6 and 7.

Lastly, looking for additional datasets or sources of information such as character wikis or fan databases could provide more variables to the original dataset, and thus more insights, into characters’ fates.

Section 4.3 - Reflection and Future Directions

One aspect that I would do differently if starting over is conducting a more comprehensive data preprocessing process to ensure the accuracy and consistency of the dataset. Furthermore, I would explore other survival analysis techniques. Lastly, I would conduct an analysis that could check the significance of my results. In summary, my analysis provides interesting insights into the survival probability of characters in “The Song of Ice and Fire” series. It discusses the influence of gender, nobility status, and allegiance on characters’ fates. While this report offers valuable insights further exploration of the complex world of Westeros are needed.

I would like to give credits to Allen Downey, whose blog post inspired me to conduct this analysis. The original post can be found here: https://allendowney.blogspot.com/2015/03/bayesian-survival-analysis-for-game-of.html