@@ -484,21 +484,30 @@ analyse_baSAR <- function(
484
484
thin <- n.MCMC / 1e+05 * 250
485
485
486
486
}else {
487
- thin <- 10
488
-
487
+ thin <- min(10 , n.MCMC / 2 )
489
488
}
490
489
} else {
490
+ .validate_positive_scalar(method_control [[" thin" ]], int = TRUE ,
491
+ name = " 'thin' in 'method.control'" )
491
492
method_control [[" thin" ]]
492
493
}
493
494
495
+ # # jags reports ugly errors if thin exceeds n.MCMC / 2, as that
496
+ # # would correspond to producing just one posterior sample, see #407
497
+ if (! is.null(method_control [[" thin" ]]) && thin > n.MCMC / 2 ) {
498
+ thin <- n.MCMC / 2
499
+ .throw_warning(" 'thin = " , method_control [[" thin" ]],
500
+ " ' is too high for 'n.MCMC = " , n.MCMC ,
501
+ " ', reset to " , thin )
502
+ }
503
+
494
504
# #variable.names
495
505
variable.names <- if (is.null(method_control [[" variable.names" ]])) {
496
506
c(' central_D' , ' sigma_D' , ' D' , ' Q' , ' a' , ' b' , ' c' , ' g' )
497
507
} else {
498
508
method_control [[" variable.names" ]]
499
509
}
500
510
501
-
502
511
# check whether this makes sense at all, just a direty and quick test
503
512
stopifnot(lower_centralD > = 0 )
504
513
@@ -532,7 +541,6 @@ analyse_baSAR <- function(
532
541
533
542
for (i in 1 : Nb_aliquots ) {
534
543
Limited_cycles [i ] <- length(data.Dose [, i ]) - length(which(is.na(data.Dose [, i ])))
535
-
536
544
}
537
545
}
538
546
@@ -668,8 +676,8 @@ analyse_baSAR <- function(
668
676
cat(" \n [analyse_baSAR()] ---- baSAR-model ---- \n " )
669
677
cat(" \n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n " )
670
678
cat(" [analyse_baSAR()] Bayesian analysis in progress ...\n " )
671
- message(" .. >> bounds set to: lower_centralD =" , lower_centralD ,
672
- " | upper_centralD =" , upper_centralD )
679
+ message(" .. >> bounds set to: lower_centralD = " , lower_centralD ,
680
+ " | upper_centralD = " , upper_centralD )
673
681
}
674
682
675
683
Nb_Iterations <- n.MCMC
@@ -717,7 +725,6 @@ analyse_baSAR <- function(
717
725
thin = thin
718
726
)
719
727
720
-
721
728
pt_zero <- 0
722
729
nb_decal <- 2
723
730
pt_zero <- Nb_aliquots
@@ -733,7 +740,6 @@ analyse_baSAR <- function(
733
740
rm(temp.vector )
734
741
}else {
735
742
gm <- NULL
736
-
737
743
}
738
744
739
745
# #quantiles
@@ -774,12 +780,12 @@ analyse_baSAR <- function(
774
780
)
775
781
)
776
782
)
777
-
778
783
}
779
784
# #END
780
785
# #////////////////////////////////////////////////////////////////////////////////////////////////
781
786
782
- # Integrity tests -----------------------------------------------------------------------------
787
+
788
+ # # Integrity checks -------------------------------------------------------
783
789
784
790
.require_suggested_package(" rjags" )
785
791
.require_suggested_package(" coda" )
@@ -1782,7 +1788,6 @@ analyse_baSAR <- function(
1782
1788
# #LxTx SD values
1783
1789
OUTPUT_results [comptage , (9 + 2 * max_cycles ): (8 + 2 * max_cycles + llong )] <-
1784
1790
as.numeric(Disc_Grain.list [[k ]][[disc_selected ]][[grain_selected ]][[4 ]])
1785
-
1786
1791
}
1787
1792
}
1788
1793
}
@@ -1917,7 +1922,6 @@ analyse_baSAR <- function(
1917
1922
1918
1923
if (! is(source_doserate , " list" )){
1919
1924
source_doserate <- list (source_doserate )
1920
-
1921
1925
}
1922
1926
}
1923
1927
@@ -1979,7 +1983,6 @@ analyse_baSAR <- function(
1979
1983
1980
1984
}else {
1981
1985
cat(" \t\t\t\t mean\t sd\t HPD\n " )
1982
-
1983
1986
}
1984
1987
1985
1988
@@ -2002,7 +2005,6 @@ analyse_baSAR <- function(
2002
2005
cat(" * mean of the central dose is the geometric mean\n " )
2003
2006
}
2004
2007
cat(" ** 68 % level | *** 95 % level\n " )
2005
-
2006
2008
}
2007
2009
2008
2010
@@ -2036,7 +2038,6 @@ analyse_baSAR <- function(
2036
2038
2037
2039
}else {
2038
2040
try(plot(results [[2 ]]))
2039
-
2040
2041
}
2041
2042
2042
2043
@@ -2137,7 +2138,6 @@ analyse_baSAR <- function(
2137
2138
pos = 3 ,
2138
2139
col = col [2 ],
2139
2140
cex = 0.9 * par()$ cex )
2140
-
2141
2141
}
2142
2142
# #update counter
2143
2143
i <- i + 15
@@ -2194,7 +2194,6 @@ analyse_baSAR <- function(
2194
2194
2195
2195
}else {
2196
2196
legend_pos <- " topleft"
2197
-
2198
2197
}
2199
2198
2200
2199
# #set plot area
@@ -2227,7 +2226,6 @@ analyse_baSAR <- function(
2227
2226
add = TRUE ,
2228
2227
col = rgb(0 , 0 , 0 , .1 )
2229
2228
)
2230
-
2231
2229
}
2232
2230
}else {
2233
2231
message(" [analyse_baSAR()] Error: Wrong 'variable.names' " ,
@@ -2291,7 +2289,6 @@ analyse_baSAR <- function(
2291
2289
bg = " grey" ,
2292
2290
legend = " measured dose points"
2293
2291
)
2294
-
2295
2292
}
2296
2293
# #remove object, it might be rather big
2297
2294
rm(plot_matrix )
@@ -2367,7 +2364,6 @@ analyse_baSAR <- function(
2367
2364
2368
2365
}else {
2369
2366
legend_pos <- " topleft"
2370
-
2371
2367
}
2372
2368
2373
2369
legend(
@@ -2377,13 +2373,9 @@ analyse_baSAR <- function(
2377
2373
col = c(" black" , col [3 ], col [2 ]),
2378
2374
bty = " n" ,
2379
2375
cex = par()$ cex * 0.8
2380
-
2381
2376
)
2382
-
2383
2377
}
2384
-
2385
2378
}
2386
-
2387
2379
}
2388
2380
2389
2381
# Return --------------------------------------------------------------------------------------
@@ -2398,5 +2390,4 @@ analyse_baSAR <- function(
2398
2390
),
2399
2391
info = list (call = sys.call())
2400
2392
))
2401
-
2402
2393
}
0 commit comments