if (FALSE) {
dat <- data.frame(item1 = c(5, 2, 3, 4, 1, 2, 4, 2),
item2 = c(5, 3, 3, 5, 2, 2, 5, 1),
item3 = c(4, 2, 4, 5, 1, 3, 5, 1),
item4 = c(5, 1, 2, 5, 2, 3, 4, 2))
# Example 1a: Compute unstandardized coefficient omega and item statistics
item.omega(dat)
# Example 1b: Alternative specification using the 'data' argument
item.omega(., data = dat)
# Example 2: Compute unstandardized coefficient omega with a residual covariance
# and item statistics
item.omega(dat, rescov = c("item1", "item2"))
# Example 3: Compute unstandardized coefficient omega with residual covariances
# and item statistics
item.omega(dat, rescov = list(c("item1", "item2"), c("item1", "item3")))
# Example 4: Compute unstandardized hierarchical omega and item statistics
item.omega(dat, type = "hierarch")
# Example 5: Compute categorical omega and item statistics
item.omega(dat, type = "categ")
# Example 6: Compute standardized coefficient omega and item statistics
item.omega(dat, std = TRUE)
# Example 7: Compute unstandardized coefficient omega
item.omega(dat, print = "omega")
# Example 8: Compute item statistics
item.omega(dat, print = "item")
# Example 9: Compute unstandardized coefficient omega and item statistics while excluding item3
item.omega(dat, exclude = "item3")
# Example 10: Summary of the CFA model used to compute coefficient omega
lavaan::summary(item.omega(dat, output = FALSE)$model.fit,
fit.measures = TRUE, standardized = TRUE)
# Example 11a: Write results into a text file
item.omega(dat, write = "Omega.txt")
# Example 11b: Write results into a Excel file
item.omega(dat, write = "Omega.xlsx")
result <- item.omega(dat, output = FALSE)
write.result(result, "Omega.xlsx")
}
Run the code above in your browser using DataLab