# Help for bayesian SEM

**URL:** https://discourse.mc-stan.org/t/help-for-bayesian-sem/39571
**Category:** Modeling
**Created:** [May 25, 2025, 1:04pm UTC](https://discourse.mc-stan.org/t/help-for-bayesian-sem/39571 "2025-05-25T13:04:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![JJJfff](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@JJJfff](https://discourse.mc-stan.org/u/JJJfff)
#### Post date: [May 25, 2025, 1:04pm UTC](https://discourse.mc-stan.org/t/help-for-bayesian-sem/39571/1 "2025-05-25T13:04:39Z")

</div>

I am trying to test an interaction term within an SEM framework using _lavaan_ by creating a product indicator. However, a Heywood case occurred, so I am attempting to resolve this using the Bayesian approach.

While running the Bayesian SEM, I encountered several error messages, and I would like some advice on how to address them:

1. Would it be better to increase the number of chains, or should I increase `alpha_delta`? I’ve read that increasing `alpha_delta` is a last resort, so I’m hesitant to do so.
2. When I ran a CFA without the interaction term, the model fit was acceptable. But once I added the interaction term, variables related to `friend_bond` started having estimation issues. Would it be reasonable to remove those variables? I’m concerned that arbitrarily removing variables might be statistically problematic.
3. I used the default prior distributions because I’m not very familiar with setting them. Should I modify them?

Please excuse my English, as I used a translator.

Below is the model specification:

```stan
##family:Physic_health (13~20 + )
subj_dat <- indProd(subj_dat, var1 = 13:20, var2 = c("health", "health_satis"), match = FALSE,
                    meanC = TRUE, residualC = FALSE, doubleMC = TRUE)

##friend_bond:Physic_health (21~24 + )
subj_dat <- indProd(subj_dat, var1 = 21:24, var2 = c("health", "health_satis"), match = FALSE,
                    meanC = TRUE, residualC = FALSE, doubleMC = TRUE)

##family_bond:Mental_health (13~24 + )
subj_dat <- indProd(subj_dat, var1 = 13:20, var2 = c("stress", "depress"), match = FALSE,
                    meanC = TRUE, residualC = FALSE, doubleMC = TRUE)

##friend_bond:Mental_health (21~24 + )
subj_dat <- indProd(subj_dat, var1 = 21:24, var2 = c("stress", "depress"), match = FALSE,
                    meanC = TRUE, residualC = FALSE, doubleMC = TRUE)

intmodel <- "
              ##latent_var
              Physic_health =~ health + health_satis
              Mental_health =~ stress + depress
              family_bond =~ family_bond_253+family_bond_254+family_bond_255+family_bond_256
                             +family_bond_257+family_bond_258+family_bond_259+family_bond_260
              friend_bond =~ friend_bond_271+friend_bond_272
              
              ##int_var
              family_bond_Physic_health =~ family_bond_253.health + family_bond_253.health_satis + family_bond_254.health 
                                          + family_bond_254.health_satis + family_bond_255.health + family_bond_255.health_satis 
                                          + family_bond_256.health + family_bond_256.health_satis + family_bond_257.health 
                                          + family_bond_257.health_satis + family_bond_258.health + family_bond_258.health_satis 
                                          + family_bond_259.health + family_bond_259.health_satis + family_bond_260.health 
                                          + family_bond_260.health_satis

              family_bond_Mental_health =~ family_bond_253.stress + family_bond_253.depress + family_bond_254.stress + 
                                          family_bond_254.depress + family_bond_255.stress + family_bond_255.depress + 
                                          family_bond_256.stress + family_bond_256.depress + family_bond_257.stress + 
                                          family_bond_257.depress + family_bond_258.stress + family_bond_258.depress + 
                                          family_bond_259.stress + family_bond_259.depress + family_bond_260.stress + 
                                          family_bond_260.depress
              
              friend_bond_Physic_health =~ friend_bond_263.health + friend_bond_263.health_satis + friend_bond_264.health +
                                          friend_bond_264.health_satis + friend_bond_271.health + friend_bond_271.health_satis 
                                          + friend_bond_272.health + friend_bond_272.health_satis
              
              friend_bond_Mental_health =~ friend_bond_263.stress + friend_bond_263.depress + friend_bond_264.stress + 
                                          friend_bond_264.depress + friend_bond_271.stress + friend_bond_271.depress + 
                                          friend_bond_272.stress + friend_bond_272.depress

              #regression
              suic_ideation ~ Physic_health + Mental_health + family_bond + friend_bond +
                             family_bond_Physic_health + family_bond_Mental_health +
                             friend_bond_Physic_health + friend_bond_Mental_health
                    
            "

blav_cfa_fit <- bcfa(intmodel, data=subj_dat, n.chains = 5)
summary(blav_cfa_fit, standardized = TRUE, rsquare = TRUE)
fitmeasures(blav_cfa_fit)

```

And here are the results:

```stan
1: blavaan WARNING: the chains may not have converged. 
2: 
591 (23.5%) p_waic estimates greater than 0.4. We recommend trying loo instead. 
3: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
 
4: blavaan WARNING: some effective number of parameter computations are < 0. This may indicate prior-data conflict or other model problems. 
> summary(blav_cfa_fit)$psrf %>% 
+ as.data.frame() %>% 
+ filter(Point.Estimate > 1.1 | is.na(Point.Estimate))
blavaan 0.5.8 did NOT end normally after 1000 iterations
**WARNING** Estimates below are most likely unreliable

  Estimator BAYES
  Optimization method MCMC
  Number of model parameters 161

  Number of observations 2510

  Statistic MargLogLik PPP
  Value -155596.980 0.000

Parameter Estimates:

Latent Variables:
                               Estimate Post.SD pi.lower pi.upper Rhat Prior       
  Physic_health =~                                                                         
    health 1.000                                                    
    health_satis 3.347 0.318 2.797 4.046 1.002 normal(0,10)
  Mental_health =~                                                                         
    stress 1.000                                                    
    depress 3.590 0.327 3.023 4.304 1.009 normal(0,10)
  family_bond =~                                                                           
    family_bnd_253 1.000                                                    
    family_bnd_254 1.006 0.040 0.927 1.086 1.007 normal(0,10)
    family_bnd_255 1.199 0.045 1.112 1.291 1.011 normal(0,10)
    family_bnd_256 1.170 0.042 1.090 1.256 1.012 normal(0,10)
    family_bnd_257 1.194 0.042 1.112 1.281 1.009 normal(0,10)
    family_bnd_258 1.150 0.040 1.068 1.233 1.006 normal(0,10)
    family_bnd_259 1.061 0.039 0.989 1.138 1.014 normal(0,10)
    family_bnd_260 1.091 0.037 1.020 1.166 1.007 normal(0,10)
  friend_bond =~                                                                           
    friend_bnd_271 1.000                                                    
    friend_bnd_272 1.357 0.060 1.212 1.445 1.036 normal(0,10)
  family_bond_Physic_health =~                                                             
    fmly_bnd_253.h 1.000                                                    
    fmly_bnd_253._ 3.227 0.144 2.968 3.519 1.021 normal(0,10)
    fmly_bnd_254.h 0.755 0.048 0.663 0.852 1.005 normal(0,10)
    fmly_bnd_254._ 2.622 0.133 2.370 2.893 1.011 normal(0,10)
    fmly_bnd_255.h 1.146 0.057 1.041 1.263 1.009 normal(0,10)
    fmly_bnd_255._ 3.639 0.159 3.341 3.971 1.005 normal(0,10)
    fmly_bnd_256.h 1.101 0.055 0.995 1.212 1.006 normal(0,10)
    fmly_bnd_256._ 3.598 0.160 3.306 3.930 1.013 normal(0,10)
    fmly_bnd_257.h 1.125 0.056 1.020 1.236 1.005 normal(0,10)
    fmly_bnd_257._ 3.579 0.156 3.289 3.900 1.012 normal(0,10)
    fmly_bnd_258.h 1.074 0.053 0.969 1.181 1.007 normal(0,10)
    fmly_bnd_258._ 3.434 0.152 3.145 3.746 1.010 normal(0,10)
    fmly_bnd_259.h 1.011 0.049 0.918 1.112 1.006 normal(0,10)
    fmly_bnd_259._ 3.376 0.148 3.096 3.668 1.006 normal(0,10)
    fmly_bnd_260.h 1.181 0.054 1.078 1.292 1.008 normal(0,10)
    fmly_bnd_260._ 3.694 0.155 3.410 4.020 1.013 normal(0,10)
  family_bond_Mental_health =~                                                             
    fmly_bnd_253.s 1.000                                                    
    fmly_bnd_253.d 1.998 0.121 1.775 2.238 1.163 normal(0,10)
    fmly_bnd_254.s 0.888 0.036 0.819 0.963 1.005 normal(0,10)
    fmly_bnd_254.d 1.786 0.126 1.554 2.042 1.122 normal(0,10)
    fmly_bnd_255.s 1.246 0.045 1.166 1.334 1.008 normal(0,10)
    fmly_bnd_255.d 2.553 0.148 2.288 2.859 1.152 normal(0,10)
    fmly_bnd_256.s 1.154 0.042 1.077 1.241 1.006 normal(0,10)
    fmly_bnd_256.d 2.254 0.135 2.010 2.534 1.147 normal(0,10)
    fmly_bnd_257.s 1.130 0.041 1.050 1.214 1.006 normal(0,10)
    fmly_bnd_257.d 2.292 0.134 2.046 2.572 1.120 normal(0,10)
    fmly_bnd_258.s 1.125 0.041 1.048 1.210 1.004 normal(0,10)
    fmly_bnd_258.d 2.337 0.140 2.087 2.631 1.166 normal(0,10)
    fmly_bnd_259.s 0.910 0.035 0.844 0.981 1.006 normal(0,10)
    fmly_bnd_259.d 1.787 0.119 1.575 2.041 1.152 normal(0,10)
    fmly_bnd_260.s 1.018 0.037 0.949 1.094 1.014 normal(0,10)
    fmly_bnd_260.d 2.052 0.123 1.827 2.303 1.159 normal(0,10)
  friend_bond_Physic_health =~                                                             
    frnd_bnd_263.h 1.000                                                    
    frnd_bnd_263._ 2.885 0.146 2.607 3.177 1.014 normal(0,10)
    frnd_bnd_264.h 1.142 0.064 1.014 1.271 1.018 normal(0,10)
    frnd_bnd_264._ 3.028 0.168 2.713 3.374 1.036 normal(0,10)
    frnd_bnd_271.h 1.542 0.074 1.404 1.688 1.005 normal(0,10)
    frnd_bnd_271._ 4.435 0.262 3.938 4.960 1.042 normal(0,10)
    frnd_bnd_272.h 1.596 0.073 1.459 1.744 1.003 normal(0,10)
    frnd_bnd_272._ 4.590 0.264 4.105 5.119 1.039 normal(0,10)
  friend_bond_Mental_health =~                                                             
    frnd_bnd_263.s 1.000                                                    
    frnd_bnd_263.d 3.012 1.852 1.273 6.067 5.565 normal(0,10)
    frnd_bnd_264.s 1.300 0.118 1.050 1.517 1.118 normal(0,10)
    frnd_bnd_264.d 3.283 1.882 1.463 6.459 5.141 normal(0,10)
    frnd_bnd_271.s 2.137 0.621 1.190 2.895 4.413 normal(0,10)
    frnd_bnd_271.d 5.320 3.856 1.849 11.719 5.810 normal(0,10)
    frnd_bnd_272.s 2.290 0.675 1.250 3.111 4.409 normal(0,10)
    frnd_bnd_272.d 5.315 3.735 1.951 11.503 5.752 normal(0,10)

Regressions:
                   Estimate Post.SD pi.lower pi.upper Rhat Prior       
  suic_ideation ~                                                              
    Physic_health -0.010 0.013 -0.037 0.017 1.006 normal(0,10)
    Mental_health 0.044 0.013 0.016 0.071 1.015 normal(0,10)
    family_bond -0.016 0.009 -0.033 0.001 1.010 normal(0,10)
    friend_bond 0.006 0.005 -0.004 0.015 1.002 normal(0,10)
    fmly_bnd_Phys_ 0.028 0.016 -0.003 0.059 1.008 normal(0,10)
    fmly_bnd_Mntl_ -0.055 0.009 -0.073 -0.038 1.011 normal(0,10)
    frnd_bnd_Phys_ 0.002 0.019 -0.037 0.038 1.015 normal(0,10)
    frnd_bnd_Mntl_ 0.013 0.022 -0.025 0.063 1.062 normal(0,10)

Covariances:
                               Estimate Post.SD pi.lower pi.upper Rhat Prior       
  Physic_health ~~                                                                         
    Mental_health 0.053 0.006 0.042 0.066 1.004 lkj_corr(1)
    family_bond -0.038 0.005 -0.048 -0.030 1.005 lkj_corr(1)
    friend_bond -0.029 0.005 -0.039 -0.019 1.003 lkj_corr(1)
    fmly_bnd_Phys_ -0.011 0.002 -0.015 -0.007 1.004 lkj_corr(1)
    fmly_bnd_Mntl_ -0.001 0.003 -0.007 0.004 1.003 lkj_corr(1)
    frnd_bnd_Phys_ -0.006 0.002 -0.009 -0.003 1.002 lkj_corr(1)
    frnd_bnd_Mntl_ -0.001 0.002 -0.005 0.002 1.255 lkj_corr(1)
  Mental_health ~~                                                                         
    family_bond -0.066 0.007 -0.079 -0.053 1.009 lkj_corr(1)
    friend_bond -0.038 0.006 -0.051 -0.025 1.010 lkj_corr(1)
    fmly_bnd_Phys_ -0.004 0.002 -0.009 -0.000 1.005 lkj_corr(1)
    fmly_bnd_Mntl_ -0.011 0.004 -0.019 -0.003 1.006 lkj_corr(1)
    frnd_bnd_Phys_ -0.004 0.002 -0.008 0.000 1.004 lkj_corr(1)
    frnd_bnd_Mntl_ 0.001 0.002 -0.004 0.005 1.089 lkj_corr(1)
  family_bond ~~                                                                           
    friend_bond 0.035 0.005 0.027 0.045 1.006 lkj_corr(1)
    fmly_bnd_Phys_ 0.006 0.002 0.003 0.010 1.002 lkj_corr(1)
    fmly_bnd_Mntl_ 0.006 0.003 0.001 0.012 1.005 lkj_corr(1)
    frnd_bnd_Phys_ 0.003 0.002 -0.000 0.006 1.002 lkj_corr(1)
    frnd_bnd_Mntl_ 0.002 0.002 -0.001 0.006 1.080 lkj_corr(1)
  friend_bond ~~                                                                           
    fmly_bnd_Phys_ 0.002 0.002 -0.003 0.006 1.005 lkj_corr(1)
    fmly_bnd_Mntl_ 0.003 0.004 -0.004 0.011 1.009 lkj_corr(1)
    frnd_bnd_Phys_ 0.001 0.002 -0.003 0.005 1.013 lkj_corr(1)
    frnd_bnd_Mntl_ -0.007 0.003 -0.011 -0.001 1.314 lkj_corr(1)
  family_bond_Physic_health ~~                                                             
    fmly_bnd_Mntl_ 0.013 0.002 0.011 0.017 1.011 lkj_corr(1)
    frnd_bnd_Phys_ 0.012 0.001 0.010 0.014 1.005 lkj_corr(1)
    frnd_bnd_Mntl_ 0.002 0.001 -0.000 0.004 1.532 lkj_corr(1)
  family_bond_Mental_health ~~                                                             
    frnd_bnd_Phys_ 0.003 0.001 0.001 0.006 1.005 lkj_corr(1)
    frnd_bnd_Mntl_ 0.013 0.003 0.007 0.019 2.074 lkj_corr(1)
  friend_bond_Physic_health ~~                                                             
    frnd_bnd_Mntl_ 0.007 0.002 0.004 0.011 2.246 lkj_corr(1)

Variances:
                   Estimate Post.SD pi.lower pi.upper Rhat Prior       
   .health 0.272 0.012 0.249 0.295 1.001 gamma(1,.5)[sd]
   .health_satis 0.860 0.103 0.641 1.050 1.002 gamma(1,.5)[sd]
   .stress 0.524 0.020 0.486 0.564 1.008 gamma(1,.5)[sd]
   .depress 2.941 0.194 2.545 3.294 1.003 gamma(1,.5)[sd]
   .family_bnd_253 0.188 0.006 0.177 0.201 1.007 gamma(1,.5)[sd]
   .family_bnd_254 0.273 0.009 0.256 0.290 1.016 gamma(1,.5)[sd]
   .family_bnd_255 0.281 0.009 0.264 0.300 1.002 gamma(1,.5)[sd]
   .family_bnd_256 0.264 0.009 0.247 0.284 1.022 gamma(1,.5)[sd]
   .family_bnd_257 0.241 0.008 0.226 0.257 1.001 gamma(1,.5)[sd]
   .family_bnd_258 0.242 0.008 0.227 0.257 1.000 gamma(1,.5)[sd]
   .family_bnd_259 0.193 0.006 0.180 0.206 1.011 gamma(1,.5)[sd]
   .family_bnd_260 0.156 0.005 0.146 0.167 1.003 gamma(1,.5)[sd]
   .friend_bnd_271 0.228 0.013 0.199 0.248 1.031 gamma(1,.5)[sd]
   .friend_bnd_272 0.019 0.020 0.000 0.069 1.041 gamma(1,.5)[sd]
   .fmly_bnd_253.h 0.098 0.003 0.092 0.104 1.013 gamma(1,.5)[sd]
   .fmly_bnd_253._ 0.481 0.015 0.453 0.511 1.003 gamma(1,.5)[sd]
   .fmly_bnd_254.h 0.134 0.004 0.127 0.142 1.005 gamma(1,.5)[sd]
   .fmly_bnd_254._ 0.629 0.019 0.593 0.664 1.006 gamma(1,.5)[sd]
   .fmly_bnd_255.h 0.143 0.004 0.135 0.152 1.011 gamma(1,.5)[sd]
   .fmly_bnd_255._ 0.554 0.017 0.521 0.589 1.000 gamma(1,.5)[sd]
   .fmly_bnd_256.h 0.134 0.004 0.126 0.142 1.020 gamma(1,.5)[sd]
   .fmly_bnd_256._ 0.579 0.018 0.545 0.614 1.002 gamma(1,.5)[sd]
   .fmly_bnd_257.h 0.136 0.004 0.128 0.144 1.000 gamma(1,.5)[sd]
   .fmly_bnd_257._ 0.523 0.017 0.490 0.558 1.003 gamma(1,.5)[sd]
   .fmly_bnd_258.h 0.129 0.004 0.121 0.136 1.007 gamma(1,.5)[sd]
   .fmly_bnd_258._ 0.563 0.018 0.529 0.600 1.009 gamma(1,.5)[sd]
   .fmly_bnd_259.h 0.098 0.003 0.092 0.104 1.003 gamma(1,.5)[sd]
   .fmly_bnd_259._ 0.442 0.014 0.416 0.471 1.007 gamma(1,.5)[sd]
   .fmly_bnd_260.h 0.100 0.003 0.094 0.106 1.002 gamma(1,.5)[sd]
   .fmly_bnd_260._ 0.381 0.013 0.356 0.406 1.010 gamma(1,.5)[sd]
   .fmly_bnd_253.s 0.159 0.006 0.149 0.171 1.081 gamma(1,.5)[sd]
   .fmly_bnd_253.d 1.354 0.045 1.266 1.444 1.094 gamma(1,.5)[sd]
   .fmly_bnd_254.s 0.207 0.007 0.195 0.220 1.055 gamma(1,.5)[sd]
   .fmly_bnd_254.d 1.805 0.060 1.657 1.916 1.091 gamma(1,.5)[sd]
   .fmly_bnd_255.s 0.230 0.008 0.215 0.247 1.074 gamma(1,.5)[sd]
   .fmly_bnd_255.d 1.991 0.068 1.858 2.122 1.078 gamma(1,.5)[sd]
   .fmly_bnd_256.s 0.209 0.008 0.194 0.225 1.133 gamma(1,.5)[sd]
   .fmly_bnd_256.d 1.724 0.056 1.617 1.834 1.077 gamma(1,.5)[sd]
   .fmly_bnd_257.s 0.205 0.007 0.191 0.219 1.083 gamma(1,.5)[sd]
   .fmly_bnd_257.d 1.709 0.058 1.600 1.821 1.084 gamma(1,.5)[sd]
   .fmly_bnd_258.s 0.210 0.007 0.196 0.224 1.082 gamma(1,.5)[sd]
   .fmly_bnd_258.d 1.776 0.061 1.660 1.897 1.125 gamma(1,.5)[sd]
   .fmly_bnd_259.s 0.174 0.006 0.163 0.186 1.095 gamma(1,.5)[sd]
   .fmly_bnd_259.d 1.434 0.047 1.341 1.530 1.087 gamma(1,.5)[sd]
   .fmly_bnd_260.s 0.158 0.006 0.147 0.170 1.155 gamma(1,.5)[sd]
   .fmly_bnd_260.d 1.283 0.045 1.196 1.374 1.114 gamma(1,.5)[sd]
   .frnd_bnd_263.h 0.083 0.003 0.078 0.089 1.011 gamma(1,.5)[sd]
   .frnd_bnd_263._ 0.479 0.016 0.450 0.512 1.004 gamma(1,.5)[sd]
   .frnd_bnd_264.h 0.138 0.004 0.130 0.147 1.003 gamma(1,.5)[sd]
   .frnd_bnd_264._ 0.660 0.021 0.621 0.703 1.010 gamma(1,.5)[sd]
   .frnd_bnd_271.h 0.130 0.005 0.121 0.141 1.051 gamma(1,.5)[sd]
   .frnd_bnd_271._ 0.533 0.027 0.481 0.584 1.028 gamma(1,.5)[sd]
   .frnd_bnd_272.h 0.128 0.005 0.119 0.138 1.040 gamma(1,.5)[sd]
   .frnd_bnd_272._ 0.547 0.030 0.492 0.610 1.036 gamma(1,.5)[sd]
   .frnd_bnd_263.s 0.177 0.011 0.161 0.198 2.119 gamma(1,.5)[sd]
   .frnd_bnd_263.d 1.278 0.179 1.011 1.497 4.642 gamma(1,.5)[sd]
   .frnd_bnd_264.s 0.280 0.021 0.250 0.317 2.553 gamma(1,.5)[sd]
   .frnd_bnd_264.d 1.985 0.192 1.678 2.241 3.435 gamma(1,.5)[sd]
   .frnd_bnd_271.s 0.201 0.105 0.106 0.344 14.510 gamma(1,.5)[sd]
   .frnd_bnd_271.d 1.842 0.684 0.929 2.509 11.856 gamma(1,.5)[sd]
   .frnd_bnd_272.s 0.209 0.121 0.099 0.374 14.995 gamma(1,.5)[sd]
   .frnd_bnd_272.d 1.736 0.653 0.859 2.384 11.242 gamma(1,.5)[sd]
   .suic_ideation 0.013 0.000 0.014 1.002 gamma(1,.5)[sd]
    Physic_health 0.097 0.011 0.076 0.120 1.002 gamma(1,.5)[sd]
    Mental_health 0.151 0.018 0.117 0.187 1.007 gamma(1,.5)[sd]
    family_bond 0.145 0.009 0.128 0.162 1.010 gamma(1,.5)[sd]
    friend_bond 0.268 0.016 0.239 0.300 1.019 gamma(1,.5)[sd]
    fmly_bnd_Phys_ 0.035 0.003 0.030 0.040 1.015 gamma(1,.5)[sd]
    fmly_bnd_Mntl_ 0.108 0.007 0.095 0.121 1.040 gamma(1,.5)[sd]
    frnd_bnd_Phys_ 0.028 0.002 0.023 0.033 1.026 gamma(1,.5)[sd]
    frnd_bnd_Mntl_ 0.028 0.010 0.012 0.042 2.994 gamma(1,.5)[sd]

```

---

<div class="post-metadata">

### Author: ![edm](https://avatars.discourse-cdn.com/v4/letter/e/f08c70/32.png) [@edm](https://discourse.mc-stan.org/u/edm)
#### Post date: [May 26, 2025, 7:35pm UTC](https://discourse.mc-stan.org/t/help-for-bayesian-sem/39571/2 "2025-05-26T19:35:06Z")

</div>

This looks like a common situation where the sign indeterminacy of the loadings leads to model nonconvergence. This is a place where it can be helpful to use more informative priors.

If you expect all your observed variables to be positively correlated with each other, I would recommend something like a `normal(1, .4)` prior on the free loadings. The rationale is that you are already fixing one loading to +1 (hence the prior mean), and the sd of .4 represents your expectation that the observed variables will be positively correlated. You would add the following argument to the `bcfa` call:

```no-highlight
dp = dpriors(lambda = "normal(1, .4)")

```

Some more discussion is at the links below

> **[Specifying Prior Distributions](https://ecmerkle.github.io/blavaan/articles/prior.html)**

> **[Opaque Prior Distributions in Bayesian Latent Variable Models| Methodology](https://meth.psychopen.eu/index.php/meth/article/view/11167)**

---

<div class="post-metadata">

### Author: ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)
#### Post date: [May 27, 2025, 9:56pm UTC](https://discourse.mc-stan.org/t/help-for-bayesian-sem/39571/3 "2025-05-27T21:56:41Z")

</div>

Hi, @JJJff and welcome to the Stan forums.

Just a heads up that `lavaan` and `blavaan` are not Stan projects, so this might not be the best place to get help for them. I’d try to help, but I don’t know SEM or the `blavaan` package. Here’s the official site for `blavaan`:

> **[GitHub - ecmerkle/blavaan: An R package for Bayesian structural equation...](https://github.com/ecmerkle/blavaan)**
>
> An R package for Bayesian structural equation modeling

I was surprised to see that we did publish a case study for `blavaan`:

> **[Bayesian Structural Equation Modeling using blavaan](https://mc-stan.org/learn-stan/case-studies/sem.html)**

---

<div class="post-metadata">

### Author: ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)
#### Post date: [May 27, 2025, 10:29pm UTC](https://discourse.mc-stan.org/t/help-for-bayesian-sem/39571/4 "2025-05-27T22:29:38Z")

</div>

> [@Bob\_Carpenter](#):
>
> I was surprised to see that we did publish a case study for `blavaan`

blavaan uses Stan internally and it’s listed on the redesigned Stan website as a tool built on Stan ([Stan Toolkit – Stan](https://mc-stan.org/tools/#software-packages-built-on-stan)), so I think it’s fair game for a Stan case study. As far as I know we don’t have a strict requirement that a case study involve writing Stan code by hand rather than using a package to generate the code.

(Or maybe I misinterpreted what you meant by “surprised”?)

---

<div class="post-metadata">

### Author: ![Ara\_Winter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/ara_winter/32/4284_2.png) [@Ara\_Winter](https://discourse.mc-stan.org/u/Ara_Winter)
#### Post date: [June 4, 2025, 5:59pm UTC](https://discourse.mc-stan.org/t/help-for-bayesian-sem/39571/5 "2025-06-04T17:59:23Z")

</div>

Depending on the type of SEM you are looking at working with I know the brms package (based on Stan) will run piece-wise (?) SEM models. I’d be happy to share my R code and data (a simplified model of the full one we use) so you can see if that will work for you. I find building them in brms works better for my brain.

---

<div class="post-metadata">

### Author: ![Mauricio\_Garnier-Villarre](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/mauricio_garnier-villarre/32/5702_2.png) [@Mauricio\_Garnier-Villarre](https://discourse.mc-stan.org/u/Mauricio_Garnier-Villarre)
#### Post date: [June 5, 2025, 8:03am UTC](https://discourse.mc-stan.org/t/help-for-bayesian-sem/39571/6 "2025-06-05T08:03:39Z")

</div>

I see you are using the double mean center method to create the interaction indicators. I think you could also use the residual method

```r
residualC = TRUE

```

When using the residual indicator products you can then fix the factor correlations to 0, making the model smaller (hopefully easier to estimate). You fix the factor correlations between the interaction factor and their respective “main” factors to 0, as these relations have been remove by the residuals method
