diff --git a/README.md b/README.md index c1e42c3..1c451bb 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ | ------------------------------------------------------------ | -------------------- | :----------------------------------------------------------- | | [Alm (2015)](https://www.tandfonline.com/doi/abs/10.1080/03461238.2013.787367) | ***SAJ*** | [review](https://github.com/kwoongbae/risk-management-papers/issues/36) / [seminar file](./review/Seminar_20240626.pdf) | | [Bermúdez et al. (2013)](https://www.cambridge.org/core/journals/astin-bulletin-journal-of-the-iaa/article/correlation-sensitivity-analysis-of-nonlife-underwriting-risk-in-solvency-capital-requirement-estimation/8C16299AF4E9DFCD13C5C7EA3697705E) | ***ASTIN Bulletin*** | [review](https://github.com/kwoongbae/risk-management-papers/issues/37) | - | [Eling and Schnell (2020)](https://www.tandfonline.com/doi/abs/10.1080/10920277.2019.1641416) | ***NAAJ*** | [review](https://github.com/kwoongbae/risk-management-papers/issues/32) / [code (R)](https://github.com/kwoongbae/risk-management-papers/blob/main/code/Eling_and_Schnell_NAAJ_2020.r) | + | [Eling and Schnell (2020)](https://www.tandfonline.com/doi/abs/10.1080/10920277.2019.1641416) | ***NAAJ*** | [review](https://github.com/kwoongbae/risk-management-papers/issues/32) / [code](./code/Eling_and_Schnell_NAAJ_2020.r) | - **(시스템적) 사이버 리스크 관련 문헌** diff --git a/code/.RData b/code/.RData new file mode 100644 index 0000000..a609037 Binary files /dev/null and b/code/.RData differ diff --git a/code/.Rhistory b/code/.Rhistory new file mode 100644 index 0000000..6e7c97c --- /dev/null +++ b/code/.Rhistory @@ -0,0 +1,100 @@ +rm(list=ls()) +# Required packages +library(mvtnorm) +library(ggplot2) +library(ggExtra) +# =================================================== +# 1. Import libraries and SAS OpRisk Global dataset +# =================================================== +install.packages("mvtnorm") +# =================================================== +# 1. Import libraries and SAS OpRisk Global dataset +# =================================================== +install.packages("ggplot2") +install.packages("ggplot2") +# =================================================== +# 1. Import libraries and SAS OpRisk Global dataset +# =================================================== +install.packages("ggExtra") +# Required packages +library(mvtnorm) +library(ggplot2) +library(ggExtra) +library(sn) +# =================================================== +# 1. Import libraries and SAS OpRisk Global dataset +# =================================================== +install.packages("sn") +library(sn) +sim.GC <- function(n, rho, qmarg1, qmarg2){ +R <- rbind(c(1,rho),c(rho,1)) +dat <- rmvnorm(n, mean = c(0,0), sigma = R) +dat[,1] <- qmarg1(pnorm(dat[,1])) +dat[,2] <- qmarg2(pnorm(dat[,2])) +return(dat) +} +set.seed(1234) +q1 <- function(p) qunif(p) +q2 <- function(p) qunif(p) +q1 +qunif(100) +ns <- 1000; rho = 0.7 +sim <- sim.GC(n = ns, rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +df +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + +xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") +ns <- 1000; rho = 1 +sim <- sim.GC(n = ns, rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + +xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") +ns <- 1000; rho = 0.7 +sim <- sim.GC(n = ns, rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + +xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") +grid::grid.newpage() +ns <- 1000; rho = 0.75 +sim <- sim.GC(n = ns,rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + +xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.75"))) +ggExtra::ggMarginal(p, type = "histogram") +#-------------------- +# Logistic marginals +#-------------------- +q1 <- function(p) qlogis(p) +q2 <- function(p) qlogis(p) +ns <- 1000; rho = 0.5 +sim <- sim.GC(n = ns,rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + +xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") +#---------------------------------------------------- +# Student-t with 4 degrees of freedom marginals +#---------------------------------------------------- +q1 <- function(p) qt(p, df = 4) +q2 <- function(p) qt(p, df = 4) +ns <- 1000; rho = 0.5 +sim <- sim.GC(n = ns,rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + +xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") +#---------------------------------------------------- +# Student-t with 4 degrees of freedom marginal for X +# Standard normal for Y +#---------------------------------------------------- +q1 <- function(p) qt(p, df = 4) +q2 <- function(p) qnorm(p) +ns <- 1000; rho = 0.5 +sim <- sim.GC(n = ns,rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + +xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") diff --git a/code/Copula.r b/code/Copula.r new file mode 100644 index 0000000..37b8891 --- /dev/null +++ b/code/Copula.r @@ -0,0 +1,96 @@ +# =================================================== +# Import libraries and SAS OpRisk Global dataset +# =================================================== +install.packages("sn") +set.seed(1234) +rm(list=ls()) +# Required packages +library(mvtnorm) +library(ggplot2) +library(ggExtra) +library(sn) + +# =================================================== +# normal margins +# =================================================== + +sim.GC <- function(n, rho, qmarg1, qmarg2){ + R <- rbind(c(1,rho),c(rho,1)) #rho가 두 변수 간의 상관관계를 의미함. + dat <- rmvnorm(n, mean = c(0,0), sigma = R) + dat[,1] <- qmarg1(pnorm(dat[,1])) + dat[,2] <- qmarg2(pnorm(dat[,2])) + return(dat) +} + +q1 <- function(p) qunif(p) +q2 <- function(p) qunif(p) + +ns <- 1000; rho = 0.7 +sim <- sim.GC(n = ns, rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + + xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") + + +grid::grid.newpage() + +ns <- 1000; rho = 0.75 +sim <- sim.GC(n = ns,rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + + xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.75"))) +ggExtra::ggMarginal(p, type = "histogram") + + + +grid::grid.newpage() + + +# =================================================== +# Logistic marginals +# =================================================== + +q1 <- function(p) qlogis(p) +q2 <- function(p) qlogis(p) + +ns <- 1000; rho = 0.5 +sim <- sim.GC(n = ns,rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + + xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") + +grid::grid.newpage() + + +# =================================================== +# Student-t with 4 degrees of freedom marginals +# =================================================== + +q1 <- function(p) qt(p, df = 4) +q2 <- function(p) qt(p, df = 4) + +ns <- 1000; rho = 0.5 +sim <- sim.GC(n = ns,rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + + xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram") + +grid::grid.newpage() + + +# =================================================== +# Student-t with 4 degrees of freedom marginal for X +# Standard normal for Y +# =================================================== +q1 <- function(p) qt(p, df = 4) +q2 <- function(p) qnorm(p) + +ns <- 1000; rho = 0.5 +sim <- sim.GC(n = ns,rho = rho,q1,q2) +df <- data.frame(x = sim[,1], y = sim[,2]) +p <- ggplot(df, aes(x, y)) + geom_point() + theme(axis.text.x = element_text(size = 14), axis.text.y = element_text(size = 14)) + + xlab("X") + ylab("Y") + ggtitle(expression(paste(rho, "=0.5"))) +ggExtra::ggMarginal(p, type = "histogram")