Skip to content

Commit 6b67d78

Browse files
committed
Update:
- recalculate all analyses using R-Ratepol 0.6.0 - change the 'early' and 'late' to follow the paleo nomenclature - add 3 new sensitivity analyses - recreated all data and all figures
1 parent b662d7e commit 6b67d78

File tree

84 files changed

+7511
-8097
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+7511
-8097
lines changed

R/00_config.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ high_diversity <- 50
6363

6464
# position of the enviromental change in the sequence
6565
breaks_late <- c(2000, 3000)
66-
breaks_recent <- c(5500, 6500)
66+
breaks_early <- c(5500, 6500)
6767

6868
# Number of simulated datasest of pollen data
6969
N_rep <- 100
7070

7171
# template of time sequence with uneven distribution of points
72-
time_seq <- data_example$list_ages[[4]]$ages$age
72+
time_seq <- data_example$sample_age[[4]]$age
7373

7474

7575
# 3.2. ROC Rratepol setting -----
7676
age_lim <- 8e3
77-
roc_n_rand <- 10e3
77+
roc_n_rand <- 1e3
7878
pollen_grains <- 150
7979

8080

R/01_data_creation.R

+10-10
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ source("R/00_config.R")
1717
# 1. Simulate datasets -----
1818
#----------------------------------------------------------#
1919

20-
# low diversity recent
20+
# low diversity early
2121

22-
sim_ld_recent <-
22+
sim_ld_early <-
2323
.simulate.pollen.data.in.multiple.datasets(
2424
time = time_seq,
2525
nforc = N_env,
2626
nprox = low_diversity,
2727
manual_edit = TRUE,
28-
breaks = breaks_recent,
28+
breaks = breaks_early,
2929
jitter = TRUE,
3030
rarity = TRUE,
3131
N_datasets = N_rep)
@@ -43,13 +43,13 @@ sim_ld_late <-
4343
N_datasets=N_rep)
4444

4545

46-
sim_hd_recent <-
46+
sim_hd_early <-
4747
.simulate.pollen.data.in.multiple.datasets(
4848
time=time_seq,
4949
nforc=N_env,
5050
nprox=high_diversity,
5151
manual_edit = T,
52-
breaks=breaks_recent,
52+
breaks=breaks_early,
5353
jitter = T,
5454
rarity=T,
5555
N_datasets=N_rep)
@@ -75,19 +75,19 @@ simulated_dataset <-
7575
dpyr::bind_rows(
7676

7777
tibble::tibble(
78-
sim_ld_recent,
78+
sim_ld_early,
7979
diversity = "low_diversity",
80-
position = "breaks_recent"),
80+
position = "breaks_early"),
8181

8282
tibble::tibble(
8383
sim_ld_late,
8484
diversity = "low_diversity",
8585
position = "breaks_late"),
8686

8787
tibble::tibble(
88-
sim_ld_recent,
88+
sim_ld_early,
8989
diversity = "high_diversity",
90-
position = "breaks_recent"),
90+
position = "breaks_early"),
9191

9292
tibble::tibble(
9393
sim_ld_late,
@@ -108,4 +108,4 @@ simulated_dataset
108108
#----------------------------------------------------------#
109109
write_rds(
110110
simulated_dataset,
111-
"data/output/datasets/simulated/simulated_dataset.rds")
111+
"data/output/datasets/simulated/simulated_dataset.rds")

R/02_ROC_of_simulated_data.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ simulated_dataset <-
2727

2828
ROC_levels <-
2929
.estimate.RoC.by.all.methods(
30-
simulated_dataset,
30+
random_data = simulated_dataset,
3131
Working_Unit = "levels",
3232
interest_threshold = 8000)
3333

R/03_model_building.R

+28-73
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ data_sum <-
3131

3232
position = factor(
3333
position,
34-
levels = c("breaks_recent", "breaks_late")) %>%
34+
levels = c("breaks_early", "breaks_late")) %>%
3535
fct_recode(
36-
"low density level" = "breaks_recent",
36+
"low density level" = "breaks_early",
3737
"high density level" = "breaks_late"),
3838
diversity = factor(
3939
diversity,
@@ -80,7 +80,6 @@ data_sum <-
8080
RoC_setting = paste0(smooth," - ",DC) %>%
8181
as.factor())
8282

83-
8483
# explore data
8584
data_sum %>%
8685
summary()
@@ -326,28 +325,38 @@ mod_detail_correct_dd %>%
326325
View()
327326

328327
mod_detail_correct_m1 <-
329-
glmmTMB(success ~ DC + position + smooth +
330-
DC:position + DC:smooth + position:smooth +
331-
DC:position:smooth + # fixed effets
328+
glmmTMB(success ~ position + smooth +
329+
position:smooth + # fixed effets
332330
(1|dataset_ID), # random effects
333331
data = data_detail_correct,
334332
family = beta_family(link = "logit")
335333
)
336334

337335

338336
mod_detail_correct_m2 <-
339-
glmmTMB(success ~ DC + diversity + position + smooth +
340-
DC:position + DC:smooth + position:smooth +
341-
DC:position:smooth + # fixed effets
337+
glmmTMB(success ~ DC + position + smooth +
338+
position:smooth + # fixed effets
339+
(1|dataset_ID), # random effects
340+
data = data_detail_correct,
341+
family = beta_family(link = "logit")
342+
)
343+
344+
mod_detail_correct_m3 <-
345+
glmmTMB(success ~ diversity + position + smooth +
346+
position:smooth + # fixed effets
342347
(1|dataset_ID), # random effects
343348
data = data_detail_correct,
344349
family = beta_family(link = "logit")
345350
)
346351

352+
353+
354+
347355
mod_detail_correct_final_comp <-
348356
compare_performance(
349357
mod_detail_correct_m1,
350358
mod_detail_correct_m2,
359+
mod_detail_correct_m3,
351360
rank = T)
352361

353362
mod_detail_correct_final_comp
@@ -356,16 +365,17 @@ mod_detail_correct_final_comp %>%
356365
as_tibble() %>%
357366
left_join(.,
358367
tibble(
359-
Model = paste0("mod_detail_correct_m",1:2),
360-
formula = lapply(paste0("mod_detail_correct_m",1:2), FUN = function(x) formula(get(x))) %>%
368+
Model = paste0("mod_detail_correct_m",1:nrow(mod_detail_correct_final_comp)),
369+
formula = lapply(paste0("mod_detail_correct_m",1:nrow(mod_detail_correct_final_comp)),
370+
FUN = function(x) formula(get(x))) %>%
361371
as.character()),
362372
by = "Model") %>%
363373
dplyr::select(formula, everything()) %>%
364374
write_csv(
365375
.,"data/output/result_tables/mod_detail_correct_final_comp.csv")
366376

367-
# -> model 1 is the best
368-
mod_detail_correct_select <- mod_detail_correct_m1
377+
# -> model 2 is the best
378+
mod_detail_correct_select <- mod_detail_correct_m2
369379
write_rds(mod_detail_correct_select,"data/output/models/mod_detail_correct_select.rds")
370380

371381
#--------------------------------#
@@ -459,89 +469,33 @@ mod_detail_false_dd %>%
459469

460470
mod_detail_false_m1 <-
461471
glmmTMB(success ~ DC + position + smooth +
462-
DC:smooth + position:smooth +
472+
position:smooth +
463473
(1|dataset_ID), # random effects
464474
data = data_detail_false,
465475
family = beta_family(link = "logit"))
466476

467477
mod_detail_false_m2 <-
468478
glmmTMB(success ~ DC + position + smooth +
469-
DC:position + DC:smooth + position:smooth +
479+
DC:position + position:smooth +
470480
DC:position:smooth +
471481
(1|dataset_ID), # random effects
472482
data = data_detail_false,
473483
family = beta_family(link = "logit"))
474484

475485
mod_detail_false_m3 <-
476486
glmmTMB(success ~ DC + diversity + position + smooth +
477-
DC:diversity + DC:smooth + position:smooth +
478-
(1|dataset_ID), # random effects
479-
data = data_detail_false,
480-
family = beta_family(link = "logit"))
481-
482-
mod_detail_false_m4 <-
483-
glmmTMB(success ~ DC + diversity + position + smooth +
484-
DC:diversity + DC:position + DC:smooth + position:smooth +
485-
DC:position:smooth +
486-
(1|dataset_ID), # random effects
487-
data = data_detail_false,
488-
family = beta_family(link = "logit"))
489-
490-
mod_detail_false_m5 <-
491-
glmmTMB(success ~ DC + position + smooth +
492-
DC:position + DC:smooth + position:smooth +
493-
(1|dataset_ID), # random effects
494-
data = data_detail_false,
495-
family = beta_family(link = "logit"))
496-
497-
mod_detail_false_m6 <-
498-
glmmTMB(success ~ DC + diversity + position + smooth +
499-
DC:diversity + DC:position + DC:smooth + position:smooth +
500-
(1|dataset_ID), # random effects
501-
data = data_detail_false,
502-
family = beta_family(link = "logit"))
503-
504-
mod_detail_false_m7 <-
505-
glmmTMB(success ~ DC + diversity + position + smooth +
506-
DC:smooth + position:smooth +
507-
(1|dataset_ID), # random effects
508-
data = data_detail_false,
509-
family = beta_family(link = "logit"))
510-
511-
mod_detail_false_m8 <-
512-
glmmTMB(success ~ DC + diversity + position + smooth +
513-
DC:diversity + DC:smooth + diversity:position + position:smooth +
514-
(1|dataset_ID), # random effects
515-
data = data_detail_false,
516-
family = beta_family(link = "logit"))
517-
518-
mod_detail_false_m9 <-
519-
glmmTMB(success ~ position + smooth +
520487
position:smooth +
521488
(1|dataset_ID), # random effects
522489
data = data_detail_false,
523490
family = beta_family(link = "logit"))
524491

525-
mod_detail_false_m10 <-
526-
glmmTMB(success ~ DC + position + smooth +
527-
position:smooth +
528-
(1|dataset_ID), # random effects
529-
data = data_detail_false,
530-
family = beta_family(link = "logit"))
531492

532493

533494
mod_detail_false_final_comp <-
534495
compare_performance(
535496
mod_detail_false_m1,
536497
mod_detail_false_m2,
537498
mod_detail_false_m3,
538-
mod_detail_false_m4,
539-
mod_detail_false_m5,
540-
mod_detail_false_m6,
541-
mod_detail_false_m7,
542-
mod_detail_false_m8,
543-
mod_detail_false_m9,
544-
mod_detail_false_m10,
545499
rank = T)
546500

547501
mod_detail_false_final_comp
@@ -550,8 +504,9 @@ mod_detail_false_final_comp %>%
550504
as_tibble() %>%
551505
left_join(.,
552506
tibble(
553-
Model = paste0("mod_detail_false_m",1:10),
554-
formula = lapply(paste0("mod_detail_false_m",1:10), FUN = function(x) formula(get(x))) %>%
507+
Model = paste0("mod_detail_false_m",1:nrow(mod_detail_false_final_comp)),
508+
formula = lapply(paste0("mod_detail_false_m",1:nrow(mod_detail_false_final_comp)),
509+
FUN = function(x) formula(get(x))) %>%
555510
as.character()),
556511
by = "Model") %>%
557512
dplyr::select(formula, everything()) %>%

0 commit comments

Comments
 (0)