Skip to content

Commit f564412

Browse files
committed
in unit tests, check that jags is installed on system
1 parent 40a1222 commit f564412

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: blavaan
22
Title: Bayesian Latent Variable Analysis
3-
Version: 0.5-9.1370
3+
Version: 0.5-9.1371
44
Authors@R: c(person(given = "Edgar", family = "Merkle",
55
role = c("aut", "cre"),
66
email = "merklee@missouri.edu",

inst/tinytest/tests.blavaan.R

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ x2 <- rnorm(100)
55
y1 <- 0.5 + 2*x1 + rnorm(100)
66
Data <- data.frame(y1 = y1, x1 = x1, x2 = x2)
77

8+
## check that jags is installed
9+
hasjags <- !all(Sys.which(c("jags", "jags-terminal")) == "")
10+
811
model <- ' y1 ~ x1 '
912

1013
## auto convergence in stan
@@ -27,10 +30,12 @@ expect_error(bsem(model2, data=Data, fixed.x=TRUE))
2730

2831
model2 <- ' y1 ~ b1*x1 + b2*x2
2932
b1 == -b2/2 '
30-
fit <- bsem(model2, data=Data, target='jags', adapt=1,
31-
burnin=1, sample=3)
32-
## ensure that == constraints are being respected
33-
expect_true(round(2*fit@Fit@x[1] + fit@Fit@x[2], 5) == 0L)
33+
if (hasjags) {
34+
fit <- bsem(model2, data=Data, target='jags', adapt=1,
35+
burnin=1, sample=3)
36+
## ensure that == constraints are being respected
37+
expect_true(round(2*fit@Fit@x[1] + fit@Fit@x[2], 5) == 0L)
38+
}
3439

3540
## do.fit=FALSE
3641
fit <- bsem(model, data=Data, fixed.x=TRUE, adapt=2,
@@ -84,7 +89,9 @@ HS.model <- ' visual =~ x1 + x2 + x3 '
8489

8590
expect_equal(class(bcfa(HS.model, data=HolzingerSwineford1939, target="stan", do.fit=FALSE, group="school", group.equal=c("intercepts","loadings"), wiggle=c("intercepts"), wiggle.sd=.1))[1], "blavaan")
8691
expect_equal(class(bcfa(HS.model, data=HolzingerSwineford1939, target="stanclassic", do.fit=FALSE, group="school", group.equal=c("intercepts","loadings"), wiggle=c("intercepts"), wiggle.sd=.1))[1], "blavaan")
87-
expect_equal(class(bcfa(HS.model, data=HolzingerSwineford1939, target="jags", do.fit=FALSE, group="school", group.equal=c("intercepts","loadings"), wiggle=c("intercepts"), wiggle.sd=.1))[1], "blavaan")
92+
if (hasjags) {
93+
expect_equal(class(bcfa(HS.model, data=HolzingerSwineford1939, target="jags", do.fit=FALSE, group="school", group.equal=c("intercepts","loadings"), wiggle=c("intercepts"), wiggle.sd=.1))[1], "blavaan")
94+
}
8895

8996
## moment match mcmcextra
9097
set.seed(341)

0 commit comments

Comments
 (0)