simsem / semTools

Useful tools for structural equation modeling
75 stars 36 forks source link

Error in getThreshold function in reliability.R #85

Closed ddueber closed 3 years ago

ddueber commented 3 years ago

I finally added support for categorical omega to BifactorIndicesCalculator, and was testing it against semTools::reliability() and noticed that the results from semTools didn't make sense (they were unrealistically low). I figured out the problem:

lines 1185-1186 of Reliability.R read: result <- lapply(ordnames, function(nn) thresholds[grepl(nn, names(thresholds))])

When indicators have names like x1, x2, x3, ..., x10, x11, .... then the grepl give too many TRUE results. For example, when nn = x1, it will also catch thresholds for x10, x11, x12, etc.

The fix is simple: result <- lapply(ordnames, function(nn) thresholds[grepl(paste0(nn, "\\|"), names(thresholds))])

There is a similar issue with lines 1208-1209

TDJorgensen commented 3 years ago

Ah, great catch, thanks! Fixed in 0.5-4.905