1

Is it possible to get credible intervals for regression paths using Blavaan package? Or, p-values for the regression estimates?

R Code:

###------------Run Model: 1A----------------###

Model1A <- ' C_ERC_ER ~ Valid + S_CCNES S_CCNES ~ C_attachment Valid ~ C_attachment C_ERC_ER ~ C_attachment #Estimating variances of exogenous variables C_ERC_ER ~~ C_ERC_ER S_CCNES ~~ S_CCNES Valid ~~ Valid

Estimating covariances of exogenous variables

S_CCNES ~~ Valid

' #Estimating residual variances for endogenous variables

###---evaluate model fit---### fit1A <- bsem( Model1A, data=data, n.chains = 2, burnin = 1000, sample = 1000, target = "stan")

coef(fit1A)

Output:

> summary(fit1A) lavaan 0.6-11 ended normally after 1000 iterations

Estimator BAYES Optimization method NLMINB Number of model parameters 12

                                              Used       Total

Number of observations 117 118 Number of missing patterns 2

Model Test User Model:

Test statistic -477.860 Degrees of freedom NA

Test statistic 0.499 Degrees of freedom NA

Parameter Estimates:

Regressions: Estimate C_ERC_ER ~
Valid -0.551 S_CCNES 0.689 S_CCNES ~
C_attachment 0.002 Valid ~
C_attachment -0.000 C_ERC_ER ~
C_attachment 0.048

Covariances: Estimate .S_CCNES ~~
.Valid 0.007

Intercepts: Estimate .C_ERC_ER 5.814 .S_CCNES 5.404 .Valid 0.742

Variances: Estimate .C_ERC_ER 6.144 .S_CCNES 0.706 .Valid 0.076

Jeremy Miles
  • 17,812
  • posterior SDs and interval estimates are usually provided in the summary(), so it looks like your model might not have converged. Were there any warning messages you didn't copy/paste? – Terrence Oct 16 '22 at 07:58
  • Thanks, @Terrence. I received the following warning: "Warning message: In lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: 1 cases were deleted due to missing values in exogenous variable(s), while fixed.x = TRUE." I added fixed.x=FALSE to the bsem argument, with no luck re: posterior SDs/interval estimates. Does this suggest the models have not converged? Or is there another potential solution? Thanks in advance. – kirstenq Oct 16 '22 at 15:54

1 Answers1

0

As @Terrence says, this could be related to convergence issues. Since you are using stan I would suggest first looking at the $\hat{R}$ statistic. $\hat{R}$ > 1.1 are problematic, and for more information see this.

Additionally, as @Terrence says credible intervals should be printed automatically when you apply summary() to a blavaan object. Though when I have used the blavaan R package in the past, I use the highest posterior density region (HPD) - one of many ways to construct Bayesian credible intervals (see this post for more information). In the code chunk below I calculated 95% percentile interval (which, as noted by @Terrence is not always equivalent to the HPD) using a dataset that can be found in the blavaan package (also see this post for a discussion of the 95% HPD in the context the blavaan package).

## Packages 
library(lavaan)
library(blavaan)
## The industrialization and Political Democracy Example
## Bollen (1989), page 332
model <- '
  # latent variable definitions
     ind60 =~ x1 + x2 + x3
     dem60 =~ y1 + a*y2 + b*y3 + c*y4
     dem65 =~ y5 + a*y6 + b*y7 + c*y8

regressions

dem60 ~ ind60
dem65 ~ ind60 + dem60

residual correlations

y1 ~~ y5
y2 ~~ y4 + y6
y3 ~~ y7
y4 ~~ y8
y6 ~~ y8

'

unique priors for mv intercepts; parallel chains

fit <- bsem(model, data=PoliticalDemocracy, dp=dpriors(nu="normal(5,10)")) fitIndices <- blavFitIndices(fit)

Calculating HPD 95% CI

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

  • Thank you very much, @Preston, for your comprehensive response. It seems the models are converging well (based on the rhats). I used the HDP 95% CI code you provided and it worked perfectly. I appreciate your help. Thanks again. – kirstenq Oct 16 '22 at 22:13
  • No problem! Glad it helped. – Preston Botter Oct 16 '22 at 22:32
  • 1
    Good answer, but some suggested edits: (1) R-hat > 1.1 (not < 1.1) is problematic, (2) the syntax provides a way to obtain percentile intervals, not (necessarily) the highest-density region. HDIs can be obtained fairly easily, though, using the HDInterval package – Terrence Oct 17 '22 at 19:22
  • Thank you for these updates @Terrence. I was able to re-run the analyses and obtain the percentile intervals (via summary ()) and also make use of the HDInterval package. I understand that the credible interval implies that there is a 95% probability the estimate falls within this interval. However, I am wondering if the CI does not contain 0, does this imply the regression path is significant? Or, is there a more appropriate way to conceptualize/report CIs? This paper http://doi: 10.1016/j.bjpt.2018.12.006 has been helpful but I am still unsure. Thank you again for your help. – kirstenq Oct 17 '22 at 22:00
  • 1
    That is one way to test a null hypothesis in the Bayesian framework. That is still an active area of development. See this recent paper: https://doi.org/10.1111/bmsp.12267 – Terrence Oct 20 '22 at 08:30
  • Thanks, @Terrence! I (1) changed the R-hat interpretation and specified I was using percentile intervals. I briefly tried to use the HDInterval package to calculate the 95% CI but had problems. I will try again later in the week when I have the time! – Preston Botter Oct 20 '22 at 19:57