Hi, thanks for making semboottools. I ran into a bootstrapping failure for standardized coefficients that seems to be caused by std_names(). Calling store_boot(..., type = "std.all") and then standardizedSolution_boot() (or any call path that triggers boot_est_std()) failed in a few (but not all) more complex models with:
Error in dimnames(x) <- dn :
length of 'dimnames' [2] not equal to array extent
Called from: `colnames<-`(`*tmp*`, value = std_names(object))
The error happens when boot_est_std() builds a bootstrap matrix out_all and then does:
colnames(out_all) <- std_names(object)
So if merge(std, ptable, all.y = FALSE) in std_names() returns a data frame with a different number of rows than std, std_names() returns the wrong-length name vector and the colnames<- assignment errors.
I patched this by avoiding merge and relying on if-else label name/finding, so different lengths can't occur:
std_names_nomerge <- function(object, type = "std.all", ...) {
std <- lavaan::standardizedSolution(
object, type = type, se = FALSE, output = "data.frame", ...
)
lab <- if ("label" %in% names(std)) std$label else rep("", nrow(std))
out <- ifelse(
std$op == ":=",
std$lhs,
ifelse(!is.na(lab) & lab != "", lab,
paste(std$lhs, std$op, std$rhs))
)
make.unique(out)
}
assignInNamespace("std_names", std_names_nomerge, ns = "semboottools")
Worked for me, but might not be great as a general approach.
Couldn't figure out a minimal repex, so I just described the issue. Hope this helps.