# Difference between optimizers

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(intercepts,beta,dependent_vars_dz,PathDZ,Rdz, expCovDZ,exp_mean_dz,DataDZ,expDZ,fitML ,name="DZmodel")

#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)

## probably no big deal; some hints

It's probably nothing to worry about, but it's also a good idea to use `summary(Satfinal,verbose=TRUE)` to see

whythe confidence limits aren't being reported.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).Log in or register to post comments

In reply to probably no big deal; some hints by AdminRobK

## 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.

Log in or register to post comments

In reply to probably no big deal; some hints by AdminRobK

## Summary

Log in or register to post comments