Learn R Programming

regsem (version 0.1.2)

multi_optim: Multiple starts for Regularized Structural Equation Modeling

Description

Multiple starts for Regularized Structural Equation Modeling

Usage

multi_optim(model, max.try = 10, lambda, LB = -Inf, UB = Inf, type,
  optMethod = "nlminb", gradFun = "ram", pars_pen = NULL,
  diff_par = NULL, hessFun = "none", verbose = TRUE, warm.start = FALSE,
  Start2 = NULL, tol = 1e-06, max.iter = 50000)

Arguments

model
Lavaan output object. This is a model that was previously run with any of the lavaan main functions: cfa(), lavaan(), sem(), or growth(). It also can be from the efaUnrotate() function from the semTools package. Currently, the parts of the model which can
max.try
number of starts to try before convergence.
lambda
Penalty value. Note: higher values will result in additional convergence issues.
LB
lower bound vector. Note: This is very important to specify when using regularization. It greatly increases the chances of converging.
UB
Upper bound vector
type
Penalty type. Options include "none", "lasso", "ridge", and "diff_lasso". diff_lasso penalizes the discrepency between parameter estimates and some pre-specified values. The values to take the deviation from are specified in diff_par.
optMethod
Solver to use. Recommended options include "nlminb" and "optimx". Note: for "optimx", the default method is to use nlminb. This can be changed in subOpt.
gradFun
Gradient function to use. Recommended to use "ram", which refers to the method specified in von Oertzen & Brick (2014). The "norm" procedure uses the forward difference method for calculating the hessian. This is slower and less accurate.
pars_pen
Parameter indicators to penalize. If left NULL, by default, all parameters in the A matrix outside of the intercepts are penalized when lambda > 0 and type != "none".
diff_par
Parameter values to deviate from. Only used when type="diff_lasso".
hessFun
Hessian function to use. Recommended to use "ram", which refers to the method specified in von Oertzen & Brick (2014). The "norm" procedure uses the forward difference method for calculating the hessian. This is slower and less accurate.
verbose
Whether to print iteration number.
warm.start
Whether start values are based on previous iteration. This is not recommended.
Start2
Provided starting values. Not required
tol
absolute tolerance for convergence.
max.iter
max iterations for optimization.

Examples

Run this code
library(regsem)
HS <- data.frame(scale(HolzingerSwineford1939[,7:15]))
mod <- '
f =~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9
'
outt = cfa(mod,HS,meanstructure=TRUE)

fit1 <- multi_optim(outt,max.try=40,
                   lambda=0.1,type="lasso",
                   gradFun="ram")


# growth model
model <- ' i =~ 1*t1 + 1*t2 + 1*t3 + 1*t4
          s =~ 0*t1 + s1*t2 + s2*t3 + 3*t4 '
fit <- growth(model, data=Demo.growth)
summary(fit)
fitmeasures(fit)
fit3 <- multi_optim(fit,lambda=0.2,type="ridge",gradFun="none")
summary(fit3)

Run the code above in your browser using DataLab