Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ Suggests:
rmarkdown,
rprojroot,
scales,
testthat,
testthat (>= 3.0.0),
tibble,
tidyr
Depends:
R (>= 3.5.0)
Config/testthat/edition: 3
46 changes: 28 additions & 18 deletions tests/testthat/test-ci.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
context("load testing data")

# Load the ratios sample dataset for testing
data("ratios_sample")

# Extract the components of the dataframe as vectors
ratio <- ratios_sample$ratio
sale_price <- ratios_sample$sale_price
Expand All @@ -11,7 +8,6 @@ assessed <- ratios_sample$assessed


##### TEST COD CI #####
context("test cod_ci function")

# Calculate PRB CI
cod_ci_out_95 <- cod_ci(ratio, nboot = 1000)
Expand All @@ -24,8 +20,12 @@ test_that("returns expected type", {
})

test_that("output equal to expected", {
expect_equivalent(cod_ci_out_95, c(16.49595, 18.84529), tolerance = 0.04)
expect_equivalent(cod_ci_out_80, c(16.83710, 18.79953), tolerance = 0.04)
expect_equal(cod_ci_out_95, c(16.49595, 18.84529),
tolerance = 0.04, ignore_attr = TRUE
)
expect_equal(cod_ci_out_80, c(16.83710, 18.79953),
tolerance = 0.04, ignore_attr = TRUE
)
})

test_that("bad input data stops execution", {
Expand All @@ -43,16 +43,17 @@ test_that("incomplete data returns NAs unless removed", {
cod_ci(c(ratio, NA)),
NA_real_
)
expect_equivalent(
expect_equal(
cod_ci(c(ratio, NA), nboot = 1000, na.rm = TRUE),
c(16.49595, 18.84529),
tolerance = 0.04
tolerance = 0.04,
ignore_attr = TRUE
)
})



##### TEST PRD CI #####
context("test prb_ci function")

# Calculate PRB CI
prd_ci_out_95 <- prd_ci(assessed, sale_price, nboot = 1000)
Expand All @@ -65,8 +66,12 @@ test_that("returns expected type", {
})

test_that("output equal to expected", {
expect_equivalent(prd_ci_out_95, c(1.034447, 1.062625), tolerance = 0.04)
expect_equivalent(prd_ci_out_80, c(1.038444, 1.058439), tolerance = 0.04)
expect_equal(prd_ci_out_95, c(1.034447, 1.062625),
tolerance = 0.04, ignore_attr = TRUE
)
expect_equal(prd_ci_out_80, c(1.038444, 1.058439),
tolerance = 0.04, ignore_attr = TRUE
)
})

test_that("bad input data stops execution", {
Expand All @@ -85,17 +90,17 @@ test_that("incomplete data returns NAs unless removed", {
prd_ci(c(assessed, NA), c(sale_price, 10e5)),
NA_real_
)
expect_equivalent(
expect_equal(
prd_ci(c(assessed, NA), c(sale_price, 10e5), na.rm = TRUE),
c(1.034447, 1.062625),
tolerance = 0.04
tolerance = 0.04,
ignore_attr = TRUE
)
})



##### TEST PRB CI #####
context("test prb_ci function")

# Calculate PRB CI
prb_ci_out_95 <- prb_ci(assessed, sale_price)
Expand All @@ -108,8 +113,12 @@ test_that("returns expected type", {
})

test_that("output equal to expected", {
expect_equivalent(prb_ci_out_95, c(-0.01404379, 0.01899536), tolerance = 0.04)
expect_equivalent(prb_ci_out_80, c(-0.00831969, 0.01327127), tolerance = 0.04)
expect_equal(prb_ci_out_95, c(-0.01404379, 0.01899536),
tolerance = 0.04, ignore_attr = TRUE
)
expect_equal(prb_ci_out_80, c(-0.00831969, 0.01327127),
tolerance = 0.04, ignore_attr = TRUE
)
})

test_that("bad input data stops execution", {
Expand All @@ -128,9 +137,10 @@ test_that("incomplete data returns NAs unless removed", {
prb_ci(c(assessed, NA), c(sale_price, 10e5)),
NA_real_
)
expect_equivalent(
expect_equal(
prb_ci(c(assessed, NA), c(sale_price, 10e5), na.rm = TRUE),
c(-0.01404379, 0.01899536),
tolerance = 0.04
tolerance = 0.04,
ignore_attr = TRUE
)
})
8 changes: 0 additions & 8 deletions tests/testthat/test-formulas.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("load testing data")

# Load the ratios sample dataset for testing
data("ratios_sample")

Expand Down Expand Up @@ -28,7 +26,6 @@ tiebreaks_Assessed_alt_sort_2 <- mki_tiebreaks$Assessed_alt_sort_2


##### TEST COD #####
context("test cod function")

# Calculate COD
cod_out <- cod(ratio)
Expand Down Expand Up @@ -64,7 +61,6 @@ test_that("standard met function", {


##### TEST PRD #####
context("test prd function")

# Calculate PRD
prd_out <- prd(assessed, sale_price)
Expand Down Expand Up @@ -108,7 +104,6 @@ test_that("standard met function", {


##### TEST PRB #####
context("test prb function")

# Calculate PRB
prb_out <- prb(assessed, sale_price)
Expand Down Expand Up @@ -152,7 +147,6 @@ test_that("standard met function", {


##### TEST MKI #####
context("test mki function")

# Calculate MKI
mki_out <- mki(mki_ki_assessed, mki_ki_sale_price)
Expand Down Expand Up @@ -212,7 +206,6 @@ test_that("all sorting variations return the same MKI (tiebreak data)", {


##### TEST KI #####
context("test ki function")

# Calculate KI
ki_out <- ki(mki_ki_assessed, mki_ki_sale_price)
Expand Down Expand Up @@ -269,7 +262,6 @@ test_that("all sorting variations return return the same ki (tiebreak data)", {


##### TEST Median Ratio #####
context("test median_ratio_met function")

test_that("standard met function", {
expect_true(med_ratio_met(median(ratio)))
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-outliers.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("load testing data")

# Create test vectors of data with certain distributions
set.seed(13378)

Expand All @@ -21,8 +19,6 @@ dist2_qnt_out <- is_outlier(test_dist2, method = "quantile")


##### TEST OUTLIER #####
context("test is_outlier function")

test_that("returns expected type", {
expect_type(dist1_iqr_out, "logical")
expect_vector(dist1_iqr_out)
Expand Down
4 changes: 0 additions & 4 deletions tests/testthat/test-sale_chasing.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("load testing data")

# Load the ratios sample dataset for testing
data("ratios_sample")

Expand All @@ -11,8 +9,6 @@ chased_ratios <- c(rnorm(900, 1, 0.15), rep(1, 100))


##### TEST CHASING DETECTION #####
context("test detect_chashing function")

# Run detection
sample_out <- detect_chasing(sample_ratios)
normal_out <- detect_chasing(normal_ratios)
Expand Down
Loading