BiologicalRecordsCentre / sparta

Species Presence/Absence R Trends Analyses
http://biologicalrecordscentre.github.io/sparta/index.html
MIT License
21 stars 24 forks source link

Changes made so max_year can be specified. #48

Closed CharlieOuthwaite closed 6 years ago

CharlieOuthwaite commented 6 years ago

Changes made to the occDetFunc function so that the max_year parameter can be set to be beyond the years of the data. Makes max_year a parameter that can be set and makes changes needed to the zst table so that initial values are created for these extra years.

Max_year also added to the occDetModel function.

AugustT commented 6 years ago

── 1. Error: Test occDetFunc with defaults (@testoccDetFunc.r#55) ───────────── invalid 'times' argument 1: occDetFunc(taxa_name = "a", n_iterations = 50, burnin = 15, occDetdata = visitData$occDetdata, spp_vis = visitData$spp_vis, write_results = FALSE, seed = 111) at testthat/testoccDetFunc.r:55 2: replicate(n_chains, initiate(z = zst, nyear = nyear, bugs_data = bugs_data), simplify = F) 3: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify) 4: lapply(X = X, FUN = FUN, ...) 5: FUN(X[[i]], ...) 6: initiate(z = zst, nyear = nyear, bugs_data = bugs_data) ── 2. Error: Test occDetFunc with model types (@testoccDetFunc.r#79) ────────── invalid 'times' argument 1: occDetFunc(taxa_name = "a", n_iterations = 50, burnin = 15, occDetdata = visitData$occDetdata, spp_vis = visitData$spp_vis, write_results = FALSE, seed = 111, modeltype = c("indran", "centering", "halfcauchy")) at testthat/testoccDetFunc.r:79 2: replicate(n_chains, initiate(z = zst, nyear = nyear, bugs_data = bugs_data), simplify = F) 3: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify) 4: lapply(X = X, FUN = FUN, ...) 5: FUN(X[[i]], ...) 6: initiate(z = zst, nyear = nyear, bugs_data = bugs_data) ── 3. Error: Test occDetFunc with julian date (@testoccDetFunc.r#258) ──���────── invalid 'times' argument 1: occDetFunc(taxa_name = "a", n_iterations = 50, burnin = 15, occDetdata = visitData$occDetdata, spp_vis = visitData$spp_vis, write_results = FALSE, seed = 111, modeltype = c("ranwalk", "intercept", "inversegamma", "jul_date")) at testthat/testoccDetFunc.r:258 2: replicate(n_chains, initiate(z = zst, nyear = nyear, bugs_data = bugs_data), simplify = F) 3: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify) 4: lapply(X = X, FUN = FUN, ...) 5: FUN(X[[i]], ...) 6: initiate(z = zst, nyear = nyear, bugs_data = bugs_data) ── 4. Error: Test occDetFunc with catagorical list length (@testoccDetFunc.r#306 invalid 'times' argument 1: occDetFunc(taxa_name = "a", n_iterations = 50, burnin = 15, occDetdata = visitData$occDetdata, spp_vis = visitData$spp_vis, write_results = FALSE, seed = 111, modeltype = c("ranwalk", "intercept", "inversegamma", "catlistlength")) at testthat/testoccDetFunc.r:306 2: replicate(n_chains, initiate(z = zst, nyear = nyear, bugs_data = bugs_data), simplify = F) 3: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify) 4: lapply(X = X, FUN = FUN, ...) 5: FUN(X[[i]], ...) 6: initiate(z = zst, nyear = nyear, bugs_data = bugs_data) ── 5. Error: Test occDetModel (@testoccDetModel.r#32) ───────────────────────── invalid 'times' argument 1: occDetModel(taxa = df$taxa, write_results = FALSE, site = df$site, time_period = df$time_period, species_list = c("a", "m", "g"), n_iterations = 100, burnin = 10, thinning = 2, seed = 111) at testthat/testoccDetModel.r:32 2: occDetFunc(taxa_name = taxa_name, occDetdata = visitData$occDetdata, spp_vis = visitData$spp_vis, n_iterations = n_iterations, burnin = burnin, thinning = thinning, n_chains = n_chains, write_results = write_results, output_dir = output_dir, nyr = nyr, modeltype = modeltype, regional_codes = regional_codes, region_aggs = region_aggs, model.function = model.function, seed = seed, max_year = max_year, additional.parameters = additional.parameters, additional.BUGS.elements = additional.BUGS.elements, additional.init.values = additional.init.values, return_data = return_data) 3: replicate(n_chains, initiate(z = zst, nyear = nyear, bugs_data = bugs_data), simplify = F) 4: sapply(integer(n), eval.parent(substitute(function(...) expr)), simplify = simplify) 5: lapply(X = X, FUN = FUN, ...) 6: FUN(X[[i]], ...) 7: initiate(z = zst, nyear = nyear, bugs_data = bugs_data)

AugustT commented 6 years ago

I think i worked it out

codecov-io commented 6 years ago

Codecov Report

Merging #48 into master will increase coverage by 3.9%. The diff coverage is 55.55%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #48     +/-   ##
========================================
+ Coverage    28.6%   32.5%   +3.9%     
========================================
  Files          79      79             
  Lines        2895    2907     +12     
========================================
+ Hits          828     945    +117     
+ Misses       2067    1962    -105
Impacted Files Coverage Δ
R/occDetModel.r 94.44% <100%> (+0.15%) :arrow_up:
R/occDetFunc.r 80.42% <50%> (+24.86%) :arrow_up:
R/formatOccData.r 96.15% <0%> (+0.15%) :arrow_up:
R/getModelFile.R 95.12% <0%> (+62.19%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ceae3e3...378cbb1. Read the comment docs.