Skip to content

Commit

Permalink
Removed all tests relating to mdist and optmatch.dlist per #134
Browse files Browse the repository at this point in the history
  • Loading branch information
josherrickson committed May 11, 2018
1 parent 7e3b907 commit e5090a6
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 454 deletions.
4 changes: 2 additions & 2 deletions man/caliper-methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions tests/testthat/test.DistanceSpecification.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,3 @@ test_that("Validating DistSpecs", {
expect_true(validDistanceSpecification(as.InfinitySparseMatrix(m3)))

})

test_that("optmatch.dlist => nodes and arcs", {

# test data: 8 arcs (2 pairs unmatchable in each subgroup)
m1 <- m2 <- matrix(c(1, Inf, 1, 2, 2, Inf), nrow = 2, ncol = 3)

colnames(m1) <- c("A", "B", "C")
rownames(m1) <- c("D", "E")

colnames(m2) <- c("f", "g", "h")
rownames(m2) <- c('i', "j")

odl <- list(m1 = m1, m2 = m2)
class(odl) <- c("optmatch.dlist", "list")

odl.result <- prepareMatching(odl)
expect_equal(dim(odl.result), c(8, 3))
expect_equal(unique(odl.result$treated), as.factor(c("D", "E", "i", "j")))
expect_equal(unique(odl.result$control), as.factor(c("A", "B", "C", "f", "g", "h")))


})
8 changes: 0 additions & 8 deletions tests/testthat/test.InfinitySparseMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,6 @@ test_that("Get subproblem size of each block", {
expect_equivalent(as.list(subdim(m)), list(dim(m)))
expect_equivalent(as.list(subdim(a)), list(dim(a)))

# test on optmatch.dlist
od <- list(matrix(c(0,0,0,0, Inf,Inf,Inf,Inf, rep(0, 12)), nrow = 2, ncol = 10, dimnames = list(letters[1:2], letters[3:12])),
matrix(c(0,0,0,0, rep(Inf, 16)), byrow = T, nrow = 5, ncol = 4, dimnames = list(letters[10:14], letters[15:18])))

class(od) <- c("optmatch.dlist", "list")

expect_equal(subdim(od), list(c(2, 10), c(5, 4)))

# test on DenseMatrix
W <- rnorm(16)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test.Optmatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ test_that("Subsetting drops any matched.distances attributes", {

test_that("Summary properly handles matched.distances #106", {
data(nuclearplants)
dist <- mdist(glm(pr~.-(pr+cost), family=binomial(),
dist <- match_on(glm(pr~.-(pr+cost), family=binomial(),
data=nuclearplants))

pm <- pairmatch(dist, data=nuclearplants)
Expand Down
31 changes: 0 additions & 31 deletions tests/testthat/test.caliper.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,6 @@ test_that("Caliper respects groups", {
# expect_equal(sum(is.na(f(m + em))), 4)
})

test_that("calipers for optmatch.dlist", {
m1 <- m2 <- matrix(c(1, Inf, 1, 2, 2, Inf), nrow = 2, ncol = 3)

colnames(m1) <- c("A", "B", "C")
rownames(m1) <- c("D", "E")

colnames(m2) <- c("f", "g", "h")
rownames(m2) <- c('i', "j")

odl <- list(m1 = m1, m2 = m2)
class(odl) <- c("optmatch.dlist", "list")

cal.res <- caliper(odl, 1.5)

expect_true(inherits(cal.res, "InfinitySparseMatrix")) # gets promoted
expect_equal(length(cal.res), 4) # two entries in each block are less than 1.5
})

test_that("update() caliper objects", {
Z <- rep(c(0,1), each = 10)
Expand All @@ -91,18 +74,4 @@ test_that("update() caliper objects", {
names(S) <- letters[1:20]
updated <- update(basic)
expect_equal(length(updated), 10)

# now repeat with optmatch.dlist objects
Z <- rep(c(0,1), each = 10)
S <- rep(1:10 * 2, 2)
names(Z) <- names(S) <- letters[1:20]
optdl <- caliper(mdist(Z ~ S, data = data.frame(Z, S)), 0.11)

# however, results will be ISMs
expect_equal(length(optdl), 28)

optdl.updated <- update(optdl, width = .001)

expect_equal(length(optdl.updated), 10)

})
31 changes: 0 additions & 31 deletions tests/testthat/test.fullmatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,6 @@ test_that("Reversion Test: Proper labeling of NAs", {
expect_warning(res <- pairmatch(caliper(d, 2)))

expect_equal(sum(is.na(res)), 9)

# repeat using an optmatch.dlist object, just in case...
od <- list(matrix(c(0,0,0,0, Inf,Inf,Inf,Inf, rep(0, 12)), nrow = 4, ncol = 5, dimnames = list(letters[1:4], letters[5:9])),
matrix(c(0,0,0,0, rep(Inf, 12)), byrow = T, nrow = 4, ncol = 4, dimnames = list(letters[10:13], letters[14:17])))

class(od) <- c("optmatch.dlist", "list")

expect_warning(expect_equal(sum(is.na(pairmatch(od))), 9))

# while we're at it, check that match failed only indicates that 1 level failed
expect_warning(expect_equal(sum(matchfailed(pairmatch(od))), 8))
})

test_that("Results are in 'data order'", {
Expand Down Expand Up @@ -274,26 +263,6 @@ test_that("Complete Inf matrices/ISMs => all NA optmatch object", {

})

test_that("Both mdist and match_on objects accepted", {
# this test depends on mdist and match_on tests passing
# it will probably fail if those fail

n <- 14
test.data <- data.frame(Z = c(rep(0, n/2), rep(1, n/2)),
X1 = rnorm(n, mean = 5),
X2 = rnorm(n, mean = -2, sd = 2),
B = rep(c(0,1), n/2))

model <- glm(Z ~ X1 + X2, data = test.data, family = binomial())
tmp <- mdist(model)
names(tmp) <- c(1) # mdist adds an 'm' to the front by default
res.mdist <- fullmatch(tmp, data=test.data)
res.mon <- fullmatch(match_on(model), data=test.data)

expect_equivalent(res.mdist, res.mon)

})

test_that("full() and pair() are alises to _match functions", {

n <- 14
Expand Down
176 changes: 0 additions & 176 deletions tests/testthat/test.mdist.R

This file was deleted.

Loading

0 comments on commit e5090a6

Please sign in to comment.