Bootstrapped confidence intervals for standardized parameters

222 views
Skip to first unread message

rras...@gmail.com

unread,
Jan 1, 2021, 9:56:30 AM1/1/21
to lavaan
Hi all,
I am running a mediation model in lavaan. I generated bootstrapped confidence intervals for unstandardized parameters using the following codes:

> MedFit <- sem(Mod, missing="fiml.x", data=Fish_data, se = "bootstrap", bootstrap = 2000)
> parameterEstimates(MedFit, boot.ci.type="bca.simple")

I wonder whether it is possible to generate similar bootstrapped confidence intervals for standardized parameters.
Thank you so much,
Ranaivo

car...@web.de

unread,
Jan 1, 2021, 8:07:44 PM1/1/21
to lav...@googlegroups.com

If you *really* want to do this, then *technically* there are several ways. Assuming you don't want to omit the acceleration procedure (bca.simple is actually bc), you can use the boot package among others. Here is a very simple example (note: no error handler and so on):

library(lavaan)
library(boot)

model <<- '
  # Simplified example
  ind60 =~ x1 + x2 + x3
  dem60 =~ y1 + y2 + y3 + y4
  dem60 ~ b * ind60
'

# Function to obtain standardized value for b
param <- function(d, i) {
  fit <- sem(model, data = d[i,])
  pe <- parameterEstimates(fit, standardized = TRUE)
  return(
    pe[pe$label == "b",]$std.all
  )
}

# Bootstrap
res <- boot(data = PoliticalDemocracy, statistic = param, R = 1000)
print(res)

# 95% CI
boot.ci(res, type="bca", conf = 0.95, index = 1)

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/1b93b7ab-1d1f-470c-b029-f083a2e0ae24n%40googlegroups.com.


rras...@gmail.com

unread,
Jan 3, 2021, 9:17:34 PM1/3/21
to lavaan
Thank you so much!
In the example you provided there is only one standardized coefficient. How to do it with multiple coefficients? Or should I do it one by one?
Thank you,

car...@web.de

unread,
Jan 4, 2021, 6:54:02 AM1/4/21
to lav...@googlegroups.com
You can do this step by step, but you don't have to. Here is a simple example with several coefficients (it also works with latent variables):

library(lavaan)
library(boot)

# Some data
set.seed(1234)
X <- rnorm(1000)
M <- 0.3 * X + rnorm(1000)
Y <- 0.4 * M + rnorm(1000)
myData <- data.frame(X = X, Y = Y, M = M)

# Simple mediation model
myModel <- '
M ~ a * X
Y ~ b * M + c * X
ind := a * b
'

# Function to obtain standardized values
param <- function(d, i) {
  fit <- sem(myModel, data = d[i,])

  pe <- parameterEstimates(fit, standardized = TRUE)
  return(
    c(
      pe[pe$label == "a",]$std.all,
      pe[pe$label == "b",]$std.all,
      pe[pe$label == "c",]$std.all,
      pe[pe$label == "ind",]$std.all
    )
  )
}


# Bootstrap
res <- boot(data = myData, statistic = param, R = 1000)

print(res)

# 95% CI
boot.ci(res, type="bca", conf = 0.95, index = 1)
boot.ci(res, type="bca", conf = 0.95, index = 2)
boot.ci(res, type="bca", conf = 0.95, index = 3)
boot.ci(res, type="bca", conf = 0.95, index = 4)



Note: I only want to show how you can solve the problem "technically". This is not a statement about the usefulness of these confidence intervals.

rras...@gmail.com

unread,
Jan 4, 2021, 12:11:01 PM1/4/21
to lavaan
Thank you so much,
Your example works.
I am new to SEM. So,  I do not really know whether CI for standardized coefficients are useful. In my field (environmental conservation), SEM is not much used and people like to see p-values or CI, so that is why I wanted to do it. 
But, would you let me know why CI for standardized coefficients may not be useful?
Thank you,


car...@web.de

unread,
Jan 4, 2021, 3:46:18 PM1/4/21
to lav...@googlegroups.com
I explicitly did not write a statement about the usefulness of these confidence intervals. On the one hand, inferences (hypothesis testing) should be based on unstandardized parameters. On the other hand, CI around standardized coefficients may be understood as a quantification of uncertainty. In a slightly different context, you can find some statements here: https://groups.google.com/g/lavaan/c/OfaPfUYqVVI/m/ZXzk3f0aDQAJ
Am 04.01.21, 18:11 schrieb "rras...@gmail.com" <rras...@gmail.com>:

rras...@gmail.com

unread,
Jan 4, 2021, 9:52:57 PM1/4/21
to lavaan
Thank you so much.
It is a great help. As pointed in the discussion link you provided, I also just want to have error bars in my graphs and that is why I want the CI for the standardized coefficients. Just to quantify uncertainty, not for hypothesis testing.
Thank you so much.
Reply all
Reply to author
Forward
0 new messages