tests/testthat/test-evaluateMatched.R

load(system.file("testdata", "testData_evaluateMatched.RData", package = "IndexNumR"))

test_that("evaluate matched returns the right results when a product disappears", {

  result_pop <- evaluateMatched(CES_sigma_2[-15,], "prices", "quantities", "time", "prodID")
  result_fixedbase <- evaluateMatched(CES_sigma_2[-15,], "prices", "quantities", "time", "prodID", output = "fixedbase")

  expect_equal(e_pop, result_pop)
  expect_equal(e_fixedbase, result_fixedbase)

})

rm(e_pop, e_fixedbase)


test_that("productChanges correctly identifies appearing/disappearing products", {

  df <- CES_sigma_2[-c(3,4,15),]

  expect_equal(productChanges(df, "time", "prodID"),
               list(`3` = list(disappearing = c(1, 2)),
                    `4` = list(appearing = 2),
                    `5` = list(appearing = 1)))

})

Try the IndexNumR package in your browser

Any scripts or data that you put into this service are public.

IndexNumR documentation built on Nov. 11, 2023, 1:07 a.m.