test_that("pickands_plot returns a data.frame with k and xi_hat columns", { set.seed(1) x <- rpareto(500, alpha = 2, xm = 1) tmp <- tempfile(fileext = ".pdf"); pdf(tmp) out <- pickands_plot(x) dev.off(); unlink(tmp) expect_s3_class(out, "data.frame") expect_true(all(c("k", "xi_hat") %in% names(out))) expect_true(nrow(out) > 0) # Pickands uses 4k < n, so it has fewer rows than moments_plot on the same data expect_true(nrow(out) <= floor(500 / 4)) }) test_that("pickands_plot works with and without xi_true", { set.seed(1) x <- rpareto(300, alpha = 2, xm = 1) tmp <- tempfile(fileext = ".pdf"); pdf(tmp) expect_no_error(pickands_plot(x)) expect_no_error(pickands_plot(x, xi_true = 0.5)) dev.off(); unlink(tmp) }) test_that("pickands_plot validates inputs", { x <- rpareto(100, alpha = 2, xm = 1) na_data <- c(x[1:5], NA, x[6:10]) expect_error(pickands_plot(as.character(x))) expect_error(pickands_plot(c(1, 2, 3, 4))) # length <= 4 expect_error(pickands_plot(na_data, na.rm = FALSE)) expect_error(pickands_plot(x, xi_true = c(0.5, 1))) })