Hello,
I'm a first time user of R and the lavaan package so it might be an obvious mistake, thanks in advance for your help and patience. I have collected data of 732 students who took a math test of originally 24 items, in later versions two items were dismissed, that's why I'm only including 22 items (data see attached file).
Long story short - I want to perform a cfa, analyzing how appropriate a one-factor-model fits the data.
My R script is shown below, I am using R-4.0.2 for Windows, RStudio Desktop 1.3.1073, lavaan 0.6-1:
library(lavaan)
library(readxl)
mathtest <- read_excel("C:/Users/andis/Downloads/mathtest.xlsx")
mathknowledge <- '
f1 =~ "MA1"+"MA2"+"MA3"+"MA4"+"MA5"+"MA6"+"MA7"+"MA8"+"MA9"+"MA10"+"MA11"+"MA13"+"MA14"+"MA15"+"MA16"+"MA17"+"MA18"+"MA20"+"MA21"+"MA22"+"MA23"+"MA24"
'
model_cfa <- cfa(model = mathknowledge, data = mathtest)
fit <- cfa(model=mathknowledge, data= mathtest)
> model_cfa <- cfa(model = mathknowledge, data = mathtest)
lavaan ERROR: missing observed variables in dataset: ..constant..
What can I do?
Thank you very much for your time.
Regards,
Andreas