Modeling
ALM
EXAM
R
Author

Thomas Gorman

Published

March 16, 2024

Code
pacman::p_load(dplyr,purrr,tidyr,ggplot2, data.table, here, patchwork, conflicted, 
               stringr,future,furrr, knitr, reactable, flextable,ggstance, htmltools,kableExtra,ggdist)
conflict_prefer_all("dplyr", quiet = TRUE)
options(scipen = 999)
walk(c("Display_Functions","fun_alm","fun_indv_fit","fun_model"), ~ source(here::here(paste0("Functions/", .x, ".R"))))

E1

Code
ds <- readRDS(here::here("data/e1_md_11-06-23.rds"))  |> as.data.table()
nbins <- 3

fd <- readRDS(here("data/e1_08-21-23.rds"))
test <- fd |> filter(expMode2 == "Test") 
testAvg <- test %>% group_by(id, condit, vb, bandInt,bandType,tOrder) %>%
  summarise(nHits=sum(dist==0),vx=mean(vx),dist=mean(dist),sdist=mean(sdist),n=n(),Percent_Hit=nHits/n)

trainAvg <- fd |> filter(expMode2 == "Train") |> group_by(id) |> 
  mutate(tr=trial,x=vb,Block=case_when(expMode2=="Train" ~ cut(tr,breaks=seq(1,max(tr), length.out=nbins+1),include.lowest=TRUE,labels=FALSE),
                                         expMode2=="Test" ~ 4)) |> 
  group_by(id,condit,vb,x,Block) |> 
  summarise(dist=mean(dist),y=mean(vx))

input_layer <<- output_layer <<-  c(100,350,600,800,1000,1200)
ids2 <- c(1,66,36)

file_name <- "e1_hybrid_n_iter_250_ntry_200_0637"

ind_fits <- map(list.files(here(paste0('data/abc_reject/'),file_name),full.names=TRUE), readRDS)
ind_fits_df <- ind_fits |> map(~list(dat=.x[[1]], Model = .x[["Model"]], Fit_Method=.x[["Fit_Method"]]))
ind_fits_df <- ind_fits_df |> map(~rbindlist(.x$dat) |> mutate(Model = .x$Model, Fit_Method = .x$Fit_Method)) |> rbindlist() 


process_folder <- function(folder_name) {
  ind_fits <- map(list.files(here(paste0('data/abc_reject/'), folder_name), 
                             full.names = TRUE), readRDS)
  ind_fits_df <- ind_fits |> 
    map(~list(dat = .x[[1]], Model = .x[["Model"]], Fit_Method = .x[["Fit_Method"]],tolM=.x$tolM,ar=.x$min_accept_rate,
              t=.x$ri$elapsed)) |> 
    map(~rbindlist(.x$dat) |> 
           mutate(Model = .x$Model, Fit_Method = .x$Fit_Method,
                 exp = str_extract(folder_name, "^e\\d"),
                 n_int = as.numeric(str_extract(folder_name, "(?<=_n_iter_)\\d+")),
                 ntry = as.numeric(str_extract(folder_name, "(?<=_ntry_)\\d+")),
                 tolM=.x$tolM,ar=.x$ar,
                 run_name = folder_name,
                 min = round(.x$t/60,0))) |> 
    rbindlist()
  return(ind_fits_df)
}

# folder_names <- c("e1_hybrid_n_iter_250_ntry_200_0637",
# "e1_hybrid_n_iter_60_ntry_150_2335",
# "e1_hybrid_n_iter_200_ntry_300_0741",
# "e1_hybrid_n_iter_150_ntry_150_4749","e1_hybrid_n_iter_100_ntry_100_1435","e1_hybrid_n_iter_400_ntry_300_3744")

folder_names <- list.files(here("data/abc_reject"),pattern="e1_hyb*")



all_fits <- map_df(folder_names, process_folder)

all_fits |> 
  group_by(exp,n_int,ntry,tolM,ar,condit,Fit_Method) |> 
  summarise(min=first(min),me=mean(mean_error),
            w=median(weight_exam),sd_w=sd(weight_exam),c=median(c),
            lr=median(lr),n=n_distinct(id)) |>
   mutate(across(c(me, w, lr, sd_w), ~round(., 2))) |>
  arrange(condit,Fit_Method,me) |> kable(caption="E1 Fit Comparisons") |> 
  kable_styling(full_width = F) |>
  column_spec(8,bold=T,border_left=T) 
E1 Fit Comparisons
exp n_int ntry tolM ar condit Fit_Method min me w sd_w c lr n
e1 150 2500 0.65 0.10 Constant Test 847 214.73 0.80 0.25 0.0000403 2.37 80
e1 100 2500 0.65 0.10 Constant Test 209 214.87 0.80 0.25 0.0000402 2.37 80
e1 200 1500 0.70 0.10 Constant Test 402 215.79 0.80 0.25 0.0000411 2.37 80
e1 50 900 0.80 0.12 Constant Test 55 217.65 0.79 0.25 0.0000433 2.32 80
e1 90 900 0.80 0.09 Constant Test 101 217.77 0.79 0.25 0.0000439 2.31 80
e1 150 500 0.95 0.10 Constant Test 112 220.00 0.79 0.25 0.0000500 2.30 80
e1 70 500 0.85 0.10 Constant Test 177 220.15 0.79 0.24 0.0000486 2.30 80
e1 400 300 0.85 0.04 Constant Test 337 220.33 0.79 0.24 0.0000491 2.28 80
e1 50 500 0.85 0.05 Constant Test 201 220.67 0.79 0.24 0.0000472 2.28 80
e1 200 300 0.90 0.10 Constant Test 129 220.96 0.79 0.24 0.0000525 2.28 80
e1 49 800 0.95 0.18 Constant Test 286 221.49 0.79 0.25 0.0000513 2.31 80
e1 61 500 0.95 0.10 Constant Test 41 221.57 0.79 0.24 0.0000552 2.30 80
e1 50 900 0.95 0.10 Constant Test 37 221.77 0.79 0.25 0.0000524 2.33 80
e1 250 200 0.85 0.10 Constant Test 176 222.09 0.78 0.24 0.0000594 2.27 80
e1 52 600 0.95 0.18 Constant Test 199 222.28 0.79 0.25 0.0000584 2.32 80
e1 65 300 0.95 0.10 Constant Test 29 223.14 0.79 0.25 0.0000602 2.26 80
e1 100 100 0.85 0.01 Constant Test 372 223.15 0.79 0.25 0.0000567 2.24 80
e1 150 150 0.85 0.10 Constant Test 72 223.85 0.78 0.24 0.0000647 2.27 80
e1 51 300 0.95 0.15 Constant Test 149 223.96 0.79 0.25 0.0000643 2.31 80
e1 60 150 0.85 0.10 Constant Test 24 224.74 0.78 0.25 0.0000670 2.28 80
e1 105 100 0.85 0.05 Constant Test 228 225.38 0.78 0.25 0.0000644 2.24 80
e1 100 100 0.90 0.10 Constant Test 162 226.26 0.79 0.25 0.0000798 2.25 80
e1 100 2500 0.65 0.10 Constant Test_Train 317 233.60 0.79 0.24 0.0000381 0.72 80
e1 200 1500 0.70 0.10 Constant Test_Train 466 234.43 0.79 0.24 0.0000388 0.72 80
e1 90 900 0.80 0.09 Constant Test_Train 120 235.49 0.78 0.25 0.0000388 0.73 80
e1 50 900 0.80 0.12 Constant Test_Train 71 235.70 0.77 0.25 0.0000388 0.71 80
e1 70 500 0.85 0.10 Constant Test_Train 173 237.28 0.77 0.25 0.0000401 0.76 80
e1 150 500 0.95 0.10 Constant Test_Train 138 237.33 0.78 0.25 0.0000400 0.75 80
e1 50 500 0.85 0.05 Constant Test_Train 217 237.64 0.78 0.25 0.0000401 0.77 80
e1 400 300 0.85 0.04 Constant Test_Train 475 237.70 0.77 0.25 0.0000409 0.79 80
e1 49 800 0.95 0.18 Constant Test_Train 263 238.08 0.78 0.25 0.0000400 0.79 80
e1 200 300 0.90 0.10 Constant Test_Train 153 238.15 0.77 0.25 0.0000413 0.82 80
e1 50 900 0.95 0.10 Constant Test_Train 38 238.19 0.78 0.25 0.0000398 0.79 80
e1 52 600 0.95 0.18 Constant Test_Train 210 238.88 0.77 0.25 0.0000395 0.82 80
e1 250 200 0.85 0.10 Constant Test_Train 183 239.01 0.77 0.25 0.0000429 0.83 80
e1 61 500 0.95 0.10 Constant Test_Train 46 239.02 0.77 0.25 0.0000410 0.81 80
e1 100 100 0.85 0.01 Constant Test_Train 465 239.10 0.77 0.25 0.0000429 0.83 80
e1 65 300 0.95 0.10 Constant Test_Train 28 239.92 0.77 0.25 0.0000423 0.82 80
e1 150 150 0.85 0.10 Constant Test_Train 89 240.04 0.77 0.25 0.0000453 0.84 80
e1 60 150 0.85 0.10 Constant Test_Train 17 240.55 0.76 0.25 0.0000466 0.83 80
e1 51 300 0.95 0.15 Constant Test_Train 137 240.77 0.77 0.25 0.0000424 0.87 80
e1 105 100 0.85 0.05 Constant Test_Train 212 241.24 0.76 0.26 0.0000480 0.91 80
e1 100 100 0.90 0.10 Constant Test_Train 194 242.04 0.76 0.25 0.0000519 0.94 80
e1 100 100 0.90 0.10 Constant Train 30 211.21 0.50 0.29 0.0000284 2.00 135
e1 200 300 0.90 0.10 Constant Train 146 220.24 0.50 0.29 0.0001014 2.08 80
e1 70 500 0.85 0.10 Constant Train 84 220.80 0.48 0.29 0.0001000 2.09 80
e1 50 500 0.85 0.05 Constant Train 91 221.54 0.50 0.29 0.0000965 2.08 80
e1 60 150 0.85 0.10 Constant Train 32 221.76 0.50 0.29 0.0000750 1.38 80
e1 52 600 0.95 0.18 Constant Train 84 224.05 0.50 0.29 0.0001002 2.01 80
e1 150 2500 0.65 0.10 Varied Test 847 217.30 0.72 0.27 0.0000745 3.16 76
e1 100 2500 0.65 0.10 Varied Test 209 217.57 0.72 0.27 0.0000807 3.11 76
e1 200 1500 0.70 0.10 Varied Test 402 219.21 0.71 0.27 0.0000771 3.09 76
e1 90 900 0.80 0.09 Varied Test 101 222.25 0.71 0.27 0.0000799 3.03 76
e1 50 900 0.80 0.12 Varied Test 55 222.79 0.71 0.27 0.0000727 2.98 76
e1 70 500 0.85 0.10 Varied Test 177 225.34 0.70 0.27 0.0000810 2.87 76
e1 150 500 0.95 0.10 Varied Test 112 225.47 0.70 0.27 0.0000810 2.89 76
e1 50 900 0.95 0.10 Varied Test 37 226.30 0.70 0.27 0.0000811 2.89 76
e1 400 300 0.85 0.04 Varied Test 337 226.51 0.69 0.27 0.0000845 2.84 76
e1 50 500 0.85 0.05 Varied Test 201 226.53 0.70 0.27 0.0000860 2.86 76
e1 49 800 0.95 0.18 Varied Test 286 226.86 0.69 0.27 0.0000783 2.95 76
e1 61 500 0.95 0.10 Varied Test 41 227.08 0.69 0.27 0.0000855 2.81 76
e1 200 300 0.90 0.10 Varied Test 129 227.66 0.69 0.27 0.0000844 2.82 76
e1 52 600 0.95 0.18 Varied Test 199 227.96 0.69 0.27 0.0000787 2.84 76
e1 250 200 0.85 0.10 Varied Test 176 229.83 0.68 0.27 0.0000894 2.71 76
e1 100 100 0.85 0.01 Varied Test 372 230.20 0.68 0.27 0.0000877 2.71 76
e1 65 300 0.95 0.10 Varied Test 29 231.00 0.67 0.26 0.0000874 2.71 76
e1 51 300 0.95 0.15 Varied Test 149 231.32 0.68 0.27 0.0000827 2.78 76
e1 150 150 0.85 0.10 Varied Test 72 231.85 0.68 0.27 0.0000879 2.57 76
e1 60 150 0.85 0.10 Varied Test 24 234.05 0.66 0.27 0.0000959 2.54 76
e1 105 100 0.85 0.05 Varied Test 228 234.81 0.67 0.27 0.0000966 2.51 76
e1 100 100 0.90 0.10 Varied Test 162 235.56 0.66 0.27 0.0000958 2.48 76
e1 100 2500 0.65 0.10 Varied Test_Train 317 290.40 0.54 0.27 0.0000764 0.99 76
e1 200 1500 0.70 0.10 Varied Test_Train 466 291.65 0.54 0.27 0.0000776 0.84 76
e1 90 900 0.80 0.09 Varied Test_Train 120 293.35 0.55 0.27 0.0000747 0.78 76
e1 50 900 0.80 0.12 Varied Test_Train 71 293.77 0.56 0.27 0.0000750 0.76 76
e1 70 500 0.85 0.10 Varied Test_Train 173 295.56 0.55 0.27 0.0000752 0.73 76
e1 49 800 0.95 0.18 Varied Test_Train 263 295.63 0.55 0.26 0.0000721 0.78 76
e1 50 500 0.85 0.05 Varied Test_Train 217 295.74 0.56 0.27 0.0000708 0.71 76
e1 50 900 0.95 0.10 Varied Test_Train 38 295.80 0.55 0.26 0.0000748 0.79 76
e1 150 500 0.95 0.10 Varied Test_Train 138 295.84 0.55 0.27 0.0000732 0.75 76
e1 52 600 0.95 0.18 Varied Test_Train 210 296.14 0.56 0.26 0.0000705 0.76 76
e1 400 300 0.85 0.04 Varied Test_Train 475 296.24 0.56 0.26 0.0000720 0.74 76
e1 61 500 0.95 0.10 Varied Test_Train 46 296.78 0.56 0.27 0.0000710 0.78 76
e1 200 300 0.90 0.10 Varied Test_Train 153 296.83 0.56 0.27 0.0000713 0.72 76
e1 100 100 0.85 0.01 Varied Test_Train 465 297.79 0.55 0.27 0.0000734 0.75 76
e1 250 200 0.85 0.10 Varied Test_Train 183 298.19 0.55 0.27 0.0000712 0.71 76
e1 65 300 0.95 0.10 Varied Test_Train 28 298.71 0.56 0.26 0.0000735 0.74 76
e1 150 150 0.85 0.10 Varied Test_Train 89 299.31 0.56 0.26 0.0000700 0.71 76
e1 51 300 0.95 0.15 Varied Test_Train 137 299.59 0.55 0.26 0.0000738 0.72 76
e1 60 150 0.85 0.10 Varied Test_Train 17 300.04 0.56 0.26 0.0000687 0.69 76
e1 105 100 0.85 0.05 Varied Test_Train 212 300.51 0.56 0.26 0.0000690 0.69 76
e1 100 100 0.90 0.10 Varied Test_Train 194 301.28 0.56 0.27 0.0000667 0.70 76
e1 100 100 0.90 0.10 Varied Train 30 265.62 0.50 0.29 0.0000226 0.92 131
e1 70 500 0.85 0.10 Varied Train 84 312.06 0.49 0.29 0.0000266 1.51 76
e1 50 500 0.85 0.05 Varied Train 91 312.34 0.51 0.28 0.0000261 1.38 76
e1 200 300 0.90 0.10 Varied Train 146 313.11 0.50 0.29 0.0000260 1.40 76
e1 52 600 0.95 0.18 Varied Train 84 314.91 0.49 0.29 0.0000267 1.40 76
e1 60 150 0.85 0.10 Varied Train 32 315.65 0.49 0.29 0.0000259 1.14 76
Code
all_fits |> 
  filter(id %in% unique(all_fits$id)[1:2]) |>
  group_by(id,exp,n_int,ntry,condit,Fit_Method) |> 
  mutate(rank=rank(mean_error)) |> filter(rank<n_int*.90) |>
  group_by(id,exp,n_int,ntry,condit,Fit_Method) |> 
  summarise(me=mean(mean_error),w=median(weight_exam),sd_w=sd(weight_exam),c=median(c),lr=median(lr)) |>
  arrange(id,condit,Fit_Method,me) |> 
    kbl() |> kable_styling(full_width = F)
id exp n_int ntry condit Fit_Method me w sd_w c lr
1 e1 100 2500 Varied Test 223.5378 0.8182305 0.2035620 0.0000019 5.2816922
1 e1 150 2500 Varied Test 223.5554 0.8585789 0.1787275 0.0000022 5.1924980
1 e1 50 900 Varied Test 223.6162 0.7473703 0.1897786 0.0000019 5.2693800
1 e1 150 500 Varied Test 224.6697 0.8149536 0.1970840 0.0000020 5.1997612
1 e1 200 1500 Varied Test 225.4042 0.7649556 0.2123507 0.0000019 5.2531997
1 e1 90 900 Varied Test 226.6014 0.7998805 0.2525561 0.0000020 5.1910494
1 e1 100 100 Varied Test 228.0284 0.8293703 0.2262617 0.0000023 5.1435685
1 e1 70 500 Varied Test 230.9324 0.8355013 0.2819217 0.0000020 5.1279383
1 e1 400 300 Varied Test 231.2286 0.8104574 0.2420737 0.0000023 5.1076418
1 e1 200 300 Varied Test 232.2169 0.8051852 0.2395735 0.0000023 5.0557794
1 e1 50 500 Varied Test 232.5206 0.8222143 0.2435945 0.0000021 5.0075482
1 e1 52 600 Varied Test 233.0113 0.8626639 0.1970062 0.0000830 2.6120010
1 e1 49 800 Varied Test 233.2076 0.8204706 0.1984141 0.0000023 5.0773731
1 e1 250 200 Varied Test 233.5362 0.7986295 0.2476705 0.0000021 5.0901121
1 e1 61 500 Varied Test 233.7241 0.8264059 0.2336978 0.0000023 5.0624427
1 e1 60 150 Varied Test 235.2363 0.7849864 0.2606166 0.0000024 5.0587135
1 e1 65 300 Varied Test 236.8494 0.7526598 0.2464510 0.0000021 5.1046996
1 e1 51 300 Varied Test 236.8643 0.8326864 0.2732785 0.0000668 4.6356408
1 e1 150 150 Varied Test 238.8422 0.8057119 0.2588631 0.0000046 4.8535159
1 e1 105 100 Varied Test 240.9037 0.7794698 0.2547383 0.0001021 1.8109660
1 e1 100 2500 Varied Test_Train 291.1208 0.4982487 0.2149724 0.0000627 0.1050512
1 e1 90 900 Varied Test_Train 291.8641 0.4633852 0.1755527 0.0000643 0.1239611
1 e1 200 1500 Varied Test_Train 292.0506 0.4656865 0.1840448 0.0000650 0.1342331
1 e1 50 900 Varied Test_Train 292.7664 0.4828479 0.2012370 0.0000584 0.0823038
1 e1 150 500 Varied Test_Train 293.0012 0.4539042 0.1576420 0.0000639 0.1014355
1 e1 70 500 Varied Test_Train 294.7952 0.4768128 0.1804256 0.0000711 0.1343180
1 e1 400 300 Varied Test_Train 294.8046 0.4961300 0.1948949 0.0000650 0.1460962
1 e1 50 500 Varied Test_Train 294.8834 0.4763972 0.1708669 0.0000729 0.1072454
1 e1 49 800 Varied Test_Train 295.0383 0.4812279 0.1352303 0.0000736 0.1449286
1 e1 100 100 Varied Test_Train 295.4118 0.4917216 0.1817776 0.0000666 0.1636531
1 e1 52 600 Varied Test_Train 295.4456 0.4399127 0.1818114 0.0000624 0.0987222
1 e1 200 300 Varied Test_Train 295.9199 0.4870067 0.2079155 0.0000664 0.1371202
1 e1 250 200 Varied Test_Train 296.5507 0.4909003 0.1756808 0.0000672 0.1867037
1 e1 105 100 Varied Test_Train 297.3157 0.4826085 0.1881216 0.0000674 0.2043142
1 e1 51 300 Varied Test_Train 297.3525 0.4793596 0.2287758 0.0000671 0.2355805
1 e1 61 500 Varied Test_Train 297.3594 0.4408326 0.1632677 0.0000699 0.1775518
1 e1 60 150 Varied Test_Train 297.5422 0.5341098 0.1860066 0.0000555 0.1508889
1 e1 150 150 Varied Test_Train 298.1399 0.5021449 0.1864520 0.0000740 0.1710864
1 e1 65 300 Varied Test_Train 300.3247 0.4955346 0.1788877 0.0000656 0.2270260
1 e1 200 300 Varied Train 301.0392 0.4510923 0.2769286 0.0000187 8.0239746
1 e1 70 500 Varied Train 301.9224 0.5754325 0.2973605 0.0000418 7.9297719
1 e1 50 500 Varied Train 302.6788 0.5817460 0.2974083 0.0000424 8.1026574
1 e1 60 150 Varied Train 305.4690 0.4887447 0.2976968 0.0000476 7.9030316
1 e1 52 600 Varied Train 306.0869 0.4761011 0.3128097 0.0000496 7.8344141
1 e1 100 100 Varied Train 306.6696 0.5408164 0.2728925 0.0000464 7.8161855
2 e1 100 2500 Varied Test 369.8400 0.5863439 0.2981269 0.0000348 4.0355545
2 e1 150 2500 Varied Test 369.8738 0.5306497 0.3050162 0.0000338 5.0224378
2 e1 150 500 Varied Test 370.1960 0.5485465 0.2928199 0.0000335 5.0353815
2 e1 50 900 Varied Test 370.5906 0.4917389 0.2895874 0.0000317 5.1695962
2 e1 200 1500 Varied Test 371.4073 0.4989873 0.2888450 0.0000336 5.0766927
2 e1 90 900 Varied Test 374.1310 0.5857368 0.2691902 0.0000345 4.9535572
2 e1 100 100 Varied Test 374.7765 0.5144509 0.2778470 0.0000341 4.7317420
2 e1 49 800 Varied Test 376.1818 0.4814195 0.3264464 0.0000352 4.4422502
2 e1 61 500 Varied Test 376.4798 0.6001896 0.2867825 0.0000353 4.0377088
2 e1 400 300 Varied Test 377.7010 0.4745654 0.2921842 0.0000345 4.0564093
2 e1 50 500 Varied Test 377.7084 0.4700296 0.2752379 0.0000385 4.0132306
2 e1 200 300 Varied Test 377.9897 0.4644357 0.3013704 0.0000351 4.1080690
2 e1 70 500 Varied Test 378.6938 0.5585721 0.3168538 0.0000356 4.0292617
2 e1 51 300 Varied Test 380.1584 0.4959267 0.2805370 0.0000381 4.0102128
2 e1 65 300 Varied Test 381.2897 0.4558618 0.3250864 0.0000353 4.0229159
2 e1 52 600 Varied Test 381.8625 0.6456892 0.3142880 0.0000380 3.9758295
2 e1 250 200 Varied Test 382.6800 0.5574183 0.2947822 0.0000368 4.0376555
2 e1 105 100 Varied Test 386.5428 0.4663750 0.3017272 0.0000374 4.1107081
2 e1 150 150 Varied Test 386.6443 0.5275578 0.3094980 0.0000363 4.0164842
2 e1 60 150 Varied Test 387.5823 0.4715924 0.3332044 0.0000386 4.0013609
2 e1 50 900 Varied Test_Train 428.1180 0.4978363 0.2970980 0.0000385 4.9800328
2 e1 150 500 Varied Test_Train 429.5278 0.4630116 0.2978593 0.0000375 4.9235301
2 e1 100 2500 Varied Test_Train 429.7416 0.4441688 0.2806442 0.0000385 4.8920111
2 e1 200 1500 Varied Test_Train 432.2028 0.4870858 0.2860881 0.0000373 4.8960848
2 e1 49 800 Varied Test_Train 436.2951 0.3925758 0.2483927 0.0000358 4.9014996
2 e1 100 100 Varied Test_Train 438.4416 0.4760461 0.3051119 0.0000351 4.8056798
2 e1 90 900 Varied Test_Train 439.2872 0.5689515 0.3051232 0.0000354 4.9116788
2 e1 52 600 Varied Test_Train 441.2831 0.5517423 0.3000017 0.0000357 4.6911650
2 e1 61 500 Varied Test_Train 441.9809 0.4955319 0.2817430 0.0000361 4.9272707
2 e1 70 500 Varied Test_Train 442.1006 0.6065832 0.3080914 0.0000364 4.9111936
2 e1 65 300 Varied Test_Train 443.6291 0.4970180 0.2848160 0.0000341 4.8086849
2 e1 400 300 Varied Test_Train 444.0730 0.5335898 0.2966844 0.0000351 4.9310083
2 e1 50 500 Varied Test_Train 444.9344 0.5975558 0.2789440 0.0000351 4.7531000
2 e1 200 300 Varied Test_Train 445.7221 0.4626835 0.2983041 0.0000358 4.9009381
2 e1 51 300 Varied Test_Train 448.7055 0.3941551 0.2908179 0.0000349 4.9279146
2 e1 250 200 Varied Test_Train 451.1523 0.4805013 0.2915747 0.0000357 4.8348896
2 e1 60 150 Varied Test_Train 455.9307 0.4307338 0.2992679 0.0000349 4.9789964
2 e1 150 150 Varied Test_Train 456.8058 0.6124759 0.3025009 0.0000359 4.7546298
2 e1 105 100 Varied Test_Train 457.5066 0.5686353 0.2888873 0.0000361 4.7358573
2 e1 200 300 Varied Train 445.4326 0.4992835 0.2903908 0.0000143 1.2852145
2 e1 50 500 Varied Train 446.0390 0.4863962 0.2996348 0.0000139 1.2527575
2 e1 52 600 Varied Train 446.2512 0.4010491 0.2681370 0.0000138 1.2558990
2 e1 70 500 Varied Train 446.4922 0.4650381 0.2920932 0.0000139 1.2373839
2 e1 60 150 Varied Train 447.9030 0.5259795 0.2935894 0.0000131 1.1056549
2 e1 100 100 Varied Train 448.5521 0.4988236 0.2767507 0.0000149 1.0656699
Code
k = all_fits |> 
    filter(id %in% unique(all_fits$id)[1])  |>
  group_by(Fit_Method) |> arrange(mean_error)

id_mdif <- all_fits |> 
    group_by(id,condit,Fit_Method,run_name) |> 
  mutate(rank=rank(mean_error)) |>
  summarize(n=n(),all_me=mean(mean_error),
            p50=mean(mean_error[rank<n*.50]),
         top10 = mean(mean_error[rank<10])) 

id_wdif <- all_fits |> 
    group_by(id,condit,Fit_Method,run_name) |> 
  mutate(rank=rank(mean_error)) |>
  summarize(n=n(),all_we=mean(weight_exam),
            p50=mean(weight_exam[rank<n*.50]),
         top10 = mean(weight_exam[rank<10])) |>
  mutate(dif=all_we-top10,adif=abs(dif)) |> arrange(adif)

id_wdifAll <- all_fits |> 
    group_by(id,condit,Fit_Method) |> 
  mutate(rank=rank(mean_error)) |>
  summarize(n=n(),all_we=median(weight_exam),
            p50=median(weight_exam[rank<n*.50]),
         top10 = median(weight_exam[rank<30])) |>
  mutate(dif=all_we-top10,adif=abs(dif)) |> arrange(-adif)
Code
# ind_fits_df |> group_by(id,condit,Fit_Method) |> summarise(w=median(weight_exam),me=mean(mean_error))
# 
# ind_fits_df |> group_by(id,condit,Fit_Method) |> summarise(we=median(weight_exam),me=mean(mean_error)) |>
#   group_by(condit,Fit_Method) |> summarise(w=mean(we),sd_w=sd(we),me=mean(me)) 
# 
# ind_fits_df |> 
#   group_by(condit,Fit_Method) |> 
#   summarise(w=median(weight_exam),sd_w=sd(weight_exam),me=mean(mean_error)) 

{all_fits |> 
   filter(Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +geom_density(alpha=.5) } /{

all_fits |> 
   filter(Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +geom_density(alpha=.5) +
  facet_wrap(~run_name)
    }

Code
all_fits |> ggplot(aes(x=condit,y=weight_exam,col=condit)) + stat_pointinterval() +
  facet_wrap(~Fit_Method)

Code
all_fits |> ggplot(aes(x=run_name,y=weight_exam,col=condit)) + stat_pointinterval() +
  facet_wrap(condit~Fit_Method)

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +
  geom_density() +
  geom_vline(xintercept = .5,linetype="dashed") +
  ggh4x::facet_wrap2(~id+condit, scales="free_y")

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test_Train") |>
    ggplot(aes(x=weight_exam,fill=condit)) +
  geom_density() +
  geom_vline(xintercept = .5,linetype="dashed") +
  ggh4x::facet_wrap2(~id+condit, scales="free_y")

Code
all_fits |> 
    group_by(id,run_name,condit,Fit_Method) |> 
  mutate(rank=rank(mean_error)) |> 
  filter(rank<n_int*.50) |>
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +
  geom_density() +
  geom_vline(xintercept = .5,linetype="dashed") +
  ggh4x::facet_wrap2(~id+condit, scales="free_y")

Code
all_fits |> 
  group_by(id,condit,Fit_Method) |>
  mutate(we_med=median(weight_exam),
         Best_Model=case_when(we_med>.5 ~"EXAM",we_med<.5 ~"ALM")) |>
  filter(Fit_Method=="Test") |>
  ungroup() |>
  mutate(id=reorder(id,we_med,decreasing = TRUE)) |>
  ggplot(aes(x=weight_exam,y=id,col=Best_Model)) + 
  geom_vline(xintercept = .5,linetype="dashed") +
  stat_pointinterval() + 
  ggh4x::facet_grid2(~condit,axes="all",scales="free_y", independent = "y")+
  theme_minimal() +
  theme(legend.position="top")

Code
all_fits |> 
  filter(Fit_Method=="Test") |>
    group_by(id,run_name,condit,Fit_Method) |> 
  mutate(rank=rank(mean_error)) |> 
  filter(rank<n_int*.50) |>
  group_by(id,condit,Fit_Method,run_name) |>
  mutate(we_med=median(weight_exam),
         Best_Model=case_when(we_med>.5 ~"EXAM",we_med<.5 ~"ALM")) |>
  ungroup() |>
  group_by(run_name) |>
    mutate(id=reorder(id,we_med,decreasing = FALSE)) |>
  ggplot(aes(x=weight_exam,y=id,col=Best_Model)) + 
  geom_vline(xintercept = .5,linetype="dashed") +
  stat_pointinterval() + 
  ggh4x::facet_grid2(run_name~condit,axes="all",scales="free_y", independent = "y")+
  theme_minimal() +
  theme(legend.position="top")

Code
all_fits |> ggplot(aes(x=condit,y=weight_exam,col=run_name)) + 
  stat_pointinterval(position=position_dodge(.5)) +
  facet_wrap(condit~Fit_Method)

Code
all_fits |> 
   filter(Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +geom_density(alpha=.5) 

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test") |>
  ggplot(aes(x=run_name,y=weight_exam,col=run_name)) + 
  stat_pointinterval(position=position_dodge(.5)) +
  ggh4x::facet_wrap2(~id+condit) + 
  theme(axis.text.x = element_blank()) 

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test_Train") |>
  ggplot(aes(x=run_name,y=weight_exam,col=run_name)) + 
  stat_pointinterval(position=position_dodge(.5)) +
  ggh4x::facet_wrap2(~id+condit) + 
  theme(axis.text.x = element_blank()) 

E2

Code
# folder_names <- c("e2_hybrid_n_iter_60_ntry_150_3658","e2_hybrid_n_iter_250_ntry_200_0540","e2_hybrid_n_iter_150_ntry_150_2904","e2_hybrid_n_iter_100_ntry_100_3211")

folder_names <- list.files(here("data/abc_reject"),pattern="e2_hyb*")


all_fits <- map_df(folder_names, process_folder)

all_fits |> 
  group_by(exp,n_int,ntry,tolM,ar,condit,Fit_Method) |> 
  summarise(min=first(min),me=mean(mean_error),
            w=median(weight_exam),sd_w=sd(weight_exam),c=median(c),
            lr=median(lr),n=n_distinct(id)) |>
   mutate(across(c(me, w, lr, sd_w), ~round(., 2))) |>
  arrange(condit,Fit_Method,me) |> kable(caption="E2 Fit Comparisons") |> 
  kable_styling(full_width = F) |>
  column_spec(8,bold=T,border_left=T) 
E2 Fit Comparisons
exp n_int ntry tolM ar condit Fit_Method min me w sd_w c lr n
e2 100 2500 0.65 0.10 Constant Test 171 221.67 0.89 0.21 0.0000892 1.82 55
e2 200 1500 0.70 0.10 Constant Test 268 222.80 0.88 0.21 0.0000989 1.82 55
e2 90 900 0.80 0.09 Constant Test 68 224.39 0.87 0.22 0.0001410 1.84 55
e2 50 900 0.80 0.12 Constant Test 33 225.12 0.87 0.22 0.0001354 1.82 55
e2 70 500 0.85 0.10 Constant Test 87 227.01 0.86 0.22 0.0001926 1.86 55
e2 150 500 0.95 0.10 Constant Test 81 227.14 0.86 0.22 0.0001649 1.82 55
e2 400 300 0.85 0.04 Constant Test 249 227.22 0.86 0.22 0.0001926 1.85 55
e2 50 500 0.85 0.05 Constant Test 108 227.28 0.86 0.22 0.0001984 1.84 55
e2 50 900 0.95 0.10 Constant Test 32 228.36 0.86 0.23 0.0001890 1.84 55
e2 52 600 0.95 0.18 Constant Test 118 228.78 0.86 0.22 0.0002007 1.87 55
e2 61 500 0.95 0.10 Constant Test 24 228.91 0.85 0.22 0.0002036 1.89 55
e2 49 800 0.95 0.18 Constant Test 139 228.94 0.86 0.22 0.0001620 1.84 55
e2 250 200 0.85 0.10 Constant Test 74 229.10 0.86 0.22 0.0002492 1.88 55
e2 100 100 0.85 0.01 Constant Test 225 229.42 0.86 0.22 0.0002304 1.85 55
e2 65 300 0.95 0.10 Constant Test 15 230.22 0.86 0.22 0.0002432 1.88 55
e2 150 150 0.85 0.10 Constant Test 57 230.44 0.85 0.23 0.0002646 1.87 55
e2 51 300 0.95 0.15 Constant Test 81 231.20 0.84 0.23 0.0002761 1.87 55
e2 60 150 0.85 0.10 Constant Test 12 231.32 0.84 0.23 0.0003111 1.90 55
e2 105 100 0.85 0.05 Constant Test 126 232.04 0.85 0.22 0.0003055 1.87 55
e2 100 100 0.85 0.10 Constant Test 92 232.82 0.84 0.22 0.0003746 1.94 55
e2 100 2500 0.65 0.10 Constant Test_Train 172 221.92 0.84 0.24 0.0000962 0.38 55
e2 200 1500 0.70 0.10 Constant Test_Train 301 222.68 0.84 0.24 0.0001096 0.42 55
e2 90 900 0.80 0.09 Constant Test_Train 62 223.95 0.84 0.24 0.0001247 0.48 55
e2 50 900 0.80 0.12 Constant Test_Train 39 224.60 0.84 0.23 0.0001343 0.53 55
e2 400 300 0.85 0.04 Constant Test_Train 191 225.77 0.83 0.24 0.0001481 0.69 55
e2 70 500 0.85 0.10 Constant Test_Train 95 225.87 0.82 0.24 0.0001523 0.67 55
e2 50 500 0.85 0.05 Constant Test_Train 118 225.89 0.83 0.24 0.0001450 0.64 55
e2 150 500 0.95 0.10 Constant Test_Train 74 225.96 0.82 0.24 0.0001472 0.66 55
e2 100 100 0.85 0.01 Constant Test_Train 236 227.13 0.82 0.24 0.0001532 0.74 55
e2 250 200 0.85 0.10 Constant Test_Train 83 227.25 0.82 0.24 0.0001663 0.88 55
e2 49 800 0.95 0.18 Constant Test_Train 152 227.38 0.83 0.24 0.0001500 0.76 55
e2 50 900 0.95 0.10 Constant Test_Train 31 227.49 0.81 0.25 0.0001571 0.69 55
e2 52 600 0.95 0.18 Constant Test_Train 130 227.65 0.82 0.24 0.0001712 0.80 55
e2 61 500 0.95 0.10 Constant Test_Train 23 227.79 0.81 0.24 0.0001700 0.89 55
e2 150 150 0.85 0.10 Constant Test_Train 52 227.94 0.82 0.24 0.0001829 1.03 55
e2 105 100 0.85 0.05 Constant Test_Train 124 228.84 0.82 0.24 0.0002131 1.22 55
e2 51 300 0.95 0.15 Constant Test_Train 90 228.86 0.82 0.24 0.0001958 1.20 55
e2 60 150 0.85 0.10 Constant Test_Train 15 228.86 0.81 0.24 0.0002271 1.66 55
e2 65 300 0.95 0.10 Constant Test_Train 18 229.04 0.81 0.24 0.0001718 0.96 55
e2 100 100 0.85 0.10 Constant Test_Train 91 229.41 0.82 0.24 0.0002158 1.61 55
e2 50 500 0.85 0.05 Constant Train 36 193.84 0.50 0.29 0.0000033 2.43 55
e2 70 500 0.85 0.10 Constant Train 28 193.88 0.50 0.29 0.0000030 2.40 55
e2 100 100 0.85 0.10 Constant Train 31 194.16 0.49 0.29 0.0000028 2.33 55
e2 60 150 0.85 0.10 Constant Train 5 194.66 0.51 0.29 0.0000032 2.35 55
e2 52 600 0.95 0.18 Constant Train 31 196.66 0.50 0.29 0.0000037 2.45 55
e2 100 2500 0.65 0.10 Varied Test 171 208.73 0.87 0.26 0.0001168 1.95 55
e2 200 1500 0.70 0.10 Varied Test 268 209.95 0.86 0.26 0.0001098 1.95 55
e2 90 900 0.80 0.09 Varied Test 68 211.50 0.85 0.27 0.0001103 1.89 55
e2 50 900 0.80 0.12 Varied Test 33 212.52 0.85 0.26 0.0000967 1.87 55
e2 150 500 0.95 0.10 Varied Test 81 214.26 0.84 0.26 0.0001105 1.88 55
e2 50 500 0.85 0.05 Varied Test 108 214.52 0.85 0.27 0.0000934 1.83 55
e2 400 300 0.85 0.04 Varied Test 249 214.62 0.84 0.26 0.0001073 1.87 55
e2 70 500 0.85 0.10 Varied Test 87 214.71 0.84 0.27 0.0001021 1.88 55
e2 50 900 0.95 0.10 Varied Test 32 215.29 0.84 0.27 0.0000970 1.90 55
e2 52 600 0.95 0.18 Varied Test 118 215.97 0.84 0.26 0.0001130 1.93 55
e2 49 800 0.95 0.18 Varied Test 139 216.30 0.84 0.26 0.0001029 1.90 55
e2 61 500 0.95 0.10 Varied Test 24 216.51 0.84 0.27 0.0001072 1.91 55
e2 250 200 0.85 0.10 Varied Test 74 216.66 0.83 0.26 0.0001020 1.87 55
e2 100 100 0.85 0.01 Varied Test 225 217.90 0.82 0.27 0.0000965 1.85 55
e2 150 150 0.85 0.10 Varied Test 57 217.98 0.83 0.27 0.0001039 1.85 55
e2 65 300 0.95 0.10 Varied Test 15 218.08 0.83 0.27 0.0000977 1.90 55
e2 51 300 0.95 0.15 Varied Test 81 219.08 0.83 0.27 0.0001295 1.85 55
e2 60 150 0.85 0.10 Varied Test 12 219.11 0.83 0.26 0.0001021 1.83 55
e2 105 100 0.85 0.05 Varied Test 126 219.59 0.82 0.26 0.0001012 1.82 55
e2 100 100 0.85 0.10 Varied Test 92 220.43 0.81 0.26 0.0001067 1.81 55
e2 100 2500 0.65 0.10 Varied Test_Train 172 219.33 0.89 0.30 0.0000330 0.60 55
e2 200 1500 0.70 0.10 Varied Test_Train 301 220.15 0.88 0.29 0.0000330 0.62 55
e2 50 900 0.80 0.12 Varied Test_Train 39 221.27 0.87 0.29 0.0000316 0.62 55
e2 90 900 0.80 0.09 Varied Test_Train 62 221.29 0.86 0.29 0.0000305 0.64 55
e2 70 500 0.85 0.10 Varied Test_Train 95 222.78 0.85 0.29 0.0000291 0.67 55
e2 150 500 0.95 0.10 Varied Test_Train 74 223.03 0.85 0.28 0.0000292 0.67 55
e2 50 500 0.85 0.05 Varied Test_Train 118 223.40 0.85 0.28 0.0000289 0.67 55
e2 400 300 0.85 0.04 Varied Test_Train 191 223.41 0.84 0.28 0.0000281 0.68 55
e2 50 900 0.95 0.10 Varied Test_Train 31 223.58 0.86 0.29 0.0000299 0.71 55
e2 61 500 0.95 0.10 Varied Test_Train 23 223.86 0.84 0.28 0.0000292 0.70 55
e2 49 800 0.95 0.18 Varied Test_Train 152 224.02 0.85 0.28 0.0000329 0.69 55
e2 52 600 0.95 0.18 Varied Test_Train 130 224.57 0.85 0.28 0.0000307 0.68 55
e2 250 200 0.85 0.10 Varied Test_Train 83 224.70 0.82 0.28 0.0000269 0.71 55
e2 100 100 0.85 0.01 Varied Test_Train 236 224.85 0.83 0.28 0.0000274 0.70 55
e2 65 300 0.95 0.10 Varied Test_Train 18 225.46 0.83 0.28 0.0000273 0.72 55
e2 150 150 0.85 0.10 Varied Test_Train 52 225.70 0.81 0.28 0.0000255 0.73 55
e2 51 300 0.95 0.15 Varied Test_Train 90 226.28 0.83 0.28 0.0000276 0.74 55
e2 105 100 0.85 0.05 Varied Test_Train 124 226.63 0.80 0.28 0.0000251 0.72 55
e2 60 150 0.85 0.10 Varied Test_Train 15 226.77 0.80 0.28 0.0000256 0.76 55
e2 100 100 0.85 0.10 Varied Test_Train 91 227.37 0.79 0.27 0.0000253 0.77 55
e2 70 500 0.85 0.10 Varied Train 28 192.05 0.50 0.29 0.0000191 0.68 55
e2 50 500 0.85 0.05 Varied Train 36 193.06 0.50 0.29 0.0000194 0.69 55
e2 100 100 0.85 0.10 Varied Train 31 193.62 0.51 0.29 0.0000190 0.70 55
e2 60 150 0.85 0.10 Varied Train 5 193.70 0.50 0.29 0.0000190 0.70 55
e2 52 600 0.95 0.18 Varied Train 31 195.83 0.51 0.29 0.0000198 0.71 55
Code
{all_fits |> 
   filter(Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +geom_density(alpha=.5) } /{

all_fits |> 
   filter(Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +geom_density(alpha=.5) +
  facet_wrap(~run_name)
    }

Code
all_fits |> ggplot(aes(x=condit,y=weight_exam,col=condit)) + stat_pointinterval() +
  facet_wrap(~Fit_Method)

Code
all_fits |> ggplot(aes(x=run_name,y=weight_exam,col=condit)) + stat_pointinterval() +
  facet_wrap(condit~Fit_Method)

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +
  geom_density() +
  geom_vline(xintercept = .5,linetype="dashed") +
  ggh4x::facet_wrap2(~id+condit, scales="free_y")

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test_Train") |>
    ggplot(aes(x=weight_exam,fill=condit)) +
  geom_density() +
  geom_vline(xintercept = .5,linetype="dashed") +
  ggh4x::facet_wrap2(~id+condit, scales="free_y")

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test") |>
  ggplot(aes(x=run_name,y=weight_exam,col=run_name)) + 
  stat_pointinterval(position=position_dodge(.5)) +
  ggh4x::facet_wrap2(~id+condit) + 
  theme(axis.text.x = element_blank()) 

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test_Train") |>
  ggplot(aes(x=run_name,y=weight_exam,col=run_name)) + 
  stat_pointinterval(position=position_dodge(.5)) +
  ggh4x::facet_wrap2(~id+condit) + 
  theme(axis.text.x = element_blank()) 

Code
all_fits |> 
  group_by(id,condit,Fit_Method) |>
  mutate(we_med=median(weight_exam),
         Best_Model=case_when(we_med>.5 ~"EXAM",we_med<.5 ~"ALM")) |>
  filter(Fit_Method=="Test") |>
  ungroup() |>
  mutate(id=reorder(id,we_med,decreasing = TRUE)) |>
  ggplot(aes(x=weight_exam,y=id,col=Best_Model)) + 
  geom_vline(xintercept = .5,linetype="dashed") +
  stat_pointinterval() + 
  ggh4x::facet_grid2(~condit,axes="all",scales="free_y", independent = "y")+
  theme_minimal() +
  theme(legend.position="top")

E3

Code
# folder_names <- c("e3_hybrid_n_iter_150_ntry_150_1757","e3_hybrid_n_iter_250_ntry_200_4300","e3_hybrid_n_iter_60_ntry_150_0946","e3_hybrid_n_iter_100_ntry_100_0545")
testE3 <- readRDS(here("data/e3_08-04-23.rds")) |> filter(expMode2 == "Test") 
e3Sbjs <- testE3 |> group_by(id,condit,bandOrder) |> summarise(n=n())

folder_names <- list.files(here("data/abc_reject"),pattern="e3_hyb*")

all_fits <- map_df(folder_names, process_folder) |> 
  left_join(e3Sbjs,by=c("id","condit")) 


all_fits |> 
  group_by(exp,n_int,ntry,tolM,ar,condit,Fit_Method) |> 
  summarise(min=first(min),me=mean(mean_error),
            w=median(weight_exam),sd_w=sd(weight_exam),c=median(c),
            lr=median(lr),n=n_distinct(id)) |>
   mutate(across(c(me, w, lr, sd_w), ~round(., 2))) |>
  arrange(condit,Fit_Method,me) |> kable(caption="E3 Fit Comparisons") |> 
  kable_styling(full_width = F) |>
  column_spec(8,bold=T,border_left=T) 
E3 Fit Comparisons
exp n_int ntry tolM ar condit Fit_Method min me w sd_w c lr n
e3 100 2500 0.65 0.10 Constant Test 246 213.60 0.75 0.27 0.0000413 2.08 110
e3 200 1500 0.70 0.10 Constant Test 348 214.91 0.74 0.27 0.0000417 2.08 110
e3 90 900 0.80 0.09 Constant Test 92 217.05 0.73 0.27 0.0000413 2.04 110
e3 50 900 0.80 0.12 Constant Test 53 217.53 0.73 0.27 0.0000406 2.02 110
e3 70 500 0.85 0.10 Constant Test 186 219.42 0.72 0.27 0.0000397 2.06 110
e3 150 500 0.95 0.10 Constant Test 96 219.56 0.72 0.27 0.0000397 2.04 110
e3 50 500 0.85 0.05 Constant Test 312 220.20 0.72 0.27 0.0000394 2.06 110
e3 400 300 0.85 0.04 Constant Test 353 220.22 0.72 0.27 0.0000403 2.04 110
e3 50 900 0.95 0.10 Constant Test 37 220.50 0.72 0.27 0.0000387 2.10 110
e3 49 800 0.95 0.18 Constant Test 303 221.29 0.72 0.27 0.0000390 2.10 110
e3 52 600 0.95 0.18 Constant Test 228 221.74 0.72 0.28 0.0000387 2.04 110
e3 61 500 0.95 0.10 Constant Test 36 221.78 0.71 0.27 0.0000381 2.02 110
e3 250 200 0.85 0.10 Constant Test 184 222.77 0.72 0.28 0.0000395 2.06 110
e3 100 100 0.85 0.01 Constant Test 804 223.08 0.71 0.27 0.0000407 2.08 110
e3 65 300 0.95 0.10 Constant Test 31 224.28 0.71 0.27 0.0000391 2.03 110
e3 150 150 0.85 0.10 Constant Test 92 224.50 0.72 0.28 0.0000396 2.03 110
e3 60 150 0.85 0.10 Constant Test 38 225.40 0.72 0.28 0.0000373 2.07 110
e3 51 300 0.95 0.15 Constant Test 162 225.64 0.72 0.27 0.0000380 2.01 110
e3 105 100 0.85 0.05 Constant Test 351 225.99 0.71 0.28 0.0000388 2.04 110
e3 100 100 0.85 0.10 Constant Test 202 227.29 0.72 0.28 0.0000383 2.07 110
e3 100 2500 0.65 0.10 Constant Test_Train 244 230.55 0.73 0.27 0.0000384 0.60 110
e3 200 1500 0.70 0.10 Constant Test_Train 480 231.40 0.71 0.27 0.0000372 0.60 110
e3 90 900 0.80 0.09 Constant Test_Train 94 232.37 0.70 0.27 0.0000369 0.62 110
e3 50 900 0.80 0.12 Constant Test_Train 58 232.77 0.70 0.28 0.0000365 0.63 110
e3 70 500 0.85 0.10 Constant Test_Train 186 233.90 0.68 0.27 0.0000364 0.67 110
e3 50 500 0.85 0.05 Constant Test_Train 224 234.15 0.68 0.28 0.0000352 0.69 110
e3 400 300 0.85 0.04 Constant Test_Train 613 234.32 0.69 0.27 0.0000358 0.71 110
e3 150 500 0.95 0.10 Constant Test_Train 106 234.35 0.69 0.27 0.0000358 0.70 110
e3 50 900 0.95 0.10 Constant Test_Train 40 235.16 0.69 0.28 0.0000359 0.73 110
e3 49 800 0.95 0.18 Constant Test_Train 263 235.38 0.69 0.28 0.0000358 0.70 110
e3 100 100 0.85 0.01 Constant Test_Train 645 235.54 0.69 0.28 0.0000357 0.76 110
e3 250 200 0.85 0.10 Constant Test_Train 289 235.70 0.68 0.28 0.0000351 0.77 110
e3 52 600 0.95 0.18 Constant Test_Train 227 235.74 0.68 0.28 0.0000358 0.77 110
e3 61 500 0.95 0.10 Constant Test_Train 48 236.01 0.68 0.28 0.0000355 0.74 110
e3 65 300 0.95 0.10 Constant Test_Train 30 236.55 0.68 0.27 0.0000347 0.77 110
e3 150 150 0.85 0.10 Constant Test_Train 92 236.60 0.67 0.28 0.0000345 0.81 110
e3 51 300 0.95 0.15 Constant Test_Train 152 236.95 0.68 0.28 0.0000352 0.79 110
e3 60 150 0.85 0.10 Constant Test_Train 23 237.40 0.67 0.28 0.0000340 0.85 110
e3 105 100 0.85 0.05 Constant Test_Train 284 237.51 0.67 0.28 0.0000348 0.86 110
e3 100 100 0.85 0.10 Constant Test_Train 167 237.92 0.67 0.28 0.0000341 0.86 110
e3 70 500 0.85 0.10 Constant Train 70 213.90 0.50 0.29 0.0000236 1.56 110
e3 100 100 0.85 0.10 Constant Train 77 214.41 0.50 0.29 0.0000195 1.48 110
e3 50 500 0.85 0.05 Constant Train 78 214.84 0.50 0.29 0.0000225 1.57 110
e3 60 150 0.85 0.10 Constant Train 16 215.59 0.51 0.29 0.0000208 1.48 110
e3 52 600 0.95 0.18 Constant Train 74 216.80 0.50 0.29 0.0000286 1.65 110
e3 100 2500 0.65 0.10 Varied Test 246 194.62 0.81 0.27 0.0000966 2.19 85
e3 200 1500 0.70 0.10 Varied Test 348 196.04 0.80 0.26 0.0000974 2.19 85
e3 90 900 0.80 0.09 Varied Test 92 197.98 0.79 0.26 0.0000914 2.18 85
e3 50 900 0.80 0.12 Varied Test 53 198.23 0.78 0.27 0.0000913 2.23 85
e3 70 500 0.85 0.10 Varied Test 186 200.61 0.78 0.27 0.0000958 2.15 85
e3 150 500 0.95 0.10 Varied Test 96 200.72 0.78 0.26 0.0000980 2.18 85
e3 50 500 0.85 0.05 Varied Test 312 200.88 0.78 0.27 0.0000973 2.20 85
e3 50 900 0.95 0.10 Varied Test 37 201.12 0.78 0.27 0.0001014 2.15 85
e3 400 300 0.85 0.04 Varied Test 353 201.41 0.78 0.26 0.0000998 2.17 85
e3 49 800 0.95 0.18 Varied Test 303 201.72 0.78 0.27 0.0000950 2.25 85
e3 52 600 0.95 0.18 Varied Test 228 202.47 0.77 0.27 0.0001007 2.18 85
e3 61 500 0.95 0.10 Varied Test 36 203.09 0.77 0.26 0.0001052 2.20 85
e3 250 200 0.85 0.10 Varied Test 184 203.72 0.77 0.27 0.0000987 2.15 85
e3 100 100 0.85 0.01 Varied Test 804 204.11 0.77 0.26 0.0000951 2.16 85
e3 65 300 0.95 0.10 Varied Test 31 204.23 0.77 0.26 0.0000958 2.17 85
e3 150 150 0.85 0.10 Varied Test 92 205.29 0.76 0.26 0.0000935 2.15 85
e3 51 300 0.95 0.15 Varied Test 162 205.69 0.76 0.26 0.0000900 2.15 85
e3 60 150 0.85 0.10 Varied Test 38 206.85 0.77 0.27 0.0001061 2.13 85
e3 105 100 0.85 0.05 Varied Test 351 207.63 0.76 0.26 0.0001001 2.13 85
e3 100 100 0.85 0.10 Varied Test 202 207.79 0.76 0.26 0.0001005 2.15 85
e3 100 2500 0.65 0.10 Varied Test_Train 244 236.31 0.83 0.28 0.0000443 0.72 85
e3 200 1500 0.70 0.10 Varied Test_Train 480 236.94 0.82 0.28 0.0000421 0.74 85
e3 90 900 0.80 0.09 Varied Test_Train 94 238.09 0.81 0.28 0.0000396 0.74 85
e3 50 900 0.80 0.12 Varied Test_Train 58 238.16 0.81 0.28 0.0000393 0.72 85
e3 50 900 0.95 0.10 Varied Test_Train 40 239.45 0.80 0.28 0.0000381 0.78 85
e3 70 500 0.85 0.10 Varied Test_Train 186 239.45 0.79 0.28 0.0000375 0.76 85
e3 50 500 0.85 0.05 Varied Test_Train 224 239.63 0.79 0.28 0.0000378 0.76 85
e3 150 500 0.95 0.10 Varied Test_Train 106 239.73 0.79 0.28 0.0000383 0.80 85
e3 400 300 0.85 0.04 Varied Test_Train 613 240.07 0.78 0.28 0.0000370 0.79 85
e3 49 800 0.95 0.18 Varied Test_Train 263 240.16 0.79 0.28 0.0000398 0.78 85
e3 52 600 0.95 0.18 Varied Test_Train 227 240.47 0.79 0.28 0.0000393 0.78 85
e3 61 500 0.95 0.10 Varied Test_Train 48 240.80 0.78 0.27 0.0000377 0.81 85
e3 250 200 0.85 0.10 Varied Test_Train 289 241.42 0.77 0.28 0.0000352 0.81 85
e3 100 100 0.85 0.01 Varied Test_Train 645 241.44 0.77 0.28 0.0000360 0.80 85
e3 51 300 0.95 0.15 Varied Test_Train 152 242.07 0.77 0.28 0.0000362 0.83 85
e3 65 300 0.95 0.10 Varied Test_Train 30 242.42 0.78 0.27 0.0000372 0.83 85
e3 150 150 0.85 0.10 Varied Test_Train 92 242.42 0.76 0.27 0.0000347 0.81 85
e3 60 150 0.85 0.10 Varied Test_Train 23 242.93 0.77 0.27 0.0000355 0.83 85
e3 105 100 0.85 0.05 Varied Test_Train 284 243.66 0.76 0.27 0.0000342 0.85 85
e3 100 100 0.85 0.10 Varied Test_Train 167 244.18 0.74 0.28 0.0000342 0.85 85
e3 70 500 0.85 0.10 Varied Train 70 231.82 0.50 0.29 0.0000210 0.82 85
e3 50 500 0.85 0.05 Varied Train 78 232.06 0.51 0.29 0.0000213 0.82 85
e3 60 150 0.85 0.10 Varied Train 16 233.78 0.50 0.29 0.0000218 0.80 85
e3 52 600 0.95 0.18 Varied Train 74 234.14 0.50 0.29 0.0000219 0.81 85
e3 100 100 0.85 0.10 Varied Train 77 234.53 0.50 0.29 0.0000211 0.81 85
Code
all_fits |> 
  group_by(exp,n_int,ntry,tolM,ar,condit,Fit_Method) |> 
  summarise(min=first(min),me=mean(mean_error),
            w=median(weight_exam),sd_w=sd(weight_exam),c=median(c),
            lr=median(lr),n=n_distinct(id)) |>
   mutate(across(c(me, w, lr, sd_w), ~round(., 2))) |>
  arrange(condit,Fit_Method,me) |> kable(caption="E2 Fit Comparisons") |> 
  kable_styling(full_width = F) |>
  column_spec(8,bold=T,border_left=T) 
E2 Fit Comparisons
exp n_int ntry tolM ar condit Fit_Method min me w sd_w c lr n
e3 100 2500 0.65 0.10 Constant Test 246 213.60 0.75 0.27 0.0000413 2.08 110
e3 200 1500 0.70 0.10 Constant Test 348 214.91 0.74 0.27 0.0000417 2.08 110
e3 90 900 0.80 0.09 Constant Test 92 217.05 0.73 0.27 0.0000413 2.04 110
e3 50 900 0.80 0.12 Constant Test 53 217.53 0.73 0.27 0.0000406 2.02 110
e3 70 500 0.85 0.10 Constant Test 186 219.42 0.72 0.27 0.0000397 2.06 110
e3 150 500 0.95 0.10 Constant Test 96 219.56 0.72 0.27 0.0000397 2.04 110
e3 50 500 0.85 0.05 Constant Test 312 220.20 0.72 0.27 0.0000394 2.06 110
e3 400 300 0.85 0.04 Constant Test 353 220.22 0.72 0.27 0.0000403 2.04 110
e3 50 900 0.95 0.10 Constant Test 37 220.50 0.72 0.27 0.0000387 2.10 110
e3 49 800 0.95 0.18 Constant Test 303 221.29 0.72 0.27 0.0000390 2.10 110
e3 52 600 0.95 0.18 Constant Test 228 221.74 0.72 0.28 0.0000387 2.04 110
e3 61 500 0.95 0.10 Constant Test 36 221.78 0.71 0.27 0.0000381 2.02 110
e3 250 200 0.85 0.10 Constant Test 184 222.77 0.72 0.28 0.0000395 2.06 110
e3 100 100 0.85 0.01 Constant Test 804 223.08 0.71 0.27 0.0000407 2.08 110
e3 65 300 0.95 0.10 Constant Test 31 224.28 0.71 0.27 0.0000391 2.03 110
e3 150 150 0.85 0.10 Constant Test 92 224.50 0.72 0.28 0.0000396 2.03 110
e3 60 150 0.85 0.10 Constant Test 38 225.40 0.72 0.28 0.0000373 2.07 110
e3 51 300 0.95 0.15 Constant Test 162 225.64 0.72 0.27 0.0000380 2.01 110
e3 105 100 0.85 0.05 Constant Test 351 225.99 0.71 0.28 0.0000388 2.04 110
e3 100 100 0.85 0.10 Constant Test 202 227.29 0.72 0.28 0.0000383 2.07 110
e3 100 2500 0.65 0.10 Constant Test_Train 244 230.55 0.73 0.27 0.0000384 0.60 110
e3 200 1500 0.70 0.10 Constant Test_Train 480 231.40 0.71 0.27 0.0000372 0.60 110
e3 90 900 0.80 0.09 Constant Test_Train 94 232.37 0.70 0.27 0.0000369 0.62 110
e3 50 900 0.80 0.12 Constant Test_Train 58 232.77 0.70 0.28 0.0000365 0.63 110
e3 70 500 0.85 0.10 Constant Test_Train 186 233.90 0.68 0.27 0.0000364 0.67 110
e3 50 500 0.85 0.05 Constant Test_Train 224 234.15 0.68 0.28 0.0000352 0.69 110
e3 400 300 0.85 0.04 Constant Test_Train 613 234.32 0.69 0.27 0.0000358 0.71 110
e3 150 500 0.95 0.10 Constant Test_Train 106 234.35 0.69 0.27 0.0000358 0.70 110
e3 50 900 0.95 0.10 Constant Test_Train 40 235.16 0.69 0.28 0.0000359 0.73 110
e3 49 800 0.95 0.18 Constant Test_Train 263 235.38 0.69 0.28 0.0000358 0.70 110
e3 100 100 0.85 0.01 Constant Test_Train 645 235.54 0.69 0.28 0.0000357 0.76 110
e3 250 200 0.85 0.10 Constant Test_Train 289 235.70 0.68 0.28 0.0000351 0.77 110
e3 52 600 0.95 0.18 Constant Test_Train 227 235.74 0.68 0.28 0.0000358 0.77 110
e3 61 500 0.95 0.10 Constant Test_Train 48 236.01 0.68 0.28 0.0000355 0.74 110
e3 65 300 0.95 0.10 Constant Test_Train 30 236.55 0.68 0.27 0.0000347 0.77 110
e3 150 150 0.85 0.10 Constant Test_Train 92 236.60 0.67 0.28 0.0000345 0.81 110
e3 51 300 0.95 0.15 Constant Test_Train 152 236.95 0.68 0.28 0.0000352 0.79 110
e3 60 150 0.85 0.10 Constant Test_Train 23 237.40 0.67 0.28 0.0000340 0.85 110
e3 105 100 0.85 0.05 Constant Test_Train 284 237.51 0.67 0.28 0.0000348 0.86 110
e3 100 100 0.85 0.10 Constant Test_Train 167 237.92 0.67 0.28 0.0000341 0.86 110
e3 70 500 0.85 0.10 Constant Train 70 213.90 0.50 0.29 0.0000236 1.56 110
e3 100 100 0.85 0.10 Constant Train 77 214.41 0.50 0.29 0.0000195 1.48 110
e3 50 500 0.85 0.05 Constant Train 78 214.84 0.50 0.29 0.0000225 1.57 110
e3 60 150 0.85 0.10 Constant Train 16 215.59 0.51 0.29 0.0000208 1.48 110
e3 52 600 0.95 0.18 Constant Train 74 216.80 0.50 0.29 0.0000286 1.65 110
e3 100 2500 0.65 0.10 Varied Test 246 194.62 0.81 0.27 0.0000966 2.19 85
e3 200 1500 0.70 0.10 Varied Test 348 196.04 0.80 0.26 0.0000974 2.19 85
e3 90 900 0.80 0.09 Varied Test 92 197.98 0.79 0.26 0.0000914 2.18 85
e3 50 900 0.80 0.12 Varied Test 53 198.23 0.78 0.27 0.0000913 2.23 85
e3 70 500 0.85 0.10 Varied Test 186 200.61 0.78 0.27 0.0000958 2.15 85
e3 150 500 0.95 0.10 Varied Test 96 200.72 0.78 0.26 0.0000980 2.18 85
e3 50 500 0.85 0.05 Varied Test 312 200.88 0.78 0.27 0.0000973 2.20 85
e3 50 900 0.95 0.10 Varied Test 37 201.12 0.78 0.27 0.0001014 2.15 85
e3 400 300 0.85 0.04 Varied Test 353 201.41 0.78 0.26 0.0000998 2.17 85
e3 49 800 0.95 0.18 Varied Test 303 201.72 0.78 0.27 0.0000950 2.25 85
e3 52 600 0.95 0.18 Varied Test 228 202.47 0.77 0.27 0.0001007 2.18 85
e3 61 500 0.95 0.10 Varied Test 36 203.09 0.77 0.26 0.0001052 2.20 85
e3 250 200 0.85 0.10 Varied Test 184 203.72 0.77 0.27 0.0000987 2.15 85
e3 100 100 0.85 0.01 Varied Test 804 204.11 0.77 0.26 0.0000951 2.16 85
e3 65 300 0.95 0.10 Varied Test 31 204.23 0.77 0.26 0.0000958 2.17 85
e3 150 150 0.85 0.10 Varied Test 92 205.29 0.76 0.26 0.0000935 2.15 85
e3 51 300 0.95 0.15 Varied Test 162 205.69 0.76 0.26 0.0000900 2.15 85
e3 60 150 0.85 0.10 Varied Test 38 206.85 0.77 0.27 0.0001061 2.13 85
e3 105 100 0.85 0.05 Varied Test 351 207.63 0.76 0.26 0.0001001 2.13 85
e3 100 100 0.85 0.10 Varied Test 202 207.79 0.76 0.26 0.0001005 2.15 85
e3 100 2500 0.65 0.10 Varied Test_Train 244 236.31 0.83 0.28 0.0000443 0.72 85
e3 200 1500 0.70 0.10 Varied Test_Train 480 236.94 0.82 0.28 0.0000421 0.74 85
e3 90 900 0.80 0.09 Varied Test_Train 94 238.09 0.81 0.28 0.0000396 0.74 85
e3 50 900 0.80 0.12 Varied Test_Train 58 238.16 0.81 0.28 0.0000393 0.72 85
e3 50 900 0.95 0.10 Varied Test_Train 40 239.45 0.80 0.28 0.0000381 0.78 85
e3 70 500 0.85 0.10 Varied Test_Train 186 239.45 0.79 0.28 0.0000375 0.76 85
e3 50 500 0.85 0.05 Varied Test_Train 224 239.63 0.79 0.28 0.0000378 0.76 85
e3 150 500 0.95 0.10 Varied Test_Train 106 239.73 0.79 0.28 0.0000383 0.80 85
e3 400 300 0.85 0.04 Varied Test_Train 613 240.07 0.78 0.28 0.0000370 0.79 85
e3 49 800 0.95 0.18 Varied Test_Train 263 240.16 0.79 0.28 0.0000398 0.78 85
e3 52 600 0.95 0.18 Varied Test_Train 227 240.47 0.79 0.28 0.0000393 0.78 85
e3 61 500 0.95 0.10 Varied Test_Train 48 240.80 0.78 0.27 0.0000377 0.81 85
e3 250 200 0.85 0.10 Varied Test_Train 289 241.42 0.77 0.28 0.0000352 0.81 85
e3 100 100 0.85 0.01 Varied Test_Train 645 241.44 0.77 0.28 0.0000360 0.80 85
e3 51 300 0.95 0.15 Varied Test_Train 152 242.07 0.77 0.28 0.0000362 0.83 85
e3 65 300 0.95 0.10 Varied Test_Train 30 242.42 0.78 0.27 0.0000372 0.83 85
e3 150 150 0.85 0.10 Varied Test_Train 92 242.42 0.76 0.27 0.0000347 0.81 85
e3 60 150 0.85 0.10 Varied Test_Train 23 242.93 0.77 0.27 0.0000355 0.83 85
e3 105 100 0.85 0.05 Varied Test_Train 284 243.66 0.76 0.27 0.0000342 0.85 85
e3 100 100 0.85 0.10 Varied Test_Train 167 244.18 0.74 0.28 0.0000342 0.85 85
e3 70 500 0.85 0.10 Varied Train 70 231.82 0.50 0.29 0.0000210 0.82 85
e3 50 500 0.85 0.05 Varied Train 78 232.06 0.51 0.29 0.0000213 0.82 85
e3 60 150 0.85 0.10 Varied Train 16 233.78 0.50 0.29 0.0000218 0.80 85
e3 52 600 0.95 0.18 Varied Train 74 234.14 0.50 0.29 0.0000219 0.81 85
e3 100 100 0.85 0.10 Varied Train 77 234.53 0.50 0.29 0.0000211 0.81 85
Code
{all_fits |> 
   filter(Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +geom_density(alpha=.5) } /{

all_fits |> 
   filter(Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +geom_density(alpha=.5) +
  facet_wrap(~run_name)
    }

Code
all_fits |> 
   filter(Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +geom_density(alpha=.5) + facet_wrap(~bandOrder) 

Code
all_fits |> ggplot(aes(x=condit,y=weight_exam,col=condit)) + stat_pointinterval() +
  facet_wrap(bandOrder~Fit_Method)

Code
all_fits |> ggplot(aes(x=run_name,y=weight_exam,col=condit)) + stat_pointinterval() +
  facet_wrap(condit~Fit_Method)

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test") |>
    ggplot(aes(x=weight_exam,fill=condit)) +
  geom_density() +
  geom_vline(xintercept = .5,linetype="dashed") +
  ggh4x::facet_wrap2(~id+condit, scales="free_y")

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test_Train") |>
    ggplot(aes(x=weight_exam,fill=condit)) +
  geom_density() +
  geom_vline(xintercept = .5,linetype="dashed") +
  ggh4x::facet_wrap2(~id+condit, scales="free_y")

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test") |>
  ggplot(aes(x=run_name,y=weight_exam,col=run_name)) + 
  stat_pointinterval(position=position_dodge(.5)) +
  ggh4x::facet_wrap2(~id+condit) + 
  theme(axis.text.x = element_blank()) 

Code
all_fits |> 
   filter(id %in% unique(all_fits$id)[1:50], Fit_Method=="Test_Train") |>
  ggplot(aes(x=run_name,y=weight_exam,col=run_name)) + 
  stat_pointinterval(position=position_dodge(.5)) +
  ggh4x::facet_wrap2(~id+condit) + 
  theme(axis.text.x = element_blank()) 

Code
{all_fits |> 
  group_by(id,condit,Fit_Method) |>
  mutate(we_med=median(weight_exam),
         Best_Model=case_when(we_med>.5 ~"EXAM",we_med<.5 ~"ALM")) |>
  filter(Fit_Method=="Test") |>
  ungroup() |>
  mutate(id=reorder(id,we_med,decreasing = TRUE)) |>
  ggplot(aes(x=weight_exam,y=id,col=Best_Model)) + 
  geom_vline(xintercept = .5,linetype="dashed") +
  stat_pointinterval() + 
  ggh4x::facet_grid2(~condit,axes="all",scales="free_y", independent = "y")+
  theme_minimal() +
  theme(legend.position="top")} / 
  {all_fits |> 
  group_by(id,condit,Fit_Method,bandOrder) |>
  mutate(we_med=median(weight_exam),
         Best_Model=case_when(we_med>.5 ~"EXAM",we_med<.5 ~"ALM")) |>
  filter(Fit_Method=="Test") |>
  ungroup() |>
  mutate(id=reorder(id,we_med,decreasing = TRUE)) |>
  ggplot(aes(x=weight_exam,y=id,col=Best_Model)) + 
  geom_vline(xintercept = .5,linetype="dashed") +
  stat_pointinterval() + 
  ggh4x::facet_grid2(~bandOrder+condit,axes="all",scales="free_y", independent = "y")+
  theme_minimal() +
  theme(legend.position="top")}