Factor scores following WLS estimation
Posted on

Forums
Dear reader,
Currently I am struggling with computing factor scores with maximum likelihood estimation using the mxFactorScores(model, type="ML") function. If I understand it correctly, the input model should include a means vector for the indicators. However, because my indicators are categorical I fit my model with mxFitFunctionWLS() and specify the data with mxDataWLS(data,type="WLS"). To my knowledge the mxDataWLS() function does not allow the specification of the means. As a result my model does not provide the means necessary to use the mxFactorScores() function.
Do you know a solution to my problem?
Best,
Paul
version?
mxVersion()
to see.Log in or register to post comments
In reply to version? by AdminRobK
OpenMx
R version: R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0
MacOS: 10.11.6
Default optimiser: SLSQP
Log in or register to post comments
In reply to OpenMx by PaulTwin
update and retry
Log in or register to post comments
Update
Log in or register to post comments
Sorry that factor scores aren
require(OpenMx)
#require(devtools)
#install_bitbucket('mhunter/easymx')
# need a bleeding edge version of EasyMx
# to get the deviation=FALSE argument
# However, if your ordinal variables all have the
# same number of categories this isn't needed.
# Then you can use
# install.packages('EasyMx')
require(EasyMx)
# Load data
data(jointdata)
jointdata[, c(2, 4, 5)] <- mxFactor(jointdata[,c(2, 4, 5)],
levels=sapply(jointdata[,c(2, 4, 5)], function(x){sort(unique(x))}))
# Build a basic factor model
m0 <- emxFactorModel(list(F1=names(jointdata)), jointdata)
m0$Loadings$lbound <- 0
# Make this a WLS factor model
m1 <- mxModel("WLSFactorModel",
emxThresholds(jointdata, ordinal=c(2, 4, 5), deviation=FALSE),
m0$Loadings, m0$Residuals, m0$LatentMeans, m0$Means, m0$LatentVariances,
m0$expectation,
mxDataWLS(jointdata),
mxFitFunctionWLS())
# Run it
m1r <- mxRun(m1)
# Try factor scores. Error.
mxFactorScores(m1r, 'ML')
# Error in mxFactorScores(m1r, "ML") :
# The 'model' argument must have raw (not summary) data.
# Swap in raw data for WLS, and ML fit function for WLS
m1rd <- mxModel(m1r,
mxData(jointdata, 'raw'),
mxFitFunctionML())
# Estimate scores
scores <- mxFactorScores(m1rd, 'ML')
It's worth mentioning that this is a strange thing to do. ML factor scores from the WLS model might not behave well. I don't think it has been studied.
Another point to consider, your ML model might run faster with better starting values. From the example above,
# Get good starting values for ML model
m0s <- mxAutoStart(m0)
The model
m0s
is an ML model with pretty good starting values. Many times this makes the ML estimation faster.Log in or register to post comments
In reply to Sorry that factor scores aren by mhunter
Thanks!
After I constrain these rownames to be equal I receive a different error: "Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings,: Observed thresholds were provided, but an expected thresholds matrix was not specified.
If you provide observed thresholds, you must specify a model for the thresholds."
You mention that estimating ML factor scores is a strange thing to do for a WLS model. What do you think would be the best method to compute factor scores for a WLS model?
Log in or register to post comments
Try a non-LISREL model
type='RAM'
withmxPath
statements or usingmxExpectationRAM
will specify a RAM model.Log in or register to post comments
In reply to Try a non-LISREL model by mhunter
No problem
Log in or register to post comments