Dear Statalisters,

I am running a SEM model with multiple independent variables and a cluster variable (accounting for different surveys).
I want to obtain the bootstrapped standard errors and confidence intervals, but apparently the vce() option does not allow at the same time for bootstrapping and clustering.

Then, I follow these instructions for creating a program that bootsraps the data: https://stats.idre.ucla.edu/stata/fa...e-sem-command/ and I run the command for multiple IV. This is the code I use:

Code:
program indireff, rclass
  sem (med <- x1) (med <- x2) (med <- x3) (y <- x1 x2 x3 med cv1 cv2), nocapslatent  vce(cluster clust_var)
  estat teffects
  mat bi = r(indirect)
  mat bd = r(direct)
  mat bt = r(total)
  return scalar indir  = el(bi,1,3)
  return scalar direct = el(bd,1,3)
  return scalar total  = el(bt,1,3)
end
 
sem (med <- x1) (med <- x2) (med <- x3) (y <- x1 x2 x3 med cv1 cv2 ), nocapslatent  vce(cluster clust_var)
quiet estat teffects
 
matrix list r(indirect)
matrix list r(direct)
matrix list r(total)
 
set seed 358395
bootstrap r(indir) r(direct) r(total), reps(10): indireff
The code however provides me with just direct and one total effect (no indirect) and of the same size. My guess is that I need to indicate to the bootstrap command which variable to focus on, but I have been unable to find how to do it.

I would very much appreciate your help.

Best regards,
Marc