Skip to content

Commit

Permalink
here package used for better working directory management
Browse files Browse the repository at this point in the history
  • Loading branch information
markean committed Jan 18, 2024
1 parent ed36ca7 commit cf19915
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 25 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: retel
Type: Package
Title: Regularized Exponentially Tilted Empirical Likelihood
Version: 0.0.0.9600
Version: 0.0.0.9601
Authors@R: c(
person("Eunseop", "Kim", email = "markean@pm.me",
role = c("aut", "cre")),
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CMD
DMS
SES
Schennach
WIP
arXiv
doi
https
Expand Down
4 changes: 2 additions & 2 deletions retel-paper/code/figures/figure1.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ lambda_RETEL <- function(par) {

# Convex hull constraint satisfied at 1
target <- lambda_RETEL(1)
grid <- seq(from = 5, to = 20, length.out = 100)
grid <- seq(from = 5, to = 20, length.out = 100L)
approx <- vapply(round(2^grid), function(k) lambda_WETEL(1, k),
FUN.VALUE = numeric(1L)
)
Expand Down Expand Up @@ -68,7 +68,7 @@ ggplot(df) +

# Convex hull constraint violated at 3
target2 <- lambda_RETEL(-3)
grid <- seq(from = 5, to = 20, length.out = 100)
grid <- seq(from = 5, to = 20, length.out = 100L)
approx2 <- vapply(round(2^grid), function(k) lambda_WETEL(-3, k),
FUN.VALUE = numeric(1L)
)
Expand Down
3 changes: 1 addition & 2 deletions retel-paper/code/figures/figure2.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ library(retel)
opts <- list("algorithm" = "NLOPT_LD_LBFGS", "xtol_rel" = 1e-06)

# Data
n <- 1
x <- 0

# Functions
Expand All @@ -15,7 +14,7 @@ f <- function(x, par) {
}

# Grid
grid <- seq(from = -1, to = 1, length.out = 300)
grid <- seq(from = -1, to = 1, length.out = 300L)
f_keep_pc <- function(tau) {
vapply(grid, function(k) {
retel(f, x,
Expand Down
4 changes: 3 additions & 1 deletion retel-paper/code/figures/figure3.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ library(cowplot)
library(ggplot2)
library(grid)
library(gridExtra)
suppressMessages(library(here))
suppressMessages(here::i_am("code/figures/figure3.R"))

# Data
result <- readRDS("./simulations/mb/mb_1/n5s5.rds")
result <- readRDS(here::here("simulations/mb/mb_1/n5s5.rds"))
df <- as.data.frame(result)

# RETEL_f
Expand Down
10 changes: 6 additions & 4 deletions retel-paper/code/figures/supplement/figure1.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ library(cowplot)
library(ggplot2)
library(grid)
library(gridExtra)
suppressMessages(library(here))
suppressMessages(here::i_am("code/figures/supplement/figure1.R"))


## Load data
df_tau1_n5s1 <-
readRDS("./simulations/mb/mb_1/n5s1.rds") |>
readRDS(here::here("simulations/mb/mb_1/n5s1.rds")) |>
as.data.frame()
df_tau1_n20s1 <-
readRDS("./simulations/mb/mb_1/n20s1.rds") |>
readRDS(here::here("simulations/mb/mb_1/n20s1.rds")) |>
as.data.frame()
df_tau1_n50s1 <-
readRDS("./simulations/mb/mb_1/n50s1.rds") |>
readRDS(here::here("simulations/mb/mb_1/n50s1.rds")) |>
as.data.frame()
df_tau1_n100s1 <-
readRDS("./simulations/mb/mb_1/n100s1.rds") |>
readRDS(here::here("simulations/mb/mb_1/n100s1.rds")) |>
as.data.frame()


Expand Down
10 changes: 6 additions & 4 deletions retel-paper/code/figures/supplement/figure2.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ library(cowplot)
library(ggplot2)
library(grid)
library(gridExtra)
suppressMessages(library(here))
suppressMessages(here::i_am("code/figures/supplement/figure2.R"))


## Load data
df_tau1_n5s5 <-
readRDS("./simulations/mb/mb_1/n5s5.rds") |>
readRDS(here::here("simulations/mb/mb_1/n5s5.rds")) |>
as.data.frame()
df_tau1_n20s5 <-
readRDS("./simulations/mb/mb_1/n20s5.rds") |>
readRDS(here::here("simulations/mb/mb_1/n20s5.rds")) |>
as.data.frame()
df_tau1_n50s5 <-
readRDS("./simulations/mb/mb_1/n50s5.rds") |>
readRDS(here::here("simulations/mb/mb_1/n50s5.rds")) |>
as.data.frame()
df_tau1_n100s5 <-
readRDS("./simulations/mb/mb_1/n100s5.rds") |>
readRDS(here::here("simulations/mb/mb_1/n100s5.rds")) |>
as.data.frame()


Expand Down
10 changes: 6 additions & 4 deletions retel-paper/code/figures/supplement/figure3.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ library(cowplot)
library(ggplot2)
library(grid)
library(gridExtra)
suppressMessages(library(here))
suppressMessages(here::i_am("code/figures/supplement/figure3.R"))


## Load data
df_taulogn_n5s1 <-
readRDS("./simulations/mb/mb_logn/n5s1.rds") |>
readRDS(here::here("simulations/mb/mb_logn/n5s1.rds")) |>
as.data.frame()
df_taulogn_n20s1 <-
readRDS("./simulations/mb/mb_logn/n20s1.rds") |>
readRDS(here::here("simulations/mb/mb_logn/n20s1.rds")) |>
as.data.frame()
df_taulogn_n50s1 <-
readRDS("./simulations/mb/mb_logn/n50s1.rds") |>
readRDS(here::here("simulations/mb/mb_logn/n50s1.rds")) |>
as.data.frame()
df_taulogn_n100s1 <-
readRDS("./simulations/mb/mb_logn/n100s1.rds") |>
readRDS(here::here("simulations/mb/mb_logn/n100s1.rds")) |>
as.data.frame()


Expand Down
10 changes: 6 additions & 4 deletions retel-paper/code/figures/supplement/figure4.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ library(cowplot)
library(ggplot2)
library(grid)
library(gridExtra)
suppressMessages(library(here))
suppressMessages(here::i_am("code/figures/supplement/figure4.R"))


## Load data
df_taulogn_n5s5 <-
readRDS("./simulations/mb/mb_logn/n5s5.rds") |>
readRDS(here::here("simulations/mb/mb_logn/n5s5.rds")) |>
as.data.frame()
df_taulogn_n20s5 <-
readRDS("./simulations/mb/mb_logn/n20s5.rds") |>
readRDS(here::here("simulations/mb/mb_logn/n20s5.rds")) |>
as.data.frame()
df_taulogn_n50s5 <-
readRDS("./simulations/mb/mb_logn/n50s5.rds") |>
readRDS(here::here("simulations/mb/mb_logn/n50s5.rds")) |>
as.data.frame()
df_taulogn_n100s5 <-
readRDS("./simulations/mb/mb_logn/n100s5.rds") |>
readRDS(here::here("simulations/mb/mb_logn/n100s5.rds")) |>
as.data.frame()


Expand Down
4 changes: 2 additions & 2 deletions retel-paper/code/simulations/cr.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ library(retel)
# Prior location
l <- 0
# Sample size
n <- 5
n <- 5L
# Prior scale
s <- 0.5

Expand Down Expand Up @@ -86,7 +86,7 @@ set.seed(847675)
cl <- makeCluster(24L)
registerDoParallel(cl)
result <- foreach(
i = icount(S), .combine = "rbind", .inorder = F,
i = icount(S), .combine = "rbind", .inorder = FALSE,
.packages = c("nloptr", "retel")
) %dorng% {
# Sample data
Expand Down
2 changes: 1 addition & 1 deletion retel-paper/code/simulations/mb.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ set.seed(847675)
cl <- makeCluster(24L)
registerDoParallel(cl)
result <- foreach(
i = icount(S), .combine = "rbind", .inorder = F,
i = icount(S), .combine = "rbind", .inorder = FALSE,
.packages = c("nloptr", "retel")
) %dorng% {
# Sample theta from prior
Expand Down
10 changes: 10 additions & 0 deletions retel-paper/renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,16 @@
],
"Hash": "b29cf3031f49b04ab9c852c912547eef"
},
"here": {
"Package": "here",
"Version": "1.0.1",
"Source": "Repository",
"Repository": "RSPM",
"Requirements": [
"rprojroot"
],
"Hash": "24b224366f9c2e7534d2344d10d59211"
},
"highr": {
"Package": "highr",
"Version": "0.10",
Expand Down

0 comments on commit cf19915

Please sign in to comment.