Hi Terrence,
Many thanks for your reply. I tried to post here, but for some reason, the repo was disappeared...
I tried the lavPredictY() function, but it didn't work for me, since all my variables were categorical and ordinal (from a 5-point Likert scale). Instead, I had the following solution, which gave me a closing solution:
Let's say we have a raw_dat including nine exogenous variables x1 - x9, with every three variables measuring a latent variable F1 - F3. So the CFA model would be
cfa_model <- '
F1 =~ x1 + x2 + x3
F2 =~ x4 + x5 + x6
F3 =~ x7 + x8 + x9
'
To calculate the casewise residual data casewise_res, I did:
fit <- cfa (cfa_model,
data = raw_dat,
ordered = TRUE,
predict_dat <- lavPredict (fit, type = "ov")
std_dat <- as.data.frame(scale(raw_dat))
casewise_res <- std_dat - predict_dat
In this code, standardized scores for each variable (std_dat) were calculated because I found lavPredict() seems to provide this form of data. Hope I am on the right track
Subsequent work will start with data casewise_res since I would like to do some regression on residuals in behaviour we will be in OLS regression.
Does this make any sense to you? Or calculating casewise residual for categorical/ordinal data is incorrect? Many thanks for any help in advance.
Cheers
-J