-1

I have the below script and I am getting an error. Running CFA on R studio using Lavaan. See below the results

*> fit <- cfa(myModel, data=ASM,)
Error in lav_data_full(data = data, group = group, cluster = cluster,  : 
  lavaan ERROR: missing observed variables in dataset: rI1 rI2 rI3 rI4 s1 s2 s3 s4 w1 w2 w3 w4
> summary(fit, standardized=TRUE)
Error in summary(fit, standardized = TRUE) : object 'fit' not found
> summary(fit, fit.measures=TRUE)
Error in summary(fit, fit.measures = TRUE) : object 'fit' not found
> fit <- cfa(myModel, data=ASM)
Error in lav_data_full(data = data, group = group, cluster = cluster,  : 
  lavaan ERROR: missing observed variables in dataset: rI1 rI2 rI3 rI4 s1 s2 s3 s4 w1 w2 w3 w4*

What could be the problem?

Script on R studio:

myModel2 <-'
#Regressions
WordofMouth + CustomerService ~ Tangibles + Realibility + Responsiveness + Assurance + Empathy
WordofMouth ~ CustomerService
#latent variable definitions
Tangibles =~ t1 +t2 + t3 + t4
Realibility =~ rI1 + rI2 + rI3 + rI4
Responsiveness =~ rs1 + rs2 + rs3 + rs4
Assurance =~ as1 + as2 + as3 + as4
Empathy =~ em1 + em2 + em3 + em4
#Variances and covariances
WordofMouth ~~ WordofMouth
WordofMouth ~~ CustomerService
CustomerService ~~ Tangibles' 
fit <- sem(myModel, data=ASM)
summary(fit, fit.measures=TRUE)
parameterEstimates(fit)
fit <- cfa(myModel, data=ASM)
summary(fit, fit.measures=TRUE)
parameterEstimates(fit)
halfer
  • 19,824
  • 17
  • 99
  • 186
  • 1
    Any chance you could provide a reproducible example? https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Vlad C. Aug 29 '18 at 15:17
  • 1
    Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Aug 29 '18 at 18:04
  • These variables don't exist in your data. Therefore you cannot estimate the SEM with them inside (`fit`) and use the object in subsequent function calls: `rI1 rI2 rI3 rI4 s1 s2 s3 s4 w1 w2 w3 w4` – Brigadeiro Jan 20 '19 at 20:04

1 Answers1

-1

R doesn't detect { rI1 rI2 rI3 rI4 s1 s2 s3 s4 w1 w2 w3 w4} variables in your data and this will lead to the rest of the errors you got. Please make sure you spelled your variables correctly. you can check it in R's command line by typing

ASM$ 

and then start typing your variables and use "tab" to use the autocomplete feature. also if you are using r-studio, you can use the following function to see your data:

View(ASM)

if instead of the heading, you see the variables in your first line, it is possible that you imported your dataset without heading. In that case, import it again and make sure to check the first line as the heading

Reza Gh
  • 34
  • 5