# Difference between optimizers

4 posts / 0 new
Offline
Joined: 10/02/2019 - 09:28
Difference between optimizers

In my twin model i calculate Rmz and Rdz from the saturated model, however when i run it (i run it on several variables) for a few variables CSOLNP fails to calculate confidence intervals, while SLSQP does caculate all. Is there a particular reason for this? Should i be concerned by this, or just use slsqp for the cases csolnp fails?

Here is the sat part, if it helps:

 #sat model, rmz, rdz:

PathMZ <- mxMatrix("Lower",nrow = 2,ncol = 2,free = TRUE,values=starting_value_pathcoeff,name = "PathMZ")#cholesky for pos definitness

PathDZ <- mxMatrix("Lower",nrow = 2,ncol = 2,free = TRUE,values=starting_value_pathcoeff,name = "PathDZ")#cholesky for pos definitness

expCovMZ <- mxAlgebra(expression = PathMZ%*%t(PathMZ),name = "expCovMZ")

expCovDZ <- mxAlgebra(expression = PathDZ%*%t(PathDZ),name = "expCovDZ")

Rmz <- mxAlgebra(expression = sqrt(vec2diag(1/diag2vec(expCovMZ)))%*%expCovMZ%*%sqrt(vec2diag(1/diag2vec(expCovMZ))), name = "Rmz")

Rdz <- mxAlgebra(expression = sqrt(vec2diag(1/diag2vec(expCovDZ)))%*%expCovDZ%*%sqrt(vec2diag(1/diag2vec(expCovDZ))), name = "Rdz")

expMZ <- mxExpectationNormal(covariance = "expCovMZ",means = "exp_mean_mz",dimnames = selectVariables)

expDZ <- mxExpectationNormal(covariance = "expCovDZ",means = "exp_mean_dz",dimnames = selectVariables)

MZmodel <- mxModel(intercepts,beta,dependent_vars_mz,PathMZ,Rmz, expCovMZ,exp_mean_mz,DataMZ,expMZ,fitML ,name="MZmodel")
#MZmodel <- mxModel(MZmodel,mxCI(c("Rmz")))

#DZmodel <- mxModel(DZmodel,mxCI(c("Rdz")))

fitmultiMLsat <- mxFitFunctionMultigroup(c("MZmodel.fitfunction","DZmodel.fitfunction"))

SatModel <- mxModel("SAT",MZmodel,DZmodel,fitmultiMLsat)
SatModel <- mxModel(SatModel,mxCI(c("MZmodel.Rmz","DZmodel.Rdz")))
Satfinal <- mxRun(SatModel, intervals = TRUE)
sum_sat_raw <- summary(Satfinal)
Offline
Joined: 01/24/2014 - 12:15
probably no big deal; some hints
Should i be concerned by this, or just use slsqp for the cases csolnp fails?

It's probably nothing to worry about, but it's also a good idea to use summary(Satfinal,verbose=TRUE) to see why the confidence limits aren't being reported.

Is there a particular reason for this?

Without going into a lot of detail, those two optimizers by default use a different internal representation of the confidence-limit search. There are also theoretical reasons why SLSQP would be expected to give better confidence intervals most of the time. If you want to use CSOLNP to fit your model, but use SLSQP to find confidence intervals, then run your MxModel with intervals=FALSE, and then use omxRunCI() on your fitted MxModel (which uses SLSQP by default).

Offline
Joined: 10/02/2019 - 09:28
Thank you!

Thank you!

I think then i will use SLSQP just for the variables where CSOLNP didn't work, because generally the intervals are a bit tighter when i use CSOLNP.

Offline
Joined: 10/02/2019 - 09:28
Summary

By the way, it's a diagnostic error: alpha level not reached infeasible non-linear constraint.