diff --git a/R/fit.bayesreg.R b/R/fit.bayesreg.R index 97f0f68..f3d7ff6 100644 --- a/R/fit.bayesreg.R +++ b/R/fit.bayesreg.R @@ -61,7 +61,7 @@ fit.bayesreg <- function(dat, algorithm = "Binomial", draws = 10000) { # parameters to track ParsStage <- c("alpha", "alpha_mu", "ynew", "fit", "fitnew") # - modfile <- paste0(tempdir(), "/Bayesian/Intercept.jags") + modfile <- paste0(tempdir(), "/Intercept.jags") interceptToJags(modfile) # m1 <- do.call(R2jags::jags.parallel, list(data = modelDat, model.file = modfile, @@ -75,7 +75,7 @@ fit.bayesreg <- function(dat, algorithm = "Binomial", draws = 10000) { ParsStage <- c("alpha", "beta", "alpha_mu", "alpha_sigma", "beta_sigma", "beta_mu", "ynew", "fit", "fitnew") # - modfile <- paste0(tempdir(), "/Bayesian/Binomial.jags") + modfile <- paste0(tempdir(), "/Binomial.jags") binomialToJags(modfile) m1 <- do.call(R2jags::jags.parallel, list(data = modelDat, parameters.to.save = ParsStage, model.file = modfile, n.thin = nt, n.iter = ni, n.burnin = nb, n.chains = nc, @@ -88,7 +88,7 @@ fit.bayesreg <- function(dat, algorithm = "Binomial", draws = 10000) { ParsStage <- c("alpha", "beta", "alpha_mu", "alpha_sigma", "beta_sigma", "beta_mu", "ynew", "fit", "fitnew") # jags file. - modfile <- paste0(tempdir(), "/Bayesian/Poisson.jags") + modfile <- paste0(tempdir(), "/Poisson.jags") poissonToJags(modfile) # m1 <- do.call(R2jags::jags.parallel(list(data = modelDat, parameters.to.save = ParsStage, @@ -102,7 +102,7 @@ fit.bayesreg <- function(dat, algorithm = "Binomial", draws = 10000) { ParsStage <- c("alpha", "beta", "alpha_mu", "alpha_sigma", "beta_sigma", "beta_mu", "ynew", "fit", "fitnew") # jags file. - modfile <- paste0(tempdir(), "/Bayesian/Multinomial.jags") + modfile <- paste0(tempdir(), "/Multinomial.jags") multinomialToJags(modfile) # m1 <- do.call(R2jags::jags.parallel, list(data = modelDat, parameters.to.save = ParsStage, diff --git a/tests/testthat/test-bayes.R b/tests/testthat/test-bayes.R new file mode 100644 index 0000000..695a3b7 --- /dev/null +++ b/tests/testthat/test-bayes.R @@ -0,0 +1,18 @@ +context("Bayesian model") + +fl1 <- paste0(tempdir(), "/binjag.jags") +fl2 <- paste0(tempdir(), "/intjag.jags") +fl3 <- paste0(tempdir(), "/muljag.jags") +fl4 <- paste0(tempdir(), "/poijag.jags") +binomialToJags(fl1) +interceptToJags(fl2) +multinomialToJags(fl3) +poissonToJags(fl4) + + +test_that("generating models as jags files", { + expect_equal(TRUE, file.exists(fl1)) + expect_equal(TRUE, file.exists(fl2)) + expect_equal(TRUE, file.exists(fl3)) + expect_equal(TRUE, file.exists(fl4)) +})