tests/testthat/test-copula.R

context("copula")

test_that("copula behaves as it should", {
  skip_on_cran()
  skip_on_travis()

    fun <- function(d) apply(d,2,function(x)(1:n)[rank(x)])/(1+n)
    n <- 200

    u2 <- cbind(sample(n),sample(n))
    d2 <- fun(u2)

    u3 <- cbind(sample(n),sample(n),sample(n))
    d3 <- fun(u3)

    expect_equal(d2, copula(u2)$copula, label="copula:2dimensional")
    expect_equal(d3, copula(u3)$copula, label="copula:3dimensional")
})

test_that("copula throws errors", {
    expect_error(copula(TRUE), label="copula:exception")
    expect_error(copula("text"), label="copula:exception")
})

test_that("copula fails for data frames without numerics", {
    dat <- data.frame(x=letters, stringsAsFactors=FALSE)
    expect_error(copula(dat))
})

test_that("copula warns if it drops variables", {
    dat <- data.frame(x=letters,
                      y=seq_along(letters),
                      stringsAsFactors=FALSE)
    expect_warning(copula(dat))
})

Try the texmex package in your browser

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

texmex documentation built on Dec. 4, 2020, 5:08 p.m.