tests/testthat/test-psi_cumsum.R

context("psi_cumsum")

test_that("output is of the same format as input", 
{
  testFormat(psi_cumsum)
})

test_that("Cumulative sums are computed corretly",
{
  x <- c(0, 0, 1, 50, 50)
  X <- cbind(1:5, c(0, 0, 1, 50, 50))

  expect_equal(psi_cumsum(X, constant = 1), 
               Y <- cbind(c(-1.5, -2.5, -2.5, -1.5, 0), c(-1, -2, -2, -0.5, 1)))
})

Try the robcp package in your browser

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

robcp documentation built on April 11, 2025, 6:18 p.m.