|
1 | 1 | if (require("testthat") && require("modelbased") && require("rstanarm") && require("insight") && require("brms") && require("lme4")) {
|
2 | 2 | test_that("estimate_response - Bayesian", {
|
3 |
| - model <- rstanarm::stan_glm(mpg ~ wt + poly(cyl, 2, raw = TRUE), data = mtcars, refresh = 0, iter = 500, chains = 2) |
| 3 | + model <- rstanarm::stan_glm(mpg ~ wt + poly(cyl, 2, raw = TRUE), data = mtcars, refresh = 0, iter = 200, chains = 2) |
4 | 4 | estim <- estimate_response(model, seed = 333)
|
5 | 5 | testthat::expect_equal(nrow(estim), nrow(mtcars))
|
6 | 6 |
|
7 |
| - model <- rstanarm::stan_glm(mpg ~ wt * as.factor(gear), data = mtcars, refresh = 0, iter = 500, chains = 2) |
| 7 | + model <- rstanarm::stan_glm(mpg ~ wt * as.factor(gear), data = mtcars, refresh = 0, iter = 200, chains = 2) |
8 | 8 | estim <- estimate_response(model, data = "grid", seed = 333)
|
9 | 9 | testthat::expect_equal(c(nrow(estim), ncol(estim)), c(43, 5))
|
10 | 10 |
|
11 |
| - model <- rstanarm::stan_glm(mpg ~ as.factor(gear) / wt, data = mtcars, refresh = 0, iter = 500, chains = 2) |
| 11 | + model <- rstanarm::stan_glm(mpg ~ as.factor(gear) / wt, data = mtcars, refresh = 0, iter = 200, chains = 2) |
12 | 12 | estim <- estimate_response(model)
|
13 | 13 | testthat::expect_equal(c(nrow(estim), ncol(estim)), c(32, 5))
|
14 | 14 |
|
15 |
| - model <- rstanarm::stan_glm(Sepal.Width ~ Petal.Width, data = iris, refresh = 0, iter = 500, chains = 2) |
| 15 | + model <- rstanarm::stan_glm(Sepal.Width ~ Petal.Width, data = iris, refresh = 0, iter = 200, chains = 2) |
16 | 16 | estim <- estimate_link(model, keep_draws = TRUE)
|
17 | 17 | draws <- reshape_draws(estim)
|
18 |
| - testthat::expect_equal(c(nrow(draws), ncol(draws)), c(12500, 7)) |
| 18 | + testthat::expect_equal(c(nrow(draws), ncol(draws)), c(5000, 7)) |
19 | 19 |
|
20 | 20 | # Polr
|
21 |
| - model <- rstanarm::stan_polr(Species ~ Petal.Width + Petal.Length, data = iris, refresh = 0, iter = 500, chains = 2, prior = rstanarm::R2(0.2, "mean")) |
| 21 | + model <- rstanarm::stan_polr(Species ~ Petal.Width + Petal.Length, data = iris, refresh = 0, iter = 200, chains = 2, prior = rstanarm::R2(0.2, "mean")) |
22 | 22 | estim <- estimate_link(model, length = 5)
|
23 | 23 | testthat::expect_equal(c(nrow(estim), ncol(estim)), c(25, 5))
|
24 | 24 |
|
25 | 25 | # Non-sampling algorithms
|
26 |
| - model <- rstanarm::stan_glm(mpg ~ drat, data = mtcars, algorithm = "meanfield", refresh=0) |
27 |
| - estim <- estimate_link(model, keep_draws = TRUE) |
28 |
| - testthat::expect_equal(c(nrow(estim), ncol(estim)), c(25, 1004)) |
| 26 | + # model <- rstanarm::stan_glm(mpg ~ disp, data = mtcars, algorithm = "meanfield", refresh=0) |
| 27 | + # estim <- estimate_link(model, keep_draws = TRUE) |
| 28 | + # testthat::expect_equal(c(nrow(estim), ncol(estim)), c(25, 1004)) |
29 | 29 |
|
30 | 30 | # model <- brms::brm(mpg ~ drat, data = mtcars, algorithm = "meanfield", refresh=0)
|
31 | 31 | # estim <- estimate_link(model, keep_draws = TRUE)
|
|
0 commit comments