set.seed(1)
target <- distr6::Normal$new()
chain <- (sampler_mcmc(make_distr6_pdf(target), start = 0, sigma_prop = 1))[[1]]
test_that("Plot levy_flights", {
plot <- plot_levy(chain, plot=FALSE)
expect_equal(mode(plot), "list")
expect_equal_to_reference(plot_levy(chain), "levytest.txt")
})
test_that("Plot psd", {
plot <- plot_PSD(chain, plot = FALSE)
expect_equal(mode(plot), "list")
expect_equal_to_reference(plot_PSD(chain), "psd.txt")
expect_error(plot_PSD(matrix(c(1,2,3,4), ncol = 2)), "Please input a one-dimensional vector")
})
test_that("Plot qqplot", {
expect_equal_to_reference(plot_qqplot(chain), "qqplot_change.txt")
expect_equal_to_reference(plot_qqplot(chain, change = FALSE), "qqplot_normal.txt")
expect_error(plot_qqplot(matrix(c(1,2,3,4), ncol = 2)), "Please input a one-dimensional vector")
})
test_that("Plot Sigma Scaling", {
plot <- plot_sigma_scaling(chain, plot=FALSE)
expect_equal(mode(plot), "numeric")
expect_equal_to_reference(plot_sigma_scaling(chain), "sigmaScaling.txt")
expect_error(plot_sigma_scaling(matrix(c(1,2,3,4), ncol = 2)), "Please input a one-dimensional vector")
})
test_that("Plot Autocorrelation", {
expect_equal_to_reference(plot_autocorr(chain), "ac_change.txt")
expect_equal_to_reference(plot_autocorr(chain, changeACF = FALSE), "ac_normal.txt")
expect_error(plot_autocorr(matrix(c(1,2,3,4), ncol = 2)), "Please input a one-dimensional vector")
})
test_that("Plot Series", {
expect_equal_to_reference(plot_series(chain), "series.txt")
expect_equal_to_reference(plot_change(chain), "change.txt")
expect_error(plot_series(matrix(c(1,2,3,4), ncol = 2)), "Please input a one-dimensional vector")
expect_error(plot_change(matrix(c(1,2,3,4), ncol = 2)), "Please input a one-dimensional vector")
})
test_that("Plot All", {
expect_equal_to_reference(plot_all(chain), "all.txt")
expect_error(plot_all(matrix(c(1,2,3,4), ncol = 2)), "Please input a one-dimensional vector")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.