@@ -31,9 +31,9 @@ data_sum <-
31
31
32
32
position = factor (
33
33
position ,
34
- levels = c(" breaks_recent " , " breaks_late" )) %> %
34
+ levels = c(" breaks_early " , " breaks_late" )) %> %
35
35
fct_recode(
36
- " low density level" = " breaks_recent " ,
36
+ " low density level" = " breaks_early " ,
37
37
" high density level" = " breaks_late" ),
38
38
diversity = factor (
39
39
diversity ,
@@ -80,7 +80,6 @@ data_sum <-
80
80
RoC_setting = paste0(smooth ," - " ,DC ) %> %
81
81
as.factor())
82
82
83
-
84
83
# explore data
85
84
data_sum %> %
86
85
summary()
@@ -326,28 +325,38 @@ mod_detail_correct_dd %>%
326
325
View()
327
326
328
327
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
332
330
(1 | dataset_ID ), # random effects
333
331
data = data_detail_correct ,
334
332
family = beta_family(link = " logit" )
335
333
)
336
334
337
335
338
336
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
342
347
(1 | dataset_ID ), # random effects
343
348
data = data_detail_correct ,
344
349
family = beta_family(link = " logit" )
345
350
)
346
351
352
+
353
+
354
+
347
355
mod_detail_correct_final_comp <-
348
356
compare_performance(
349
357
mod_detail_correct_m1 ,
350
358
mod_detail_correct_m2 ,
359
+ mod_detail_correct_m3 ,
351
360
rank = T )
352
361
353
362
mod_detail_correct_final_comp
@@ -356,16 +365,17 @@ mod_detail_correct_final_comp %>%
356
365
as_tibble() %> %
357
366
left_join(. ,
358
367
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 ))) %> %
361
371
as.character()),
362
372
by = " Model" ) %> %
363
373
dplyr :: select(formula , everything()) %> %
364
374
write_csv(
365
375
. ," data/output/result_tables/mod_detail_correct_final_comp.csv" )
366
376
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
369
379
write_rds(mod_detail_correct_select ," data/output/models/mod_detail_correct_select.rds" )
370
380
371
381
# --------------------------------#
@@ -459,89 +469,33 @@ mod_detail_false_dd %>%
459
469
460
470
mod_detail_false_m1 <-
461
471
glmmTMB(success ~ DC + position + smooth +
462
- DC : smooth + position : smooth +
472
+ position : smooth +
463
473
(1 | dataset_ID ), # random effects
464
474
data = data_detail_false ,
465
475
family = beta_family(link = " logit" ))
466
476
467
477
mod_detail_false_m2 <-
468
478
glmmTMB(success ~ DC + position + smooth +
469
- DC : position + DC : smooth + position : smooth +
479
+ DC : position + position : smooth +
470
480
DC : position : smooth +
471
481
(1 | dataset_ID ), # random effects
472
482
data = data_detail_false ,
473
483
family = beta_family(link = " logit" ))
474
484
475
485
mod_detail_false_m3 <-
476
486
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 +
520
487
position : smooth +
521
488
(1 | dataset_ID ), # random effects
522
489
data = data_detail_false ,
523
490
family = beta_family(link = " logit" ))
524
491
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" ))
531
492
532
493
533
494
mod_detail_false_final_comp <-
534
495
compare_performance(
535
496
mod_detail_false_m1 ,
536
497
mod_detail_false_m2 ,
537
498
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 ,
545
499
rank = T )
546
500
547
501
mod_detail_false_final_comp
@@ -550,8 +504,9 @@ mod_detail_false_final_comp %>%
550
504
as_tibble() %> %
551
505
left_join(. ,
552
506
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 ))) %> %
555
510
as.character()),
556
511
by = " Model" ) %> %
557
512
dplyr :: select(formula , everything()) %> %
0 commit comments