pi.lower or hpd. Standardized hpd.

320 views
Skip to first unread message

Sebastien Mas

unread,
Jul 6, 2020, 5:45:29 AM7/6/20
to blavaan
Hello,

In the Blavaan summary section for bsem function, I don't have the hpd anymore but pi.low and pi.uppe instaed. Is it the same indicator? How can I set it to 95% (hpd command doesn't work anymore). I don't even know what is the default prob parameter.

I also wonder if is possible to have the standardized hpd values (or pi if it is similar)?

Thx you very much for your help :)

Saisissez le code ici.IBCMeffiBsem <- bsem(IBCMModel, data=KT1, target = "stan", bcontrol = list(cores=6), dp = my_priors)
summary
(IBCMeffiBsem,standardized = TRUE)


blavaan (0.3-9) results of 1000 samples after 500 adapt/burnin iterations

 
Number of observations                           114

 
Number of missing patterns                         1

 
Statistic                                 MargLogLik         PPP
 
Value                                      -1901.985       0.386

Regressions:
                   
Estimate  Post.SD pi.lower pi.upper   Std.lv  Std.all     Rhat    Prior      
  BHV
~                                                                                          
    T1_ACT  
(PABH)    0.104    0.049    0.013    0.202    0.104    0.264    0.999 normal(0,10000)
   
PstBhv  (PBBH)    0.011    0.121   -0.224    0.248    0.011    0.011    0.999 normal(0,10000)
    T1_INT  
(INTB)    0.075    0.023     0.03     0.12    0.075    0.349    0.999 normal(0,10000)
    T1_CP  
(PBCB)    0.012    0.034   -0.054    0.078    0.012    0.037    0.999 normal(0,10000)
  T1_INT
~                                                                                      
    RAI    
(RAII)    0.089    0.020    0.051    0.126    0.089    0.561    1.001 normal(0,10000)
    T1_ATT  
(ATTI)    0.090    0.183   -0.263    0.447    0.090    0.062    1.000 normal(0,10000)
    T1_NS  
(NSIN)   -0.033    0.140    -0.31    0.232   -0.033   -0.017    1.001 normal(0,10000)
    T1_CP  
(PBCI)    0.247    0.145   -0.037    0.523    0.247    0.171    1.000 normal(0,10000)
  T1_ACTPLAN
~                                                                                  
    T1_INT  
(AINT)    0.119    0.047    0.026    0.208    0.119    0.219    0.999 normal(0,10000)
    T1_CP  
(PBCP)    0.232    0.067    0.102    0.367    0.232    0.297    0.999 normal(0,10000)
   
PstBhv (PsBPA)    1.062    0.212     0.64    1.456    1.062    0.391    1.000 normal(0,10000)
  T1_ATT
~                                                                                      
    RAI    
(RAIA)    0.090    0.005    0.079    0.101    0.090    0.829    0.999 normal(0,10000)
  T1_NS
~                                                                                        
    RAI    
(RAIN)    0.033    0.007    0.021    0.045    0.033    0.413    0.999 normal(0,10000)
  T1_CP
~                                                                                        
    RAI    
(RAIP)    0.081    0.007    0.068    0.094    0.081    0.736    0.999 normal(0,10000)
  RAI
~                                                                                          
   
PstBhv  (PBRA)   18.975    2.247   14.595   23.487   18.975    0.602    1.000 normal(0,10000)
   
Saautr  (PASR)    1.774    0.692    0.465    3.145    1.774    0.190    1.000 normal(0,10000)
 
Saautre ~                                                                                      
   
PstBhv (PBPAS)    0.983    0.306    0.373    1.566    0.983    0.291    0.999 normal(0,10000)

Covariances:
                   
Estimate  Post.SD pi.lower pi.upper   Std.lv  Std.all     Rhat    Prior      
 
.T1_ATT ~~                                                                                      
   
.T1_CP             0.327    0.104    0.139    0.545    0.327    0.323    1.000       beta(1,1)

Intercepts:
                   
Estimate  Post.SD pi.lower pi.upper   Std.lv  Std.all     Rhat    Prior      
   
.BHV               0.761    0.160    0.444    1.072    0.761    1.495    1.000 normal(0,10000)
   
.T1_INT            0.823    0.729   -0.602    2.278    0.823    0.346    1.002 normal(0,10000)
   
.T1_ACTPLAN       -0.755    0.314   -1.373    -0.16   -0.755   -0.586    1.000 normal(0,10000)
   
.T1_ATT            2.799    0.144    2.516    3.084    2.799    1.725    0.999 normal(0,10000)
   
.T1_NS             2.995    0.171    2.661    3.331    2.995    2.521    1.000 normal(0,10000)
   
.T1_CP             3.327    0.180    2.976    3.694    3.327    2.020    1.000 normal(0,10000)
   
.RAI             -18.914    4.385  -27.537  -10.417  -18.914   -1.264    1.000 normal(0,10000)
   
.Saautre           3.315    0.527    2.301    4.343    3.315    2.068    1.000 normal(0,10000)

Variances:
                   
Estimate  Post.SD pi.lower pi.upper   Std.lv  Std.all     Rhat    Prior      
   
.BHV               0.171    0.025     0.13    0.225    0.171    0.662    1.000 gamma(1,.5)[sd]
   
.T1_INT            2.534    0.347    1.948    3.307    2.534    0.448    1.000 gamma(1,.5)[sd]
   
.T1_ACTPLAN        0.726    0.101    0.552    0.955    0.726    0.436    0.999 gamma(1,.5)[sd]
   
.T1_ATT            0.823    0.112    0.635     1.06    0.823    0.312    0.999 gamma(1,.5)[sd]
   
.T1_NS             1.171    0.160    0.899    1.518    1.171    0.829    0.999 gamma(1,.5)[sd]
   
.T1_CP             1.245    0.166    0.967      1.6    1.245    0.459    1.000 gamma(1,.5)[sd]
   
.RAI             119.933   16.109   92.563  154.706  119.933    0.536    1.000 gamma(1,.5)[sd]
   
.Saautre           2.352    0.329    1.796    3.062    2.352    0.915    0.999 gamma(1,.5)[sd]

Defined Parameters:
                   
Estimate  Post.SD pi.lower pi.upper   Std.lv  Std.all     Rhat    Prior      
   
ATTIntBehav       0.007    0.014   -0.021    0.035    0.007    0.021       NA                
   
NSIntBehav       -0.002    0.011   -0.024    0.019   -0.002   -0.006       NA                
   
PBCIntBehav       0.018    0.013   -0.007    0.043    0.018    0.060       NA                
   
PBCplanaBhv       0.024    0.014   -0.002    0.051    0.024    0.079       NA                
   
PBCBHVfull        0.043    0.018    0.007    0.078    0.043    0.138       NA                
   
RAIintBHV         0.007    0.003    0.002    0.012    0.007    0.196       NA                
   
RAIATTintBHV      0.075       NA       NA       NA    0.075    0.314       NA                
   
RAINSintBHV         Inf       NA       NA       NA      Inf      Inf       NA                
   
RAIPBCintBHV      0.001    0.001   -0.001    0.004    0.001    0.044       NA                
    RAIPBCBHV        
0.001    0.003   -0.005    0.006    0.001    0.028       NA                
    RAIPBCPLANABHV    
0.002    0.001        0    0.004    0.002    0.058       NA                
   
RAIBHVfull          Inf       NA       NA       NA      Inf      Inf       NA                
    PAS_RAI_INT_BH    
0.012    0.007   -0.001    0.025    0.012    0.037       NA                
    PAS_RAI_ATT_IN    
0.001    0.001        0    0.002    0.001    0.031       NA                
    PAS_RAI_NS_INT  
-0.000    0.001   -0.002    0.001   -0.000   -0.000       NA                
    PAS_RAI_PBC_IN    
0.003    0.002   -0.002    0.007    0.003    0.008       NA                
    PAS_RAI_PBC_BH    
0.002    0.005   -0.009    0.012    0.002    0.005       NA                
    PAS_RAI_PBC_PA    
0.003    0.003   -0.002    0.009    0.003    0.011       NA                
    PAS_BHV_full      
0.021    0.010        0    0.041    0.021    0.092       NA                
    PB_RAI_INT_BHV    
0.126    0.050    0.028    0.224    0.126    0.118       NA                
    PB_RAI_ATT_INT    
0.011    0.025   -0.037     0.06    0.011    0.011       NA                
    PB_RAI_NS_INT_  
-0.002    0.007   -0.015    0.012   -0.002   -0.001       NA                
    PB_RAI_PBC_INT    
0.028    0.020   -0.012    0.068    0.028    0.026       NA                
    PB_RAI_PBC_BHV    
0.018    0.053   -0.087    0.122    0.018    0.017       NA                
    PB_RAI_PBC_PAB    
0.037    0.022   -0.005     0.08    0.037    0.035       NA                
    PB_PAS_RAI_INT    
0.012    0.008   -0.004    0.027    0.012    0.011       NA                
    PB_PAS_RAI_ATT    
0.001    0.003   -0.004    0.006    0.001    0.001       NA                
    PB_PAS_RAI_NS_  
-0.000    0.001   -0.002    0.001   -0.000   -0.000       NA                
    PB_PAS_RAI_PBC    
0.003    0.002   -0.002    0.007    0.003    0.002       NA                
    PB_PAS_RAI_PBC    
0.002    0.006   -0.009    0.012    0.002    0.002       NA                
    PB_PAS_RAI_PBC    
0.003    0.003   -0.002    0.009    0.003    0.003       NA                
   
PstBhv_PlA_BHV    0.111    0.058   -0.003    0.224    0.111    0.103       NA                
   
PstBhv_BHV_fll    0.351    0.080    0.193    0.508    0.351    0.327       NA                




Ed Merkle

unread,
Jul 7, 2020, 12:40:08 AM7/7/20
to Sebastien Mas, blavaan
Sebastian,

I need to look at this in detail sometime soon... JAGS provides hpd but Stan does not, and I think that is the source of the problem. The default "target" changed from JAGS to Stan in a previous version, then I realized later that the summary output was still printing HPD even though the Stan intervals were not HPD.

I will send a more informative message after I look at it. For Stan, it might be the case that you need to export the MCMC samples and compute HPD intervals manually.

Best,
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/blavaan/906b78ec-63d3-4c0e-b0a2-97352fd9fa8ao%40googlegroups.com.

sebm...@gmail.com

unread,
Jul 7, 2020, 4:02:32 AM7/7/20
to blavaan
Thx for your answer.

I have tried running a jags analysis but I still have pi lower and upper in the summary. Could it be linked to a package I use (or do not use)...? Furthermore, most of the time I have to unload and reload Blavaan otherwise I got a Lavaan result in the summary (instead of Blavaan) with only the estimates. Another bug I didn't have with the previous version 6 months ago.

Do you know if pi is similar to hpd ? Can we set it to 95% CI? How can I get the standardized version ?

Thx a lot for your help

Ed Merkle

unread,
Jul 7, 2020, 5:05:08 PM7/7/20
to sebm...@gmail.com, blavaan
Sebastien,

See below...

On Tue, 2020-07-07 at 01:02 -0700, sebm...@gmail.com wrote:
Thx for your answer.

I have tried running a jags analysis but I still have pi lower and upper in the summary. Could it be linked to a package I use (or do not use)...?

Yes, the label will be the same regardless of target. But JAGS is still providing HPD, whereas Stan is providing prediction interval (credible interval). I need to fix the labels to be more accurate in a future version.

Furthermore, most of the time I have to unload and reload Blavaan otherwise I got a Lavaan result in the summary (instead of Blavaan) with only the estimates. Another bug I didn't have with the previous version 6 months ago.

This commonly happens if you do library(lavaan) after library(blavaan). It happens because a blavaan object inherits from a lavaan object, so R can get confused about which summary() method to use. When you load blavaan, you also load lavaan, so an extra library(lavaan) should not be necessary.


Do you know if pi is similar to hpd ?

PI and HPD intervals will often be similar, which is the reason why I missed the labeling issue. The difference is summarized here (see first two bullets under "choosing a credible interval"):


Can we set it to 95% CI?

The summary() output automatically provides a 95% interval.

How can I get the standardized version ?

Look at the standardizedPosterior() function; this provides posterior draws of standardized parameters. Intervals could be obtained via

stdpost <- standardizedPosterior(fit)
apply(stdpost, 2, quantile, c(.025,.975))

Ed

sebm...@gmail.com

unread,
Jul 8, 2020, 3:16:13 AM7/8/20
to blavaan
Wahouu ! Thx you very much for this comprehensive answer !! I will try your propositions for stdpost.

For Jags, I tried that :   bsem(IBCMModel, data=KT1, convergence = "auto", target = "jags")
and I got a pi (not a HPD). But it's not important at the moment. I will try to understand that latter.

Thx again. Have a nice day.
Reply all
Reply to author
Forward
0 new messages