Skip to content

Commit

Permalink
rearranged tests so that test MCMC+BAS is on its own issue #35
Browse files Browse the repository at this point in the history
now passes with R CMD check locally
  • Loading branch information
merliseclyde committed Aug 14, 2018
1 parent 8a0e783 commit bd1a17f
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions tests/testthat/test-bas-glm.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,7 @@ test_that("GLM logit", {
method = "deterministic", betaprior = bic.prior(),
family = binomial(), modelprior = uniform()
)

pima_MCBAS <- bas.glm(type ~ ., data = Pima.tr,
method = "MCMC+BAS",
betaprior = bic.prior(),
family = binomial(), modelprior = uniform())
pima_MCMC <- bas.glm(type ~ .,
data = Pima.tr, MCMC.iterations = 1024,
method = "MCMC", betaprior = aic.prior(),
family = binomial(),
modelprior = uniform())
expect_null(diagnostics(pima_MCMC, type = "model"))
expect_error(diagnostics(pima_MCMC, type = "pip"))
expect_equal(pima_BAS$probne0, pima_det$probne0)
expect_equal(pima_BAS$probne0, pima_MCBAS$probne0)
expect_equal(
predict(pima_BAS, type = "link")$fit,
as.vector(fitted(pima_det))
Expand Down Expand Up @@ -112,9 +99,28 @@ test_that("GLM logit", {
expect_equal(pima_BAS$probne0, pima_det$probne0)
})

test_that("missing MCMC.iterations and n.models arg", {
# FIXME issue #28
test_that("diagnostic plot for glm MCMC", {
data(Pima.tr, package="MASS")
pima_MCMC <- bas.glm(type ~ .,
data = Pima.tr, MCMC.iterations = 1024,
method = "MCMC", betaprior = aic.prior(),
family = binomial(),
modelprior = tr.poisson(2,5))
expect_null(diagnostics(pima_MCMC, type = "model"))
expect_error(diagnostics(pima_MCMC, type = "pip"))
})

# FIXME issue #35
test_that("MCMC+BAS: missing MCMC.iterations and n.models arg", {
data(Pima.tr, package = "MASS")
set.seed(1)
pima_BAS <- bas.glm(type ~ .,
data = Pima.tr, method = "BAS",
betaprior = bic.prior(),
family = binomial(),
modelprior = uniform())
set.seed(1)
pima_1 <- bas.glm(type ~ ., data=Pima.tr,
method = "MCMC+BAS",
betaprior = bic.prior(),
Expand All @@ -124,11 +130,13 @@ test_that("missing MCMC.iterations and n.models arg", {
pima_2 <- bas.glm(type ~ ., data = Pima.tr,
method = "MCMC+BAS",
betaprior = bic.prior(),
n.models=128,
MCMC.iterations=10000,
n.models=2^7,
MCMC.iterations=10000, #default
family = binomial(),
modelprior = uniform())
expect_equal(pima_1$probne0, pima_2$probne0)
expect_equal(pima_BAS$probne0, pima_2$probne0)
expect_equal(pima_BAS$n.models, pima_1$n.models)
})

test_that("missing data arg", {
Expand Down

0 comments on commit bd1a17f

Please sign in to comment.