tests/testthat/test_ValAR.R

library(quantdr)

test_that("the function returns an error when y is multivariate response", {
  data(edhec, package = "PerformanceAnalytics")
  y <- cbind(as.vector(edhec[, 1]), as.vector(edhec[, 2]))
  tau <- 0.05
  p <- 5
  expect_error(ValAR(y, p, tau = tau), )
})

test_that("the function returns an error when n is less than p", {
  data(edhec, package = "PerformanceAnalytics")
  y <- as.vector(edhec[1:4, 2])
  tau <- 0.05
  p <- 5
  expect_error(ValAR(y, p, tau = tau), )
})

test_that("the function returns an error when tau is more than one-dimension", {
  data(edhec, package = "PerformanceAnalytics")
  y <- as.vector(edhec[, 2])
  tau <- c(0.01, 0.05)
  p <- 5
  expect_error(ValAR(y, p, tau = tau), )
})

test_that("the function returns an error when tau is outside the (0, 1) interval", {
  data(edhec, package = "PerformanceAnalytics")
  y <- as.vector(edhec[, 2])
  tau <- 1.1
  p <- 5
  expect_error(ValAR(y, p, tau = tau), )
})

test_that("the function returns an error when the moving window is not an integer", {
  data(edhec, package = "PerformanceAnalytics")
  y <- as.vector(edhec[, 2])
  tau <- 0.05
  p <- 5
  movwind <- 150.5
  expect_error(ValAR(y, p, tau = tau, movwind = movwind), )
})

test_that("the function returns an error when the moving window exceeds the number of observations", {
  data(edhec, package = "PerformanceAnalytics")
  y <- as.vector(edhec[, 2])
  tau <- 0.05
  p <- 5
  movwind <- 400
  expect_error(ValAR(y, p, tau = tau, movwind = movwind), )
})

Try the quantdr package in your browser

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

quantdr documentation built on May 9, 2022, 5:08 p.m.