Hi,
I am trying to run omega and alpha statistics using a combination of the lavaan package and the SEMTools package
I am a complete newbie on this so apologies if the question seems basic. I was inspired by the post
https://drsimonj.svbtle.com/how-to-calculate-internal-consistencyHowever a lot of the litrature seems to specify that boot strapping and confidence intervals should be used when calculating Cronbach Or Omega
I have 3 constructs taken from the `lavaan` data HolzingerSwineford1939
My aim is to run both Alpha and Omega on my constructs that i have created with the final result being to plot the point statistic with error bars showing the confidence interval of each construct.
So in theory i want get back my alpha/omega statistic and the confidence interval so i can plot my point with error bars
I am getting the below error when i run it
Warning messages:
1: In lav_object_post_check(lavobject) :
lavaan WARNING: some estimated ov variances are negative
2: In lav_object_post_check(lavobject) :
lavaan WARNING: some estimated ov variances are negative
3: In lav_object_post_check(lavobject) :
lavaan WARNING: some estimated ov variances are negative
4: In lav_object_post_check(lavobject) :
lavaan WARNING: some estimated ov variances are negative
Can anyone help me how to trouble shoot?
Below is the code which i appreciate needs a lot of work :)
#------------------------
# CODE
#-------------------------
library(lavann)
library(tidyverse)
library(semTools)
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
# Fit the model
boot.fn <- function(model,data, indices, testtype) {
library(semTools)
d <- data[indices,]
if(testtype == 'alpha'){
slice_index = 1
} else {
slice_index = 2
}
fit <- cfa(model, d)
# Slicing either 1 or 2 will result in either Omega or Alpha results being returned
rel <- as.data.frame(reliability(fit)) %>%
slice(slice_index)
rel <- as.numeric(rel)
return(rel)
}
results.alpha <- boot(data=HolzingerSwineford1939, statistic=boot.fn, R=1000, model = HS.model, testtype = 'alpha')
results.omega <- boot(data=HolzingerSwineford1939, statistic=boot.fn, R=1000, model = HS.model, testtype = 'omega')
boot.ci(results.alpha)
Im taking my information on how to create boot strapping from 'R In Action' Pg 306 and ISLR page 196
Cheers
Steve