@@ -5,6 +5,9 @@ x2 <- rnorm(100)
55y1 <- 0.5 + 2 * x1 + rnorm(100 )
66Data <- 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+
811model <- ' y1 ~ x1 '
912
1013# # auto convergence in stan
@@ -27,10 +30,12 @@ expect_error(bsem(model2, data=Data, fixed.x=TRUE))
2730
2831model2 <- ' 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
3641fit <- bsem(model , data = Data , fixed.x = TRUE , adapt = 2 ,
@@ -84,7 +89,9 @@ HS.model <- ' visual =~ x1 + x2 + x3 '
8489
8590expect_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" )
8691expect_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
9097set.seed(341 )
0 commit comments