Skip to content

Commit

Permalink
touch up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Sep 18, 2016
1 parent b91b011 commit 8c48366
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 27 deletions.
4 changes: 4 additions & 0 deletions Makefile
Expand Up @@ -20,6 +20,10 @@ check: build
test:
Rscript -e 'library("testthat",quietly=TRUE);library("faoutlier",quietly=TRUE);require("methods",quietly=TRUE);test_dir("tests/testthat")'

paralleltest:
Rscript -e 'library("testthat",quietly=TRUE);library("faoutlier",quietly=TRUE);require("methods",quietly=TRUE);setCluster();test_dir("tests/testthat")'


clean:
$(RM) src/*.o
$(RM) src/*.so
Expand Down
2 changes: 2 additions & 0 deletions README.md
@@ -1,3 +1,5 @@
[![Travis-CI Build Status](https://travis-ci.org/philchalmers/faoutlier.svg?branch=master)](https://travis-ci.org/philchalmers/faoutlier) [![](http://www.r-pkg.org/badges/version/faoutlier)](http://www.r-pkg.org/pkg/faoutlier) ![License](http://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)

#faoutlier

Tools for detecting and summarize influential cases that
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-GOF.R
Expand Up @@ -15,8 +15,8 @@ test_that('GOF run', {

#-------------------------------------------------------------------
suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE))
GOFresult <- GOF(holzinger, model)
GOFresult.outlier <- GOF(holzinger.outlier, model)
GOFresult <- suppressWarnings(GOF(holzinger, model))
GOFresult.outlier <- suppressWarnings(GOF(holzinger.outlier, model))
expect_equal(as.numeric(GOFresult[1:3]), c(-4.945440, -1.943843, -3.330193),
tolerance=1e-5)
expect_is(GOFresult, 'GOF')
Expand Down Expand Up @@ -52,7 +52,7 @@ test_that('GOF categorical', {
F2 =~ MissNum + MxdArit + OddWrds
F3 =~ Boots + Gloves + Hatchts'

GOFresult <- GOF(dat, model, orthogonal=TRUE, ordered=colnames(dat))
GOFresult <- suppressWarnings(GOF(dat, model, orthogonal=TRUE, ordered=colnames(dat)))
expect_is(GOFresult, 'GOF')
expect_equal(as.numeric(head(GOFresult)),
c(2.392693, -8.217107, -2.637149, -17.303106, 4.298777, -11.997538),
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-LD.R
Expand Up @@ -15,8 +15,8 @@ test_that('LD run', {

#-------------------------------------------------------------------
suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE))
LDresult <- LD(holzinger, model)
LDresult.outlier <- LD(holzinger.outlier, model)
LDresult <- suppressWarnings(LD(holzinger, model))
LDresult.outlier <- suppressWarnings(LD(holzinger.outlier, model))
expect_equal(as.numeric(LDresult[1:3]), c(-4.945440, -1.943843, -3.330193),
tolerance=1e-5)
expect_is(LDresult, 'LD')
Expand Down
20 changes: 9 additions & 11 deletions tests/testthat/test-forward.search.R
@@ -1,25 +1,23 @@
context('forward.search')

setCluster()

test_that('forward.search run', {
test_that('forward.search run', {
set.seed(1234)

#Exploratory
nfact <- 3
FS <- forward.search(holzinger, nfact, print.messages = FALSE)
expect_is(FS, 'forward.search')
expect_is(plot(FS), 'trellis')
expect_equal(FS$GOF[c(1, length(FS$GOF))], c(3.717805, 26.293829), tolerance = 1e-5)
#-------------------------------------------------------------------
suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE))

#-------------------------------------------------------------------
suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE))
FS.outlier <- suppressWarnings(forward.search(holzinger.outlier, model, print.messages = FALSE))
expect_is(FS.outlier, 'forward.search')
expect_is(plot(FS.outlier), 'trellis')
expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))],
expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))],
c(34.64542, 161.01480), tolerance = 1e-5)

#---- lavaan
model <- 'F1 =~ Remndrs + SntComp + WrdMean
F2 =~ MissNum + MxdArit + OddWrds
Expand All @@ -28,7 +26,7 @@ test_that('forward.search run', {
p.base = .7)
expect_is(FS.outlier, 'forward.search')
expect_is(plot(FS.outlier), 'trellis')
expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))],
expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))],
c(26.96743, 111.39844), tolerance = 1e-5)

})
2 changes: 1 addition & 1 deletion tests/testthat/test-gCD.R
Expand Up @@ -14,7 +14,7 @@ test_that('gCD run', {

#-------------------------------------------------------------------
suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE))
gCDresult <- gCD(holzinger, model)
gCDresult <- suppressWarnings(gCD(holzinger, model))
gCDresult.outlier <- suppressWarnings(gCD(holzinger.outlier, model))
expect_is(gCDresult, 'gCD')
expect_is(plot(gCDresult), 'trellis')
Expand Down
20 changes: 10 additions & 10 deletions tests/testthat/test-obs.resid.R
@@ -1,7 +1,7 @@
context('obs.resid')

test_that('obs.resid run', {

#Exploratory
nfact <- 3
ORresult <- obs.resid(holzinger, nfact)
Expand All @@ -11,24 +11,24 @@ test_that('obs.resid run', {
expect_is(ORresult, 'obs.resid')
expect_is(ORresult.outlier, 'obs.resid')
expect_is(plot(ORresult), 'trellis')
expect_is(plot(ORresult.outlier), 'trellis')
#-------------------------------------------------------------------
suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE))
ORresult <- obs.resid(holzinger, model)
ORresult.outlier <- obs.resid(holzinger.outlier, model)
expect_is(plot(ORresult.outlier), 'trellis')

#-------------------------------------------------------------------
suppressMessages(model <- sem::specifyModel(file='sem-model/sem-model.txt', quiet=TRUE))
ORresult <- suppressWarnings(obs.resid(holzinger, model))
ORresult.outlier <- suppressWarnings(obs.resid(holzinger.outlier, model))
expect_equal(ORresult$std_res[1:3], c(0.2548177, -0.5300287, -1.8518586),
tolerance = 1e-5)
expect_is(ORresult, 'obs.resid')
expect_is(ORresult.outlier, 'obs.resid')
expect_is(plot(ORresult), 'trellis')
expect_is(plot(ORresult.outlier), 'trellis')
#-------------------------------------------------------------------

#-------------------------------------------------------------------
model <- 'F1 =~ Remndrs + SntComp + WrdMean
F2 =~ MissNum + MxdArit + OddWrds
F3 =~ Boots + Gloves + Hatchts'

obs.resid2 <- obs.resid(holzinger, model, orthogonal=TRUE)
obs.resid2.outlier <- obs.resid(holzinger.outlier, model, orthogonal=TRUE)
expect_equal(ORresult$std_res[1:3], c(0.2548177, -0.5300287, -1.8518586),
Expand Down

0 comments on commit 8c48366

Please sign in to comment.