knitr::opts_chunk$set(echo = TRUE)
library(FiDEL)
library(ggplot2)
library(latex2exp)
library(data.table)
library(ggpubr)

lambda function

get_fermi(0.8, 0.1, N=10000)
auclist <- (2:48)*0.01 + 0.5
rholist <- (2:18)*0.05
N <-1000

res <- data.table()

for (a in auclist) {
  for (r in rholist) {
    temp <- get_fermi(a, r)
    temp <- c(temp, a, r)
    res <- cbind(res, temp)
  }
}

res <- data.table(t(res))
colnames(res) <- c('beta', 'mu', 'rs', 'AUC', 'rho')
res
auclist <- (2:48)*0.01 + 0.5
rholist <- (2:18)*0.05
N <-1000

res1 <- data.table()

for (a in auclist) {
  for (r in rholist) {
    temp <- get_fermi_root(a, r)
    temp <- c(temp, a, r)
    res1 <- cbind(res1, temp)
  }
}

res1 <- data.table(t(res1))
colnames(res1) <- c('beta', 'mu', 'rs', 'AUC', 'rho')
res1
g1 <- ggplot(data=res) + geom_point(aes(x=AUC, y=mu, color=rho)) + theme_classic() + 
  xlab('AUC') + ylab(TeX('$\\mu/N$'))
ggsave('results/dilog_lambda_auc_l1.pdf', width=6)
g1
g2 <- ggplot(data=res) + geom_point(aes(x=AUC, y=beta, color=rho)) + theme_classic() +
  xlab('AUC') + ylab(TeX('$N \\beta$'))
ggsave('results/dilog_lambda_auc_l2.pdf', width=6)
g2
g3 <- ggplot(data=res) + geom_point(aes(x=AUC, y=rs, color=rho)) + theme_classic() +
  xlab('AUC') + ylab('R*/N')
ggsave('results/dilog_lambda_auc_rs.pdf', width=6)
g3
g4 <- ggplot(data=res) + geom_point(aes(x=rho, y=mu, color=AUC)) + theme_classic() + 
  xlab(TeX('$\\rho')) + ylab(TeX('$\\mu / N$'))
g4
g5 <- ggplot(data=res) + geom_point(aes(x=rho, y=beta, color=AUC)) + theme_classic() + 
  xlab(TeX('$\\rho')) + ylab(TeX('$N \\beta'))
g5
g <- ggarrange(g2, g1, g5, g4, labels=c("A", "B", "C", "D"), ncol=2  , nrow=2)
ggsave("results/dilog_betamu_relation.pdf", width=8, height=6, dpi=300)
g
library(plotly)
rhoN <- length(unique(res$rho))
AUCN <- length(unique(res$AUC))

rho <- unique(res$rho)
AUC <- unique(res$AUC)

beta <- matrix(res$beta, nrow=rhoN, ncol=AUCN)
mu <- matrix(res$mu, nrow=rhoN, ncol=AUCN)
fig <- plot_ly(z = ~mu, x = AUC, y = rho, type='surface') %>% add_surface(
  contours = list(
    z = list(
      show=TRUE,
      usecolormap=TRUE,
      highlightcolor="#ff0000",
      project=list(z=TRUE)
      )
    )
  )
fig <- fig %>% layout(
    scene = list(
      camera=list(
        eye = list(x=1.87, y=0.88, z=-0.64)
        )
      )
  )

fig


sungcheolkim78/FiDEL documentation built on Nov. 13, 2024, 7:58 a.m.