Blavaan: Prior Predictive Check Error

28 views
Skip to first unread message

Gabe Avakian Orona

unread,
May 18, 2024, 4:42:31 AMMay 18
to blavaan
Hi All,

Any help with how to obtain the prior predictive check in blavaan? I followed these steps on the ecmerkle page, but receive the following two errors: 

Stan model 'stanmarg' does not contain samples.

AND:

> bfit3 <- bsem(b3, data = osf, std.lv=TRUE, prisamp = T) Error in eval(mc, parent.frame()) : Exception: mismatch in dimension declared and found in context; processing stage=data initialization; variable name=YXbar; position=0; dims declared=(16,12); dims found=(1,12) (in 'string', line 513, column 2 to column 60) failed to create the sampler; sampling not done Computing post-estimation metrics (including lvs if requested)... Stan model 'stanmarg' does not contain samples. Error in rowvec[samppar] <- which(grepl(stanvec[j], names(b.est)) & !(grepl("_c\\[", : replacement has length zero

Here is my full model:

b3 <- '
RT1 =~
prior("normal(0.81, .30)")*CRT1 +  
prior("normal(0.50, .30)")*BBS1 +
prior("normal(0.72, .30)")*BRN1 +
prior("normal(0.37, .30)")*WAS1
# Time 2: Reflective Thinking
RT2 =~
prior("normal(0.81, .30)")*CRT2 +
prior("normal(0.81, .30)")*CRT4 +
prior("normal(0.81, .30)")*CRTv +
prior("normal(0.50, .30)")*BBS2 +
prior("normal(0.72, .30)")*BRN2 +
prior("normal(0.37, .30)")*WAS2
# Regression
RT2 ~ c*trt + prior("normal(0.65, .40)")*RT1 + prior("normal(0.35, .15)")*logDT + b*logDT
logDT ~ prior("normal(0.22, .20)")*trt + a*trt

# Estimated/Generated Quantities
IndirectEffect_ab := a*b
TotalEffect := (a*b)+c
# Correlated Uniqueness
BRN1 ~~ BRN2
WAS1 ~~ WAS2
BBS1 ~~ BBS2
CRT1 ~~ CRT2
'
#_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

The error occurs without the indirect effects, as well.

Thank you for any help you can offer!

Best,
Gabe

Ed Merkle

unread,
May 20, 2024, 4:16:01 PMMay 20
to Gabe Avakian Orona, blavaan
Gabe,

Thanks for the report. I haven't been able to reproduce this error using the CRAN version of blavaan (0.5-4) or the github version of blavaan. Is there a chance you are on an earlier version of blavaan, or perhaps an earlier version of lavaan (earlier than 0.6-17)?

Ed
--
You received this message because you are subscribed to the Google Groups "blavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blavaan+u...@googlegroups.com.

Gabe Avakian Orona

unread,
May 21, 2024, 12:48:22 PMMay 21
to Ed Merkle, blavaan
Hi Ed, 

Thank you for looking into this. I'm using .5-2
image.png


However, the issue does NOT occur when I use different data, such as the one in your example online. 

Gabe
--
Gabe Avakian Orona, Ph.D.

Postdoctoral Research Fellow
Hector Research Institute of Education Sciences and Psychology
University of Tübingen
gabrie...@uni-tuebingen.de

Ed Merkle

unread,
May 21, 2024, 1:08:28 PMMay 21
to Gabe Avakian Orona, blavaan
Thanks for the info. Are you able to upgrade to 0.5-4 or the github version? I believe this error may have been fixed in more recent versions (or, at least, some related errors have been fixed).

Ed


On Tue, 2024-05-21 at 18:48 +0200, Gabe Avakian Orona wrote:
Hi Ed, 

Thank you for looking into this. I'm using .5-2

Gabe Avakian Orona

unread,
May 22, 2024, 3:37:32 AMMay 22
to Ed Merkle, blavaan
Hi Ed,

Yes, I was able to upgrade to 0.5-4. However, the same error occurs:
image.png

Any assistance would be greatly appreciated. (I also tried this on two different computers--same result.)

Thank you very much, Ed. 

Best,
Gabe

Ed Merkle

unread,
May 22, 2024, 2:19:05 PMMay 22
to Gabe Avakian Orona, blavaan
Thanks for following up. I dug deeper and can reproduce this when the dataset has missing values.

For now, I think the workaround is to eliminate missing data from your dataset when you use prisamp = TRUE. This shouldn't have any influence on results because you are sampling from priors, and the data are not involved in the sampling. But I should also be able to fix it soon to avoid the error.

Ed


On Wed, 2024-05-22 at 09:37 +0200, Gabe Avakian Orona wrote:
Hi Ed,

Yes, I was able to upgrade to 0.5-4. However, the same error occurs:

Gabe Avakian Orona

unread,
May 24, 2024, 3:46:50 AMMay 24
to Ed Merkle, blavaan
Hi Ed,

Thank you very much. That worked great. Appreciate your help.

Best,
Gabe
Reply all
Reply to author
Forward
0 new messages