From f8628a95ac0a727caa9d93e56b9a00d2488297ce Mon Sep 17 00:00:00 2001 From: drnickisaac Date: Sat, 25 Apr 2020 17:54:47 +0100 Subject: [PATCH 1/8] updated documentation of datasets --- R/butterflies_hs-data.R | 1 + R/butterflies_wc-data.R | 1 + R/dragonflies-data.R | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/R/butterflies_hs-data.R b/R/butterflies_hs-data.R index f0a61f0..0a8928a 100644 --- a/R/butterflies_hs-data.R +++ b/R/butterflies_hs-data.R @@ -1,6 +1,7 @@ #' @name butterflies_hs #' @title Data - UK Butterfly Monitoring Scheme - Habitat Specialists #' @description This dataset from the UK Butterfly Monitoring Scheme has national abundance indices for 26 species regarded as habitat specialists from 1976-2017. +#' There are 1000 rows of data. Ten species have a complete time-series (42 years of data); 15 species join late (9 in the 1970s, 3 in the 1980s and 3 in the 1990s); the Swallowtail (Papilio machaon) spans the full range of years but has no data for 1978. #' @docType data #' @format #' There are four columns of data: diff --git a/R/butterflies_wc-data.R b/R/butterflies_wc-data.R index 42bdcc3..32c1840 100644 --- a/R/butterflies_wc-data.R +++ b/R/butterflies_wc-data.R @@ -1,6 +1,7 @@ #' @name butterflies_wc #' @title Data - UK Butterfly Monitoring Scheme - Wider Countryside Species #' @description This dataset from the UK Butterfly Monitoring Scheme has national abundance indices for 24 species regarded as wider countryside species from 1976-2017. +#' There are 1005 lines of data, reflecting late entry into the time series for the Scotch Argus (Erebia aethops). Time-series for the other 23 species are complete. #' @docType data #' @usage data(butterflies_wc) #' @format diff --git a/R/dragonflies-data.R b/R/dragonflies-data.R index fdcb24a..712f328 100644 --- a/R/dragonflies-data.R +++ b/R/dragonflies-data.R @@ -1,7 +1,7 @@ #' @name dragonflies #' @title Data - British Dragonfly Society, UK #' @description This dataset contains annual occupancy estimates for 45 species of dragonflies and damselflies in the UK, 1970-2015. -#' There are 2039 rows: 44 species have an estimate for every year, but the Small red-eyed damselfly has no estimates prior to 2001 (the first year in which it was recorded in UK). +#' There are 2039 rows: 44 species have an estimate for every year, but the Small red-eyed damselfly (Erythromma viridulum) has no estimates prior to 2001 (the first year in which it was recorded in UK). #' The models are based on biological records data from the British Dragonfly Society. #' The data are derived from Bayesian occupancy detection models, described in Outhwaite et al (2019). #' @usage data(dragonflies) From 6d996782f232c073df922daaaa6dd427ae38c2ab Mon Sep 17 00:00:00 2001 From: drnickisaac Date: Tue, 9 Mar 2021 10:19:28 +0000 Subject: [PATCH 2/8] adding small constant (0.0001) to ower limit of priors on standard deviation hyperparameters in bma_BUGS_models. This fixes an occasional bug in which sd -> 0 hence precision -> Inf, thus throwing an error in JAGS. --- R/bma_BUGS_models.R | 6 +++--- man/butterflies_hs.Rd | 1 + man/butterflies_wc.Rd | 1 + man/dragonflies.Rd | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/R/bma_BUGS_models.R b/R/bma_BUGS_models.R index 5cf428a..6bf8331 100644 --- a/R/bma_BUGS_models.R +++ b/R/bma_BUGS_models.R @@ -84,20 +84,20 @@ bma_model_Smooth <- function(incl.2deriv = FALSE, process_errors <- ' # process errors tau.spi <- pow(sigma.spi,-2) - sigma.spi ~ dunif(0,30)' + sigma.spi ~ dunif(0.0001,30)' if(seFromData){ obsErrors <- ' # observation errors: one value per site-species for (s in 1:nsp){ for (t in 1:nyears){ - sigma.obs[s,t] ~ dunif(0, max_se) # for the missing values + sigma.obs[s,t] ~ dunif(0.0001, max_se) # for the missing values }} ' } else { obsErrors <- ' # observation error is constant - theta ~ dunif(0,10)' + theta ~ dunif(0.0001,10)' } return(paste(c( diff --git a/man/butterflies_hs.Rd b/man/butterflies_hs.Rd index 390298e..549d9be 100644 --- a/man/butterflies_hs.Rd +++ b/man/butterflies_hs.Rd @@ -21,6 +21,7 @@ data(butterflies_hs) } \description{ This dataset from the UK Butterfly Monitoring Scheme has national abundance indices for 26 species regarded as habitat specialists from 1976-2017. +There are 1000 rows of data. Ten species have a complete time-series (42 years of data); 15 species join late (9 in the 1970s, 3 in the 1980s and 3 in the 1990s); the Swallowtail (Papilio machaon) spans the full range of years but has no data for 1978. } \examples{ data(butterflies_hs) diff --git a/man/butterflies_wc.Rd b/man/butterflies_wc.Rd index 3e5cced..3a96844 100644 --- a/man/butterflies_wc.Rd +++ b/man/butterflies_wc.Rd @@ -21,6 +21,7 @@ data(butterflies_wc) } \description{ This dataset from the UK Butterfly Monitoring Scheme has national abundance indices for 24 species regarded as wider countryside species from 1976-2017. +There are 1005 lines of data, reflecting late entry into the time series for the Scotch Argus (Erebia aethops). Time-series for the other 23 species are complete. } \examples{ data(butterflies_wc) diff --git a/man/dragonflies.Rd b/man/dragonflies.Rd index 24be1d9..803e047 100644 --- a/man/dragonflies.Rd +++ b/man/dragonflies.Rd @@ -23,7 +23,7 @@ data(dragonflies) } \description{ This dataset contains annual occupancy estimates for 45 species of dragonflies and damselflies in the UK, 1970-2015. -There are 2039 rows: 44 species have an estimate for every year, but the Small red-eyed damselfly has no estimates prior to 2001 (the first year in which it was recorded in UK). +There are 2039 rows: 44 species have an estimate for every year, but the Small red-eyed damselfly (Erythromma viridulum) has no estimates prior to 2001 (the first year in which it was recorded in UK). The models are based on biological records data from the British Dragonfly Society. The data are derived from Bayesian occupancy detection models, described in Outhwaite et al (2019). } From 97cce1f30783284fc6ae34ed64966697a9452acc Mon Sep 17 00:00:00 2001 From: drnickisaac Date: Tue, 9 Mar 2021 10:21:46 +0000 Subject: [PATCH 3/8] bumping version number --- DESCRIPTION | 6 +++--- man/bma.Rd | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a385e1a..5946aab 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: BRCindicators Type: Package Title: Creating multispecies biodiversity indicators -Version: 1.3.6 -Date: 2020-04-10 +Version: 1.3.7 +Date: 2021-03-09 Authors@R: c(person("Tom", "August", role = c("aut", "cre"), email = "tomaug@ceh.ac.uk"), person("Gary", "Powney", role = c("aut")), person("Charlie", "Outhwaite", role = c("aut")), @@ -27,7 +27,7 @@ VignetteBuilder: knitr License: GPL-3 URL: https://github.com/BiologicalRecordsCentre/BRCindicators BugReports: https://github.com/BiologicalRecordsCentre/BRCindicators/issues -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 Encoding: UTF-8 Suggests: testthat, diff --git a/man/bma.Rd b/man/bma.Rd index 4309129..ae2c78d 100644 --- a/man/bma.Rd +++ b/man/bma.Rd @@ -9,6 +9,7 @@ bma( plot = TRUE, model = "smooth", parallel = FALSE, + n.cores = parallel::detectCores() - 1, incl.model = TRUE, n.iter = 10000, n.thin = 5, @@ -35,7 +36,9 @@ NB: Index values are assumed to be on the unbounded (logarithmic scale)} \item{model}{The type of model to be used. See details.} \item{parallel}{if \code{TRUE} the model chains will be run in parallel using one fewer cores than -are available on the computer. NOTE: this will typically not work for parallel use on cluster PCs.} +are available on the computer as default. NOTE: this will typically not work for parallel use on cluster PCs.} + +\item{n.cores}{if running the code in parallel this option specifies the number of cores to use.} \item{incl.model}{if \code{TRUE} the model is added as an attribute of the object returned} From bcf74a35f5df0d0948d5ff4497be6f267d42dfb5 Mon Sep 17 00:00:00 2001 From: Tom August Date: Mon, 29 Mar 2021 09:57:38 +0100 Subject: [PATCH 4/8] Replace seed argument in jags calls with set.seed() prior to calls --- tests/testthat/testbma.R | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/testthat/testbma.R b/tests/testthat/testbma.R index cfa0bef..7f6e575 100644 --- a/tests/testthat/testbma.R +++ b/tests/testthat/testbma.R @@ -17,8 +17,7 @@ test_that("simple run", { bma_indicator <- bma(data, model = "smooth", m.scale = "logit", - n.iter = 100, - seed = 123) + n.iter = 100) sink() # test a data frame is returned.. expect_is(bma_indicator, 'data.frame') @@ -81,11 +80,11 @@ test_that("degraded data", { data2 <- data2[1:(nrow(data2)-1),] sink(temp) + set.seed(123) bma_indicator <- bma(data2, model = "smooth", m.scale = "logit", - n.iter = 100, - seed = 123) + n.iter = 100) sink() expect_is(bma_indicator, 'data.frame') @@ -95,11 +94,11 @@ test_that("degraded data", { test_that("model options", { + # set.seed(123) # bma_indicator_det <- bma(data, # model = "smooth_det", # m.scale = "logit", - # n.iter = 100, - # seed = 123) + # n.iter = 100) # # # test a data frame is returned.. # expect_is(bma_indicator_det, 'data.frame') @@ -108,13 +107,12 @@ test_that("model options", { # c("Year", "Index.Mprime", "lowerCI.Mprime", "upperCI.Mprime", # "Index.M", "lowerCI.M", "upperCI.M")) - set.seed(123) sink(temp) + set.seed(123) bma_indicator_smooth_det2 <- bma(data, model = "smooth_det2", m.scale = "logit", - n.iter = 100, - seed = 123) + n.iter = 100) sink() # test a data frame is returned.. @@ -138,14 +136,12 @@ test_that("model options", { 126.238820288326, 128.289739888977, 129.315919102855, 129.111127561621, 127.494892855453)) - set.seed(123) - sink(temp) + set.seed(123) bma_indicatorsmooth_det_sigtheta <- bma(data, model = "smooth_det_sigtheta", m.scale = "logit", - n.iter = 100, - seed = 123) + n.iter = 100) sink() # test a data frame is returned.. @@ -180,7 +176,6 @@ test_that("different parameters", { model = "smooth", m.scale = "logit", n.iter = 100, - seed = 123, seFromData = TRUE, rescale_indices = 2, rescaleYr = 5, @@ -199,8 +194,7 @@ test_that("different parameters", { bma_indicator_params2 <- bma(data, model = "smooth", m.scale = "logit", - n.iter = 100, - seed = 123, + n.iter = 100, Y1perfect = FALSE) sink() expect_is(bma_indicator_params2, 'data.frame') From ab1233135d8109e3ec9c45633c1934c63e49426b Mon Sep 17 00:00:00 2001 From: Tom August Date: Mon, 29 Mar 2021 09:59:12 +0100 Subject: [PATCH 5/8] Add test plots to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7a9012d..d5a4fa2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ Other_files/ vignettes/BRCindicators_cache/ vignettes/BRCindicators_files/ -misc/ \ No newline at end of file +misc/ +tests/testthat/Rplots.pdf \ No newline at end of file From 7d4554c3255d4c34aaed9d712df0f140e1d08e49 Mon Sep 17 00:00:00 2001 From: Tom August Date: Mon, 29 Mar 2021 09:00:21 +0100 Subject: [PATCH 6/8] delete test plot outputs --- tests/testthat/Rplots.pdf | Bin 8631 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/testthat/Rplots.pdf diff --git a/tests/testthat/Rplots.pdf b/tests/testthat/Rplots.pdf deleted file mode 100644 index 56ae17bb005d8c18f4b4dc4fe432ccd4b02552df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8631 zcmb7q2T)U8*RBGBfJ#+BDWM8N2%(0K5PC0Cq!R*$7D|v#M5=-yD7`8OA|jp85oyu_ z5@QX! z{P$`AAR|9_H~^$%i?Ve=Is!m?wvKQwfCxdr0PrsbiT|N+A$K9|33o&NQyip(bVCt_ zUI54+b&vtv3+e3%BiIxDFMAgPe}zK}?&gSk1Q3-F76yP+5H2Xf4nQg{gy2BoFr+>F zV%=USLd;w#d^0A}HA}28-Vuw7CaZ5`Hcci$p*k6&$}hwfoG!DFFkP(<9VumQqotmo zItcnvUn9}~Odyk!h1iWu|0HT2qyDMgoAYKID9$$!eX_Pr)j1U_jAUn)%pY@6T|E_V zrO~Vl_dMBM+mi2$^Eu!C)qH*$Jttv3ab@>f=h>o3^O5XX^^ds?AM^>1CKkCqyTyHW zaB68EIoG`I)HvifACL56F4^#JdO?S-Nnc9(5>Au5j75xhVBby6Vv8p=#u?AQN$6Z& z8IcS(pFHGW|6EX95^3J;d~C(WS8ZMtjfOP&kF8)H++N+Jz}UaG&(Q z)|>Apn^D4gu;|^lv%J-=ITckh)d1t147@ITX!&%q;biAcl{GrbJns=MCS$zkM`!fN z7st+?jg7Olcc+KPs{Qx7Hgb>YR5~pR8IL!&UeCxHAopi>$Xg8=jfz}-DHh%3t=~<2 zY3rcWyn#t@onotAH2+G8*$2B7TCRO5nn1f(A)A|Z(dj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|3cfArfJU%ZI%a_b*A^I{0X%x4WYK0i)7xDzaTT4uQnkd<4OmD;pv36+M8m)(_z zpYH}Y{ANG0Z4bjjcR0sXJ9&ccg5<3ZeNWVfU!@kb%k!UG9QV$T`ZW8V2n*em7CW=p zJ;9ZvTfc7}IUihyZ=gnYPfeIg9ITQX^wD0^z!lf?`V=2Jk=l*24SxBQ;NM4#yIbo8 zF}m5o#0OzJ$NwYimi#*nrTAyVTG@@z8%DShI@T9y>%T@O2)FxgUWmT{3J?_G-~cCd zsV~~l<^WMKkSoH?+Y4a%Z|(3uIrU#z?mznBe==^6p|>6CPka0VB&6~>wyuQamym`3 zarzG#HMq-TI0^x?r2zfq6mYTJe{Y}v$<+Tp91t?WcrwgoMHWLr&;_(S;BWLj1Qb1PmsWNdIXMB770kzc7@iEy4xvNjO~r02w0u w;e;3fKgQxAXs6)%*nC+bhMAR=H93T|#?T@{M|11`WJssI20 From 19ee890109c9e219025604e53d7db508078b9fd0 Mon Sep 17 00:00:00 2001 From: Tom August Date: Mon, 29 Mar 2021 09:13:08 +0100 Subject: [PATCH 7/8] set.seed used inside bma rather than the seed srgument to jags --- R/bayesian_meta_analysis.R | 4 +- tests/testthat/testbma.R | 113 +++++++++++++++++++------------------ 2 files changed, 59 insertions(+), 58 deletions(-) diff --git a/R/bayesian_meta_analysis.R b/R/bayesian_meta_analysis.R index d34e60c..f68ee31 100644 --- a/R/bayesian_meta_analysis.R +++ b/R/bayesian_meta_analysis.R @@ -204,6 +204,7 @@ bma <- function (data, } if(incl.2deriv) params <- c(params, "t2dash") + set.seed(seed = seed) model.out <- jagsUI::jags(data = bugs_data, inits = NULL, param = params, @@ -214,8 +215,7 @@ bma <- function (data, n.chains = 3, n.thin = n.thin, n.iter = n.iter, - n.burnin = floor(n.iter/2), - seed = seed) + n.burnin = floor(n.iter/2)) if (plot==TRUE) { array_sim <- model.out$samples diff --git a/tests/testthat/testbma.R b/tests/testthat/testbma.R index 7f6e575..4fb5a7d 100644 --- a/tests/testthat/testbma.R +++ b/tests/testthat/testbma.R @@ -13,61 +13,61 @@ test_that("simple run", { # Run the Bayesian meta-analysis sink(temp) - set.seed(123) bma_indicator <- bma(data, model = "smooth", m.scale = "logit", - n.iter = 100) + n.iter = 100, + seed = 123) sink() # test a data frame is returned.. expect_is(bma_indicator, 'data.frame') - # it has hte right elements ... + # it has the right elements ... expect_equal(names(bma_indicator), c("Year", "Index.Mprime", "lowerCI.Mprime", "upperCI.Mprime", "Index.M", "lowerCI.M", "upperCI.M")) - # and the vaues are the same + # and the values are the same expect_equal(bma_indicator$Index.Mprime, - c(100, 93.3281170803379, 90.6111878405955, 87.5200429462382, - 85.6960730856869, 83.9068609021675, 82.5258411195666, 82.7743854797202, - 84.3478599908994, 86.6056218146639, 88.0782576597769, 88.5578062394473, - 89.238345955564, 87.982298981628, 87.8734302792336, 87.2031967135093, - 85.6877866411153, 84.8218459824503, 84.142244489741, 82.9412270136467, - 81.9500565400498, 81.4197519001476, 81.3219269630374, 82.1393227366779, - 83.2026871469642, 84.0002038428555, 84.4286613588619, 82.7499600249012, - 82.551209963727, 81.2576932647317, 80.7966839697043, 79.4798695780263, - 77.8596552458764, 75.5825238736814, 75.6695538589672, 75.8975875129473, - 77.5445898258082, 78.6391936143979, 79.8878227140963, 80.7257430563527, - 83.6929130770363, 85.5823427434962, 86.9888523644877, 87.5569232178518, - 88.3731701780635, 88.8759602490618, 90.3988588376878, 89.6151774723484, - 88.8136013862888, 87.5490348910981)) + c(100, 93.1465767464721, 89.3114218507984, 85.5949722505127, + 83.9430123481585, 81.7122675078106, 81.8167733236095, 82.7176213907474, + 83.3935699017243, 85.1826680239021, 86.3883832546833, 86.8605063852497, + 87.0319518142757, 86.5052174855781, 85.0451805248205, 84.7401918331028, + 84.9681235858301, 84.3467073945094, 84.4438554050815, 84.1907230954043, + 83.5201814440744, 83.5287837582316, 82.9231296876419, 82.4319186857621, + 83.3906397435168, 83.5515326766049, 83.4313022781406, 83.3486575572758, + 82.1637590219783, 81.0162205587243, 81.1844861945805, 80.2952402308285, + 78.7823884739663, 77.7885238732459, 77.3966745315161, 78.1227372536011, + 79.0582627468008, 80.3413200812947, 80.953936667349, 81.3779531999397, + 82.7174476819934, 84.660166060221, 87.2201788944389, 88.1572203767751, + 88.2189703244452, 89.4176030065389, 90.1433359905299, 90.8034570882722, + 92.0122644339251, 91.8501716477788), tolerance=1e-3) expect_equal(bma_indicator$Index.M, - c(100, 95.1066424835543, 91.3277245037226, 88.4678784823851, - 86.3749875308697, 84.9289578315946, 84.0282642314814, 83.5732818349891, - 83.4603232794704, 83.5779762787929, 83.8203922311029, 84.1037927653868, - 84.3668218409477, 84.5704470720489, 84.6949304070813, 84.7380799523458, - 84.7153660145554, 84.6562107839785, 84.5854974146199, 84.5177530126733, - 84.4571762815342, 84.3988976106347, 84.3321081506402, 84.2405725547339, - 84.1028316496622, 83.8984447989557, 83.6163659513033, 83.2555068082075, - 82.8247269865824, 82.3445098974237, 81.8479674471805, 81.3803882658224, - 80.9967396195252, 80.7479373177327, 80.6761690900314, 80.8158186574453, - 81.1918701375337, 81.8126218286924, 82.6678619340919, 83.7277504340206, - 84.9432933084802, 86.248127439241, 87.5568964352754, 88.7643412067508, - 89.7566668063039, 90.4240705821149, 90.6646901541542, 90.3880341473998, - 89.5124407395943, 87.9667954932412)) + c(100, 93.7151859934056, 88.875900433918, 85.20094872192, 82.4765853212565, + 80.5376857944807, 79.2493211841401, 78.4870867450422, 78.1287961186731, + 78.0491399314556, 78.1351896369235, 78.3057925867868, 78.5114547241235, + 78.7318919099216, 78.9516941612148, 79.1455137994674, 79.2777836955814, + 79.3071750299046, 79.2089527032148, 78.9822255414714, 78.6497989645542, + 78.2481502176824, 77.8030174303428, 77.3257693887762, 76.814065732173, + 76.2659923256175, 75.6984596395346, 75.1477823779312, 74.66740771411, + 74.3057098446791, 74.0905727971162, 74.0299753705505, 74.11530034614, + 74.3394964938591, 74.704155847949, 75.219667467046, 75.9015707542142, + 76.7580360559506, 77.7869948130706, 78.9754033565609, 80.2991540237979, + 81.7234877505562, 83.2018612557898, 84.6750349752032, 86.076547229449, + 87.3386690915678, 88.3936477532576, 89.1746925343515, 89.6136824473334, + 89.6413004538255), tolerance=1e-3) expect_equal(bma_indicator$upperCI.Mprime, - c(100, 101.71603026475, 100.390760343151, 97.3989075311615, 99.027915406523, - 93.4105829108475, 89.0609363834422, 90.6656635858461, 94.795001614849, - 98.7402396272953, 97.3459553696627, 97.0118402819752, 97.2850883439693, - 97.4541460296808, 95.677973583939, 96.8587425808644, 95.2519829741334, - 92.09623820932, 94.6123864016084, 92.4170748734287, 89.5064615471656, - 88.1619216479188, 90.5508988467181, 93.4473540316933, 92.4616676539753, - 92.4717453668377, 97.2948337385315, 94.1397738563561, 92.4042892449142, - 91.4440562370639, 90.352535255976, 90.0310366650038, 86.5736129343628, - 82.9753644402092, 83.9884634058, 84.4568399158517, 84.5953989600447, - 88.0608604261613, 88.8383050468053, 88.8849585790184, 96.4952611083576, - 103.638182923942, 100.144118574511, 101.545846142705, 101.524175258706, - 100.23781509227, 102.688628825797, 102.793775202159, 101.654403765812, - 106.200952061652)) + c(100, 100.912670097298, 97.9127659677016, 95.8499701178894, + 94.671316063692, 89.967762734754, 93.9463008307346, 91.8714213799306, + 93.5154825557029, 97.2103850587094, 100.604000942243, 98.284833857316, + 99.5794344914379, 100.058004589596, 96.023948265488, 93.9152620486179, + 92.8653040381579, 93.6033909233236, 91.3659011269288, 92.2840208179575, + 91.3889899929472, 95.6265216726726, 100.784686621884, 98.3937767294999, + 99.0346891492975, 98.5975993343305, 93.7589428156902, 94.0423242183192, + 90.0355125646069, 89.3574031716457, 88.5411398430671, 88.6128338294964, + 86.9089757554644, 85.9470043459705, 85.2854508468944, 87.5774486565996, + 86.1864430155758, 87.6080843176338, 88.2546335849038, 90.2893916629357, + 91.5802927032084, 93.6644725019474, 97.7541237492462, 100.40716888185, + 101.115243416602, 101.47662882825, 104.027283069311, 107.464620760871, + 111.656833538891, 116.888378869377), tolerance=1e-3) }) @@ -84,7 +84,8 @@ test_that("degraded data", { bma_indicator <- bma(data2, model = "smooth", m.scale = "logit", - n.iter = 100) + n.iter = 100, + seed = 123) sink() expect_is(bma_indicator, 'data.frame') @@ -94,25 +95,25 @@ test_that("degraded data", { test_that("model options", { - # set.seed(123) # bma_indicator_det <- bma(data, # model = "smooth_det", # m.scale = "logit", - # n.iter = 100) + # n.iter = 100, + # seed = 123) # # # test a data frame is returned.. # expect_is(bma_indicator_det, 'data.frame') - # # it has hte right elements ... + # # it has the right elements ... # expect_equal(names(bma_indicator_det), # c("Year", "Index.Mprime", "lowerCI.Mprime", "upperCI.Mprime", # "Index.M", "lowerCI.M", "upperCI.M")) sink(temp) - set.seed(123) bma_indicator_smooth_det2 <- bma(data, model = "smooth_det2", m.scale = "logit", - n.iter = 100) + n.iter = 100, + seed = 123) sink() # test a data frame is returned.. @@ -137,16 +138,16 @@ test_that("model options", { 127.494892855453)) sink(temp) - set.seed(123) bma_indicatorsmooth_det_sigtheta <- bma(data, model = "smooth_det_sigtheta", m.scale = "logit", - n.iter = 100) + n.iter = 100, + seed = 123) sink() # test a data frame is returned.. expect_is(bma_indicatorsmooth_det_sigtheta, 'data.frame') - # it has hte right elements ... + # it has the right elements ... expect_equal(names(bma_indicatorsmooth_det_sigtheta), c("Year", "Index.Mprime", "lowerCI.Mprime", "upperCI.Mprime", "Index.M", "lowerCI.M", "upperCI.M")) @@ -170,7 +171,6 @@ test_that("model options", { test_that("different parameters", { sink(temp) - set.seed(123) # test reading se and indexing bma_indicator_params1 <- bma(data, model = "smooth", @@ -180,7 +180,8 @@ test_that("different parameters", { rescale_indices = 2, rescaleYr = 5, baseline = 10, - incl.2deriv = TRUE) + incl.2deriv = TRUE, + seed = 123) sink() @@ -189,13 +190,13 @@ test_that("different parameters", { expect_equal(bma_indicator_params1$upperCI.Mprime[5], 10) sink(temp) - set.seed(123) # test reading se bma_indicator_params2 <- bma(data, model = "smooth", m.scale = "logit", n.iter = 100, - Y1perfect = FALSE) + Y1perfect = FALSE, + seed = 123) sink() expect_is(bma_indicator_params2, 'data.frame') From 11394d90cb1662720e840d9fa86e7758ff00ea32 Mon Sep 17 00:00:00 2001 From: Tom August Date: Mon, 29 Mar 2021 09:33:44 +0100 Subject: [PATCH 8/8] Exact number comparisons removed from tests of bma, because set.seed is currently unable to make two independent runs identical. --- R/bayesian_meta_analysis.R | 2 + tests/testthat/testbma.R | 140 ++++++++++++++++++------------------- 2 files changed, 72 insertions(+), 70 deletions(-) diff --git a/R/bayesian_meta_analysis.R b/R/bayesian_meta_analysis.R index f68ee31..a29ccab 100644 --- a/R/bayesian_meta_analysis.R +++ b/R/bayesian_meta_analysis.R @@ -75,6 +75,8 @@ bma <- function (data, CI = 95, seed = NULL){ + set.seed(seed = seed) + # Check if jagsUI is installed if (!requireNamespace("jagsUI", quietly = TRUE)) { stop("Package 'jagsUI' is needed for the 'bma' function to work. Please insatll this from CRAN. You will also be required to install JAGS, which you can download from https://sourceforge.net/projects/mcmc-jags/files/JAGS/", diff --git a/tests/testthat/testbma.R b/tests/testthat/testbma.R index 4fb5a7d..e6114ba 100644 --- a/tests/testthat/testbma.R +++ b/tests/testthat/testbma.R @@ -26,48 +26,48 @@ test_that("simple run", { c("Year", "Index.Mprime", "lowerCI.Mprime", "upperCI.Mprime", "Index.M", "lowerCI.M", "upperCI.M")) # and the values are the same - expect_equal(bma_indicator$Index.Mprime, - c(100, 93.1465767464721, 89.3114218507984, 85.5949722505127, - 83.9430123481585, 81.7122675078106, 81.8167733236095, 82.7176213907474, - 83.3935699017243, 85.1826680239021, 86.3883832546833, 86.8605063852497, - 87.0319518142757, 86.5052174855781, 85.0451805248205, 84.7401918331028, - 84.9681235858301, 84.3467073945094, 84.4438554050815, 84.1907230954043, - 83.5201814440744, 83.5287837582316, 82.9231296876419, 82.4319186857621, - 83.3906397435168, 83.5515326766049, 83.4313022781406, 83.3486575572758, - 82.1637590219783, 81.0162205587243, 81.1844861945805, 80.2952402308285, - 78.7823884739663, 77.7885238732459, 77.3966745315161, 78.1227372536011, - 79.0582627468008, 80.3413200812947, 80.953936667349, 81.3779531999397, - 82.7174476819934, 84.660166060221, 87.2201788944389, 88.1572203767751, - 88.2189703244452, 89.4176030065389, 90.1433359905299, 90.8034570882722, - 92.0122644339251, 91.8501716477788), tolerance=1e-3) - expect_equal(bma_indicator$Index.M, - c(100, 93.7151859934056, 88.875900433918, 85.20094872192, 82.4765853212565, - 80.5376857944807, 79.2493211841401, 78.4870867450422, 78.1287961186731, - 78.0491399314556, 78.1351896369235, 78.3057925867868, 78.5114547241235, - 78.7318919099216, 78.9516941612148, 79.1455137994674, 79.2777836955814, - 79.3071750299046, 79.2089527032148, 78.9822255414714, 78.6497989645542, - 78.2481502176824, 77.8030174303428, 77.3257693887762, 76.814065732173, - 76.2659923256175, 75.6984596395346, 75.1477823779312, 74.66740771411, - 74.3057098446791, 74.0905727971162, 74.0299753705505, 74.11530034614, - 74.3394964938591, 74.704155847949, 75.219667467046, 75.9015707542142, - 76.7580360559506, 77.7869948130706, 78.9754033565609, 80.2991540237979, - 81.7234877505562, 83.2018612557898, 84.6750349752032, 86.076547229449, - 87.3386690915678, 88.3936477532576, 89.1746925343515, 89.6136824473334, - 89.6413004538255), tolerance=1e-3) - expect_equal(bma_indicator$upperCI.Mprime, - c(100, 100.912670097298, 97.9127659677016, 95.8499701178894, - 94.671316063692, 89.967762734754, 93.9463008307346, 91.8714213799306, - 93.5154825557029, 97.2103850587094, 100.604000942243, 98.284833857316, - 99.5794344914379, 100.058004589596, 96.023948265488, 93.9152620486179, - 92.8653040381579, 93.6033909233236, 91.3659011269288, 92.2840208179575, - 91.3889899929472, 95.6265216726726, 100.784686621884, 98.3937767294999, - 99.0346891492975, 98.5975993343305, 93.7589428156902, 94.0423242183192, - 90.0355125646069, 89.3574031716457, 88.5411398430671, 88.6128338294964, - 86.9089757554644, 85.9470043459705, 85.2854508468944, 87.5774486565996, - 86.1864430155758, 87.6080843176338, 88.2546335849038, 90.2893916629357, - 91.5802927032084, 93.6644725019474, 97.7541237492462, 100.40716888185, - 101.115243416602, 101.47662882825, 104.027283069311, 107.464620760871, - 111.656833538891, 116.888378869377), tolerance=1e-3) + # expect_equal(bma_indicator$Index.Mprime, + # c(100, 93.6269997707243, 90.7642414846384, 86.4298924338845, + # 84.9660369922485, 83.7795156080376, 81.7308696892823, 81.6835339747922, + # 83.785498716095, 86.5077332003976, 87.6172556814392, 89.2808101569097, + # 89.4325835702012, 89.3560597071043, 88.9755823882497, 88.9353548004614, + # 88.3891728744399, 86.7979384446049, 85.2610259639761, 84.2409033288102, + # 82.3361826455479, 80.4730747181269, 80.4001032086602, 80.9139796855676, + # 81.8654713301714, 82.9416418952172, 83.3709956238925, 82.2126310793402, + # 81.6051372670485, 81.030762956591, 81.3100983064533, 80.8560131088383, + # 79.1559257580868, 77.846150838896, 76.7975166999173, 76.5336153994869, + # 77.4264611588755, 77.4785340958339, 78.1311758607365, 79.160262525242, + # 81.8550651741761, 84.0829271927207, 84.9058311033919, 86.3448876097604, + # 87.3739969177288, 87.9062457477897, 88.7744721743016, 89.4518976996496, + # 89.2268047378459, 87.8301566665547), tolerance=1e-3) + # expect_equal(bma_indicator$Index.M, + # c(100, 93.7151859934056, 88.875900433918, 85.20094872192, 82.4765853212565, + # 80.5376857944807, 79.2493211841401, 78.4870867450422, 78.1287961186731, + # 78.0491399314556, 78.1351896369235, 78.3057925867868, 78.5114547241235, + # 78.7318919099216, 78.9516941612148, 79.1455137994674, 79.2777836955814, + # 79.3071750299046, 79.2089527032148, 78.9822255414714, 78.6497989645542, + # 78.2481502176824, 77.8030174303428, 77.3257693887762, 76.814065732173, + # 76.2659923256175, 75.6984596395346, 75.1477823779312, 74.66740771411, + # 74.3057098446791, 74.0905727971162, 74.0299753705505, 74.11530034614, + # 74.3394964938591, 74.704155847949, 75.219667467046, 75.9015707542142, + # 76.7580360559506, 77.7869948130706, 78.9754033565609, 80.2991540237979, + # 81.7234877505562, 83.2018612557898, 84.6750349752032, 86.076547229449, + # 87.3386690915678, 88.3936477532576, 89.1746925343515, 89.6136824473334, + # 89.6413004538255), tolerance=1e-3) + # expect_equal(bma_indicator$upperCI.Mprime, + # c(100, 100.912670097298, 97.9127659677016, 95.8499701178894, + # 94.671316063692, 89.967762734754, 93.9463008307346, 91.8714213799306, + # 93.5154825557029, 97.2103850587094, 100.604000942243, 98.284833857316, + # 99.5794344914379, 100.058004589596, 96.023948265488, 93.9152620486179, + # 92.8653040381579, 93.6033909233236, 91.3659011269288, 92.2840208179575, + # 91.3889899929472, 95.6265216726726, 100.784686621884, 98.3937767294999, + # 99.0346891492975, 98.5975993343305, 93.7589428156902, 94.0423242183192, + # 90.0355125646069, 89.3574031716457, 88.5411398430671, 88.6128338294964, + # 86.9089757554644, 85.9470043459705, 85.2854508468944, 87.5774486565996, + # 86.1864430155758, 87.6080843176338, 88.2546335849038, 90.2893916629357, + # 91.5802927032084, 93.6644725019474, 97.7541237492462, 100.40716888185, + # 101.115243416602, 101.47662882825, 104.027283069311, 107.464620760871, + # 111.656833538891, 116.888378869377), tolerance=1e-3) }) @@ -122,20 +122,20 @@ test_that("model options", { expect_equal(names(bma_indicator_smooth_det2), c("Year", "Index.Mprime", "lowerCI.Mprime", "upperCI.Mprime", "Index.M", "lowerCI.M", "upperCI.M")) - expect_equal(bma_indicator_smooth_det2$Index.M, - c(100, 95.93909090935, 92.7672496713464, 90.3009486772026, 88.3910564873888, - 86.9135156978769, 85.762962294484, 84.8485307419185, 84.0907145192179, - 83.419528497586, 82.7801742540728, 82.1397126378509, 81.4865697868186, - 80.8283760531123, 80.1769336841978, 79.5395128209959, 78.918912999682, - 78.3155809591785, 77.7374190089791, 77.2025558362917, 76.7390450389058, - 76.3828846793717, 76.173517902885, 76.1536897880308, 76.3699821598276, - 76.8573692438152, 77.6172261446705, 78.6144721564787, 79.7775852704348, - 81.0389454212986, 82.367518378779, 83.7723498196311, 85.3012594012114, - 87.0137904449635, 88.9705565936254, 91.2341498812796, 93.8627067415033, - 96.8850398226239, 100.290874956475, 104.023304761472, 107.984525783209, - 112.054621420101, 116.091278710721, 119.928865688976, 123.379833426503, - 126.238820288326, 128.289739888977, 129.315919102855, 129.111127561621, - 127.494892855453)) + # expect_equal(bma_indicator_smooth_det2$Index.M, + # c(100, 95.93909090935, 92.7672496713464, 90.3009486772026, 88.3910564873888, + # 86.9135156978769, 85.762962294484, 84.8485307419185, 84.0907145192179, + # 83.419528497586, 82.7801742540728, 82.1397126378509, 81.4865697868186, + # 80.8283760531123, 80.1769336841978, 79.5395128209959, 78.918912999682, + # 78.3155809591785, 77.7374190089791, 77.2025558362917, 76.7390450389058, + # 76.3828846793717, 76.173517902885, 76.1536897880308, 76.3699821598276, + # 76.8573692438152, 77.6172261446705, 78.6144721564787, 79.7775852704348, + # 81.0389454212986, 82.367518378779, 83.7723498196311, 85.3012594012114, + # 87.0137904449635, 88.9705565936254, 91.2341498812796, 93.8627067415033, + # 96.8850398226239, 100.290874956475, 104.023304761472, 107.984525783209, + # 112.054621420101, 116.091278710721, 119.928865688976, 123.379833426503, + # 126.238820288326, 128.289739888977, 129.315919102855, 129.111127561621, + # 127.494892855453)) sink(temp) bma_indicatorsmooth_det_sigtheta <- bma(data, @@ -151,20 +151,20 @@ test_that("model options", { expect_equal(names(bma_indicatorsmooth_det_sigtheta), c("Year", "Index.Mprime", "lowerCI.Mprime", "upperCI.Mprime", "Index.M", "lowerCI.M", "upperCI.M")) - expect_equal(bma_indicatorsmooth_det_sigtheta$Index.M, - c(100, 95.1066424835543, 91.3277245037226, 88.4678784823851, - 86.3749875308697, 84.9289578315946, 84.0282642314814, 83.5732818349891, - 83.4603232794704, 83.5779762787929, 83.8203922311029, 84.1037927653868, - 84.3668218409477, 84.5704470720489, 84.6949304070813, 84.7380799523458, - 84.7153660145554, 84.6562107839785, 84.5854974146199, 84.5177530126733, - 84.4571762815342, 84.3988976106347, 84.3321081506402, 84.2405725547339, - 84.1028316496622, 83.8984447989557, 83.6163659513033, 83.2555068082075, - 82.8247269865824, 82.3445098974237, 81.8479674471805, 81.3803882658224, - 80.9967396195252, 80.7479373177327, 80.6761690900314, 80.8158186574453, - 81.1918701375337, 81.8126218286924, 82.6678619340919, 83.7277504340206, - 84.9432933084802, 86.248127439241, 87.5568964352754, 88.7643412067508, - 89.7566668063039, 90.4240705821149, 90.6646901541542, 90.3880341473998, - 89.5124407395943, 87.9667954932412)) + # expect_equal(bma_indicatorsmooth_det_sigtheta$Index.M, + # c(100, 95.1066424835543, 91.3277245037226, 88.4678784823851, + # 86.3749875308697, 84.9289578315946, 84.0282642314814, 83.5732818349891, + # 83.4603232794704, 83.5779762787929, 83.8203922311029, 84.1037927653868, + # 84.3668218409477, 84.5704470720489, 84.6949304070813, 84.7380799523458, + # 84.7153660145554, 84.6562107839785, 84.5854974146199, 84.5177530126733, + # 84.4571762815342, 84.3988976106347, 84.3321081506402, 84.2405725547339, + # 84.1028316496622, 83.8984447989557, 83.6163659513033, 83.2555068082075, + # 82.8247269865824, 82.3445098974237, 81.8479674471805, 81.3803882658224, + # 80.9967396195252, 80.7479373177327, 80.6761690900314, 80.8158186574453, + # 81.1918701375337, 81.8126218286924, 82.6678619340919, 83.7277504340206, + # 84.9432933084802, 86.248127439241, 87.5568964352754, 88.7643412067508, + # 89.7566668063039, 90.4240705821149, 90.6646901541542, 90.3880341473998, + # 89.5124407395943, 87.9667954932412)) })