Skip to content

Commit 136d35a

Browse files
committed
Lowered the iteration count to balance core count per Claude advice
"Run more shorter chains instead of fewer long ones. For example, 8 chains × 1000 iterations will have less variance in finish times than 4 chains × 2000 iterations, and you get the same total draws. The load-balancing improves because the law of large numbers works in your favor."
1 parent ff557af commit 136d35a

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

2025/planscore_models_congress.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ m <- brm(bf(dem_share_imputed ~ dpres_mn + incumb +
8282
group="stateabrev"),
8383
set_prior("student_t(3, 0.02, 0.05)", class="sd",coef="incumb",
8484
group="stateabrev")),
85-
cores=detectCores(), chains=4, control=list(adapt_delta=0.99999, max_treedepth=12),
86-
warmup=2000, iter=6000, refresh=10, thin=16)
85+
cores=detectCores(), chains=detectCores(), control=list(adapt_delta=0.99999, max_treedepth=12),
86+
warmup=ceiling(4*2000/detectCores()), iter=ceiling(4*6000/detectCores()), refresh=10, thin=16)
8787
proc.time() - start
8888
saveRDS(m, "full_model_2025B_incumbency_congress.rds")
8989

@@ -135,7 +135,7 @@ m <- brm(bf(dem_share_imputed ~ dpres_mn +
135135
set_prior("student_t(3, 0.07, 0.1)", class="sd",coef="dpres_mn",
136136
group="stateabrev")),
137137
cores=detectCores(), chains=detectCores(), control=list(adapt_delta=0.99999, max_treedepth=12),
138-
warmup=2000, iter=6000, refresh=10, thin=16)
138+
warmup=ceiling(4*2000/detectCores()), iter=ceiling(4*6000/detectCores()), refresh=10, thin=16)
139139
proc.time() - start
140140
saveRDS(m, "full_model_2025B_openseat_congress.rds")
141141

@@ -233,7 +233,7 @@ m <- brm(bf(dem_share_imputed ~ dpres_mn + incumb +
233233
set_prior("student_t(3, 0.02, 0.05)", class="sd",coef="incumb",
234234
group="stateabrev")),
235235
cores=detectCores(), chains=detectCores(), control=list(adapt_delta=0.99999, max_treedepth=12),
236-
warmup=2000, iter=6000, refresh=10, thin=16)
236+
warmup=ceiling(4*2000/detectCores()), iter=ceiling(4*6000/detectCores()), refresh=10, thin=16)
237237
proc.time() - start
238238
saveRDS(m, "full_model_2025A_incumbency_congress.rds")
239239

@@ -285,7 +285,7 @@ m <- brm(bf(dem_share_imputed ~ dpres_mn +
285285
set_prior("student_t(3, 0.07, 0.1)", class="sd",coef="dpres_mn",
286286
group="stateabrev")),
287287
cores=detectCores(), chains=4, control=list(adapt_delta=0.99999, max_treedepth=12),
288-
warmup=2000, iter=6000, refresh=10, thin=16)
288+
warmup=ceiling(4*2000/detectCores()), iter=ceiling(4*6000/detectCores()), refresh=10, thin=16)
289289
proc.time() - start
290290
saveRDS(m, "full_model_2025A_openseat_congress.rds")
291291

2025/planscore_models_state_leg.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ m <- brm(bf(dem_share_imputed ~ dpres_mn + incumb +
7474
set_prior("student_t(3, 0.02, 0.05)", class="sd",coef="incumb",
7575
group="stateabrev")),
7676
cores=detectCores(), chains=detectCores(), control=list(adapt_delta=0.99999, max_treedepth=12),
77-
warmup=2000, iter=6000, refresh=10, thin=16) #warmup and iter for number of cycles
77+
warmup=ceiling(4*2000/detectCores()), iter=ceiling(4*6000/detectCores()), refresh=10, thin=16) #warmup and iter for number of cycles
7878
proc.time() - start
7979
saveRDS(m, "full_model_2026A_incumbency_statelege.rds")
8080

@@ -129,7 +129,7 @@ m <- brm(bf(dem_share_imputed ~ dpres_mn +
129129
set_prior("student_t(3, 0.11, 0.1)", class="sd",coef="dpres_mn",
130130
group="stateabrev")),
131131
cores=detectCores(), chains=detectCores(), control=list(adapt_delta=0.99999, max_treedepth=12),
132-
warmup=2000, iter=6000, refresh=10, thin=16) #warmup and iter for number of cycles
132+
warmup=ceiling(4*2000/detectCores()), iter=ceiling(4*6000/detectCores()), refresh=10, thin=16) #warmup and iter for number of cycles
133133
proc.time() - start
134134
saveRDS(m, "full_model_2026A_openseat_statelege.rds")
135135

0 commit comments

Comments
 (0)