I performed a CFA using the lavaan package

require('lavaan');

HS.model <- 'external_regulation_soc =~ JOBMOTIVATIE_extsoc1 +
                  JOBMOTIVATIE_extsoc2 + JOBMOTIVATIE_extsoc3
             external_regulation_mat =~ JOBMOTIVATIE_extmat1 +
                  JOBMOTIVATIE_extmat2 + JOBMOTIVATIE_extmat3
             introjected_regulation =~ JOBMOTIVATIE_introj1 +
                  JOBMOTIVATIE_introj2 + JOBMOTIVATIE_introj3 +
                  JOBMOTIVATIE_introj4
             identified_regulation =~ JOBMOTIVATIE_ident1 +
                  JOBMOTIVATIE_ident2 + JOBMOTIVATIE_ident3
             intrinsic_motivation =~ JOBMOTIVATIE_intrin1 +
                  JOBMOTIVATIE_intrin2 + JOBMOTIVATIE_intrin3'

fit <- cfa(HS.model, data = dataset, scores="regression")

summary(fit, fit.measures=TRUE, standardized=TRUE)

I managed to get the values for the five factors in a seperate dataset using

data_factor <- predict(fit)

But I need these 5 factors (as columns, as variables), added to my original
dataset. How can I achieve this?

I tried cbind, but got an error:

factorERS <- select(dataset, JOBMOTIVATIE_extsoc1 +
                   JOBMOTIVATIE_extsoc2 + JOBMOTIVATIE_extsoc3)

data_CFA <- cbind(dataset, fit$scores)
Error in fit$scores : $ operator not defined for this S4 class

Thanks for helping me out!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to