tests/testthat/test-help_functions.R

test_that("csolve returns a (generalized) inverse", {
  # Simulate small matrices, one of them singular
  X <- matrix(rnorm(30*30), 30, 30)
  X_sing <- rbind(cbind(X[1:15, 1:15], X[1:15, 1:15]),
                  cbind(X[1:15, 1:15], X[1:15, 1:15]))
  # Check combuted inverses
  expect_equal(csolve(X) %*% X, diag(1, 30))
  expect_equal((csolve(X_sing) %*% X_sing) %*% X_sing, X_sing)
})#TEST_THAT

Try the ddml package in your browser

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

ddml documentation built on Oct. 3, 2024, 1:13 a.m.