From c1863669ecc7a742c9ce5d504e76a89447240b17 Mon Sep 17 00:00:00 2001 From: Pierre Santagostini <pierre.santagostini@agrocampus-ouest.fr> Date: Tue, 4 Feb 2025 14:42:08 +0100 Subject: [PATCH] Tests estparnormratio --- tests/testthat/test-estparnormratio.R | 35 +++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/testthat/test-estparnormratio.R diff --git a/tests/testthat/test-estparnormratio.R b/tests/testthat/test-estparnormratio.R new file mode 100644 index 0000000..517c67c --- /dev/null +++ b/tests/testthat/test-estparnormratio.R @@ -0,0 +1,35 @@ +set.seed(1234) +x1 <- rnorm(2048, 1, 5) +y1 <- rnorm(2048, 10, 10) +z1 <- x1/y1 +beta1 <- 0.1; rho1 <- 2; delta1 <- 1 +theta1 <- estparnormratio(z1, eps = 1e-6) +test_that("estparnormratio works 1", { + expect_equal(round(theta1$beta, 1), beta1) + expect_equal(round(theta1$rho, 0), rho1) + expect_equal(round(theta1$delta, 1), delta1) +}) + +set.seed(1234) +x2 <- rnorm(2048, 0, 5) +y2 <- rnorm(2048, 10, 10) +z2 <- x2/y2 +beta2 <- 0; rho2 <- 2; delta2 <- 1 +theta2 <- estparnormratio(z2, eps = 1e-6) +test_that("estparnormratio works 2", { + expect_equal(round(theta2$beta, 1), beta2) + expect_equal(round(theta2$rho, 1), rho2) + expect_equal(round(theta2$delta, 1), delta2) +}) + +set.seed(1234) +x3 <- rnorm(2048, -1.5*20, 20/3) +y3 <- rnorm(2048, 20, 20/3*1.5) +z3 <- x3/y3 +beta3 <- -1.5; rho3 <- 1.5; delta3 <- 0.5 +theta3 <- estparnormratio(z3, eps = 1e-6) +test_that("estparnormratio works 3", { + expect_equal(round(theta3$beta, 1), beta3) + expect_equal(round(theta3$rho, 1), rho3) + expect_equal(round(abs(theta3$delta), 2), delta3) +}) -- GitLab