Error in reliability

339 views
Skip to first unread message

b.ez...@gmail.com

unread,
Oct 14, 2021, 3:39:32 AM10/14/21
to lavaan
Greeting all

could any one help to solve this error in reliability function of semtools?

 
data(HolzingerSwineford1939)
HS9 <- HolzingerSwineford1939[ , c("x7","x8","x9")]
HSbinary <- as.data.frame( lapply(HS9, cut, 2, labels=FALSE) )
names(HSbinary) <- c("y7","y8","y9")
HS <- cbind(HolzingerSwineford1939, HSbinary)
HS.model <- ' visual =~ x1 + x2 + x3
+ textual =~ x4 + x5 + x6
+ speed =~ y7 + y8 + y9 '
fit <- cfa(HS.model, data = HS, ordered = c("y7","y8","y9"), std.lv = TRUE)
reliability(fit)
Error in keys[[scales]] : this S4 class is not subsettable

reliability(fit, omit.factors = "speed", return.total = TRUE)
Error in reliability(fit, omit.factors = "speed", return.total = TRUE) : 
  unused arguments (omit.factors = "speed", return.total = TRUE)


Terrence Jorgensen

unread,
Oct 15, 2021, 9:55:42 AM10/15/21
to lavaan
Your code works (after I remove the plus signs from the R Console) using the development version:

https://github.com/simsem/semTools/wiki

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Message has been deleted
Message has been deleted

b.ez...@gmail.com

unread,
Oct 15, 2021, 10:42:57 AM10/15/21
to lavaan
for me the problem is exist even after installing github version.

data(HolzingerSwineford1939)
HS9 <- HolzingerSwineford1939[ , c("x7","x8","x9")]
HSbinary <- as.data.frame( lapply(HS9, cut, 2, labels=FALSE) )
names(HSbinary) <- c("y7","y8","y9")
HS <- cbind(HolzingerSwineford1939, HSbinary)
HS.model <- ' visual =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed =~ y7 + y8 + y9 '
 fit <- cfa(HS.model, data = HS, ordered = c("y7","y8","y9"), std.lv = TRUE)
reliability(fit)
Error in keys[[scales]] : this S4 class is not subsettable

b.ez...@gmail.com

unread,
Oct 15, 2021, 10:43:18 AM10/15/21
to lavaan
for me when i load psych package along with other one the problem appear.

with psych

library(foreign)
#require(faoutlier)
#library(haven)
#library(lavaan)
library(semTools)
require(semPlot)
library(EGAnet)
library(psych)

data(HolzingerSwineford1939)
HS9 <- HolzingerSwineford1939[ , c("x7","x8","x9")]
HSbinary <- as.data.frame( lapply(HS9, cut, 2, labels=FALSE) )
names(HSbinary) <- c("y7","y8","y9")
HS <- cbind(HolzingerSwineford1939, HSbinary)
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ y7 + y8 + y9 '
fit <- cfa(HS.model, data = HS, ordered = c("y7","y8","y9"), std.lv = TRUE)
reliability(fit)
Error in keys[[scales]] : this S4 class is not subsettable

no psych

library(foreign)
#require(faoutlier)
#library(haven)
#library(lavaan)
library(semTools)
require(semPlot)
library(EGAnet)
#library(psych)

data(HolzingerSwineford1939)
HS9 <- HolzingerSwineford1939[ , c("x7","x8","x9")]
HSbinary <- as.data.frame( lapply(HS9, cut, 2, labels=FALSE) )
names(HSbinary) <- c("y7","y8","y9")
HS <- cbind(HolzingerSwineford1939, HSbinary)
HS.model <- ' visual =~ x1 + x2 + x3
 textual =~ x4 + x5 + x6
speed =~ y7 + y8 + y9 '
fit <- cfa(HS.model, data = HS, ordered = c("y7","y8","y9"), std.lv = TRUE)
reliability(fit)
For constructs with categorical indicators, Zumbo et al.`s (2007) "ordinal alpha" is calculated in addition to the standard alpha, which treats ordinal variables as numeric. See Chalmers (2018) for a critique of "alpha.ord" and the response by Zumbo & Kroc (2019). Likewise, average variance extracted is calculated from polychoric (polyserial) not Pearson correlations.

             visual   textual     speed
alpha     0.6261171 0.8827069 0.4460672
alpha.ord        NA        NA 0.6672581
omega     0.6367040 0.8795086 0.4674903
omega2    0.6367040 0.8795086 0.4674903
omega3    0.6247881 0.8741398 0.4559127
avevar    0.3880813 0.7089975 0.4200451

Terrence Jorgensen

unread,
Oct 16, 2021, 9:28:16 AM10/16/21
to lavaan

for me when i load psych package along with other one the problem appear.

Aha, then you can probably just use the double-colon operator to let R know which reliability() function you want.

semTools::reliability()
?"::" # help page
Reply all
Reply to author
Forward
0 new messages