HTMT confidence intervals

193 views
Skip to first unread message

Carsten S

unread,
Apr 17, 2023, 7:04:32 AM4/17/23
to lavaan
Hello,

up to now, I have used semTools::htmt() to get heterotrait-monotrait results.
Can anybody point me to a way to receive htmt values with confidence intervals?

Thank you!

Christian Arnold

unread,
Apr 17, 2023, 7:26:59 AM4/17/23
to lavaan

Carsten S

unread,
Apr 17, 2023, 10:57:23 AM4/17/23
to lavaan
Hi Christian,

is there an introduction to the function?
Or do you have an example for using it towards the CI of HTMT?

Thanks 
Carsten

Christian Arnold

unread,
Apr 17, 2023, 12:13:32 PM4/17/23
to lavaan
Hi Carsten,

The first post explains how to bootstrap HTMT with x.boot. Since you don't need to fit a lavaan object to compute HTMT, you can also do something like this (quick and dirty - check code):

library(semTools)

HS.model <- 'visual  =~ x1 + x2 + x3
             textual =~ x4 + x5 + x6
             speed   =~ x7 + x8 + x9'

data <- HolzingerSwineford1939

# Bootstrap draws
R <- 100

# Run the bootstrap
boot <- sapply(1 : R, function(x, data) {
  d <- data[sample(1 : nrow(data), replace = TRUE, nrow(data)),]
  t <- htmt(HS.model, d)
  t[lower.tri(t)]
}, data)

# Get CI
sapply(1 : nrow(boot), function(x, t0, boot) {
  c(
    coef = t0[lower.tri(t0)][x],
    quantile(boot[x,], c(0.025, 0.975))
  )
}, htmt(HS.model, data), boot) 



HTH

Christian

Carsten S

unread,
Apr 18, 2023, 3:40:55 AM4/18/23
to lav...@googlegroups.com
Thank you very much. Works like a charm.

However, I also have one single item measurement. This is not covered
by the htmt() function.
Any suggestions on how to best work around this?

Thank you!
> --
> You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/Uizg37S3dYc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/fba67f23-0349-41d3-bc4f-a5d5b39d547dn%40googlegroups.com.

Christian Arnold

unread,
Apr 18, 2023, 4:56:15 AM4/18/23
to lavaan
Hi Carsten,

Well, the documentation says quite clearly: "lavaan model.syntax of a confirmatory factor analysis model where at least two factors are required for indicators measuring the same construct" (https://rdrr.io/cran/semTools/man/htmt.html). Why don't you switch to the discriminantValidity function (https://rdrr.io/cran/semTools/man/discriminantValidity.html)?

There is literature that very clearly emphasizes the advantage of this method for SEM compared to HTMT: https://journals.sagepub.com/doi/10.1177/1094428120968614

HTH

Christian
Reply all
Reply to author
Forward
0 new messages