test_that("coint_maki works with basic input", { set.seed(123) n <- 100 e1 <- rnorm(n) e2 <- rnorm(n) x <- cumsum(e1) y <- 0.5 * x + cumsum(e2) y[51:100] <- y[51:100] + 2 data <- cbind(y, x) result <- coint_maki(data, m = 1, model = 0) expect_s3_class(result, "maki_test") expect_true(is.numeric(result$statistic)) expect_true(is.numeric(result$breakpoints)) expect_length(result$critical_values, 3) expect_true(is.logical(result$reject_5)) }) test_that("cv_coint_maki returns correct dimensions", { cv <- cv_coint_maki(100, m = 1, model = 0) expect_length(cv, 3) expect_true(all(!is.na(cv))) expect_true(cv[1] < cv[2]) # 1% < 5% expect_true(cv[2] < cv[3]) # 5% < 10% }) test_that("input validation works", { expect_error(coint_maki(1:10, m = 1), "must be a matrix") expect_error(coint_maki(matrix(1:10, ncol = 1), m = 1), "at least 2 columns") expect_error(coint_maki(matrix(1:20, ncol = 2), m = 6), "must be between 0 and 5") expect_error(coint_maki(matrix(1:20, ncol = 2), m = 1, model = 4), "must be 0, 1, 2, or 3") }) test_that("different models produce different results", { set.seed(456) n <- 100 data <- cbind(cumsum(rnorm(n)), cumsum(rnorm(n))) r0 <- coint_maki(data, m = 1, model = 0) r1 <- coint_maki(data, m = 1, model = 1) expect_false(identical(r0$statistic, r1$statistic)) }) test_that("print method works", { set.seed(789) n <- 50 data <- cbind(cumsum(rnorm(n)), cumsum(rnorm(n))) result <- coint_maki(data, m = 1, model = 0) expect_output(print(result), "Maki Cointegration Test") expect_output(print(result), "Test Statistic") }) test_that("m=0 works (no breaks)", { set.seed(111) n <- 80 data <- cbind(cumsum(rnorm(n)), cumsum(rnorm(n))) result <- coint_maki(data, m = 0, model = 0) expect_s3_class(result, "maki_test") expect_null(result$breakpoints) }) test_that("m=2 works (two breaks)", { set.seed(222) n <- 150 x <- cumsum(rnorm(n)) y <- 0.5 * x + cumsum(rnorm(n)) y[51:100] <- y[51:100] + 1 y[101:150] <- y[101:150] + 2 data <- cbind(y, x) result <- coint_maki(data, m = 2, model = 0) expect_s3_class(result, "maki_test") expect_length(result$breakpoints, 2) })