Skip to content

Commit

Permalink
fix GOF with new mirt inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Jun 8, 2020
1 parent 19640bc commit 63fd4d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion R/GOF.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ GOF <- function(data, model, M2 = TRUE, progress = TRUE, ...)
LR <- myApply(index, MARGIN=1L, FUN=f_lavaan, progress=progress,
data=data, model=model, ...)
} else if(class(model) == "mirt.model"){
large <- MLmod_full <- mirt::mirt(data=data, model=model, large = TRUE)
large <- MLmod_full <- mirt::mirt(data=data, model=model, large = 'return')
index <- matrix(1L:length(large$Freq[[1L]]))
MLmod_full <- mirt::mirt(data=data, model=model, verbose = FALSE, large=large, ...)
sv <- mirt::mod2values(MLmod_full)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-GOF.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test_that('GOF categorical', {
F2 =~ MissNum + MxdArit + OddWrds
F3 =~ Boots + Gloves + Hatchts'

GOFresult <- suppressWarnings(GOF(dat, model, orthogonal=TRUE, ordered=colnames(dat)))
GOFresult <- suppressWarnings(GOF(dat, model, progress=FALSE, 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 All @@ -63,7 +63,7 @@ test_that('GOF mirt', {
data(LSAT7, package = 'mirt')
dat <- mirt::expand.table(LSAT7)
model <- mirt::mirt.model('F = 1-5')
GOFresult <- GOF(dat, model)
GOFresult <- GOF(dat, model, progress=FALSE)
expect_equal(as.numeric(GOFresult[1:3]), c(0.028003080, 0.001699223, 0.034445923),
tolerance=1e-5)
expect_is(GOFresult, 'GOF')
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-forward.search.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_that('forward.search run', {
expect_is(FS.outlier, 'forward.search')
expect_is(plot(FS.outlier), 'trellis')
expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))],
c(30.5883, 161.01480), tolerance = 1e-5)
c(25.69686, 161.01480), tolerance = 1e-5)

#---- lavaan
model <- 'F1 =~ Remndrs + SntComp + WrdMean
Expand All @@ -27,6 +27,6 @@ test_that('forward.search run', {
expect_is(FS.outlier, 'forward.search')
expect_is(plot(FS.outlier), 'trellis')
expect_equal(FS.outlier$GOF[c(1, length(FS.outlier$GOF))],
c(25.37104, 111.39844), tolerance = 1e-5)
c(29.22207, 111.39844), tolerance = 1e-5)

})

0 comments on commit 63fd4d3

Please sign in to comment.