| Type: | Package |
| Title: | Semi-Confirmatory Structural Equation Modeling via PenalizedLikelihood or Least Squares |
| Version: | 0.6.11 |
| Description: | Fits semi-confirmatory structural equation modeling (SEM) via penalized likelihood (PL) or penalized least squares (PLS). For details, please see Huang (2020) <doi:10.18637/jss.v093.i07>. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| Collate: | lslxData-class.R lslxData-initialize-method.RlslxModel-class.R lslxModel-initialize-method.RlslxFitting-class.R lslxFitting-initialize-method.Rprelslx-class.R prelslx-initialize-method.Rprelslx-prefit-method.R lslx-class.R lslx-print-method.Rlslx-set-coefficient-method.R lslx-set-block-method.Rlslx-set-directed-method.R lslx-set-heterogeneity-method.Rlslx-set-undirected-method.R lslx-set-data-method.RRcppExports.R lslx-fit-method.R lslx-get-method.Rlslx-extract-method.R lslx-test-method.Rlslx-summarize-method.R lslx-plot-method.Rlslx-validate-method.R lslx-s3-interface.R polyhedral.Rutility-function.R |
| Depends: | R (≥ 3.5.0) |
| Imports: | stats, Rcpp, R6, ggplot2 |
| Suggests: | knitr, rmarkdown, lavaan |
| VignetteBuilder: | knitr |
| LinkingTo: | Rcpp, RcppEigen |
| RoxygenNote: | 7.2.2 |
| URL: | https://github.com/psyphh/lslx/wiki |
| BugReports: | https://github.com/psyphh/lslx/issues |
| NeedsCompilation: | yes |
| Packaged: | 2022-12-02 07:00:24 UTC; phhaung |
| Author: | Po-Hsien Huang [cre, aut], Wen-Hsin Hu [aut] |
| Maintainer: | Po-Hsien Huang <psyphh@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2022-12-02 08:20:05 UTC |
S3 method to extract parameter estimate fromlslx
Description
coef.lslx() is anS3 interface for extracting parameter estimate from alslx object.
Usage
## S3 method for class 'lslx'coef(object, selector, lambda, delta, ...)Arguments
object | A fitted |
selector | A |
lambda | A |
delta | A |
... | Other arguments. For details, please see the |
S3 method to extract model-implied moments fromlslx
Description
fitted.lslx() is anS3 interface for extracting model-implied moments from alslx object.
Usage
## S3 method for class 'lslx'fitted(object, selector, lambda, delta, ...)Arguments
object | A fitted |
selector | A |
lambda | A |
delta | A |
... | Other arguments. For details, please see the |
R6 class for semi-confirmatory structural equation modeling via penalized likelihood
Description
R6 class for semi-confirmatory structural equation modeling via penalized likelihood
R6 class for semi-confirmatory structural equation modeling via penalized likelihood
Value
Object oflslx R6 class for fitting semi-confirmatory structural equation modeling (SEM) with penalized likelihood (PL).
Usage
lslx is anR6ClassGenerator for constructing anlslx object that has methods for fitting semi-confirmatory SEM.In a simpliest case, the use oflslx involves three major steps
Initialize a new
lslxobject by specifying a model and importing a data set.r6_lslx <- lslx$new(model, data)Fit the specified model to the imported data with given fitting control.
r6_lslx$fit(penalty_method, lambda_grid, delta_grid)Summarize the fitting results with specified selector.
r6_lslx$summarize(selector)
To citelslx in publications use:
Po-Hsien Huang (in press). lslx: Semi-Confirmatory Structural Equation Modeling via Penalized Likelihood. Journal of Statistical Software.
Overview
lslx is a package for fitting semi-confirmatory structural equation modeling (SEM) via penalized likelihood (PL) developed by Huang, Chen, and Weng (2017).In this semi-confirmatory method, an SEM model is distinguished into two parts: a confirmatory part and an exploratory part.The confirmatory part includes all of the freely estimated parameters and fixed parameters that are allowed for theory testing.The exploratory part is composed by a set of penalized parameters describing relationships that cannot be clearly determined by available substantive theory.By implementing a sparsity-inducing penalty and choosing an optimal penalty level, the relationships in the exploratory part can be efficiently identified by the sparsity pattern of these penalized parameters.After Version 0.6.7,lslx also supports penalized least squares for SEM with ordianl data under delta parameterization. The technical details oflslx can be found in its JSS paper (Huang, 2020) <doi:10.18637/jss.v093.i07> or Vignette for Package lslx (https://cran.r-project.org/web/packages/lslx/vignettes/vignette-lslx.pdf).
The main functionlslx generates an object oflslx R6 class.R6 class is established via packageR6 (Chang, 2017) that facilitates encapsulation object-oriented programming inR system.Hence, thelslx object is self-contained.On the one hand,lslx object stores model, data, and fitting results.On the other hand, it has many built-in methods to respecify model, fit the model to data, and test goodness of fit and coefficients.The initialization of a newlslx object requires importing a model and a data set to be analyzed.After anlslx object is initialized, build-in methods can be used to modify the object, find the estimates, and summarize fitting result.Details of object initialization is described in the section ofInitialize Method.
In the current semi-confirmatory approach, the model specification is quite similar to the traditional practice of SEM except that some parameters can be set as penalized.Model specification inlslx mainly relies on the argument model when creating a newlslx object.After alslx object is initialized, the initialized model can be still modified by set-related methods.These set-related methods may hugely change the initialized model by just one simple command.This two-step approach allows users specifying their own models flexibly and efficiently.Details of the model specification can be found in the sections ofModel Syntax andSet-Related Methods.
Given a penalty level,lslx finds a PL estimate by minimizing a penalized maximum likelihood (ML) loss or a least squares loss functions (including OLS, DWLS, and WLS).The penalty function can be set as lasso (Tibshirani, 1996), ridge (Hoerl & Kennard, 1970), elastic net (Zou & Hastie, 2005), or mcp (minimax concave penalty; Zhang, 2010).lslx solves the optimization problem based on an improvedglmnet method (Friedman, Hastie, & Tibshirani, 2010) made by Yuan, Ho, and Lin (2012).The underlying optimizer is written by usingRcpp (Eddelbuettel & Francois, 2011) andRcppEigen (Bates & Eddelbuettel, 2013).Our experiences show that the algorithm can efficiently find a local minimum provided that (1) the starting value is reasonable, and (2) the saturated covariance matrix is not nearly singular.Details of optimization algorithm and how to implement the algorithm can be found in the sections ofOptimization Algorithm andFit-Related Methods.
When conducting SEM, missing data are easily encountered.lslx can handle missing data problem by listwise deletion and two-step methods.Details of the methods for missing data can be found in the section ofMissing Data.
After fitting the specified model to data under all of the considered penalty levels, an optimal penalty level should be chosen.A naive method for penalty level selection is using information criteria.Huang, Chen, and Weng (2017) have shown the asymptotic properties of Akaike information criterion (AIC) and Bayesian information criterion (BIC) in selecting the penalty level.Inlslx, information criteria other an AIC and BIC can be also used.However, the empirical performances of these included criteria should be further studied.Details of choosing an optimal penalty level can be found in the section ofPenalty Level Selection.
Given a penalty level, it is important to evaluate the goodness-of-fit of selected model and coefficients.Inlslx, it is possible to make statistical inferences for goodness-of-fit and coefficients.However, the inference methods assume that no model selection is conducted, which is not true in the case of using PL.After version 0.6.4, several post-selection mehtods are available (Huang, 2019b).Details of statistical inference can be found in the sections ofModel Fit Evaluation andCoefficient Evaluation.Implementations of these methods can be found in the sections ofSummarize Method andTest-Related Methods.
Besides making statistical inference,lslx has methods for plotting the fitting results, include visualizing quality of optimization and the values of information criteria, fit indices, and coefficient estimates.Details of methods for plotting can be found in the section ofPlot-Related Methods.
An object oflslx R6 class is composed by three R6 class objects:lslxModel,lslxData, andlslxFitting.lslxModel contains the specified model andlslxData object stores the imported data to be analyzed.When fitting the model to data, a reduced model and data will be sent tolslxFitting.After the underlying optimizer finishes its job, the fitting results will be also stored inlslxFitting.Since the three members are set as private, they can be only assessed by defined member functions.Other than the three members, quantities that are crucial for SEM can be also extracted, such as model-implied moments, information matrix, and etc..Details of methods for obtaining private members and SEM-related quantities can be found in the sections ofGet-Related Methods andExtract-Related Methods.
Model Syntax
Withlslx the relationships among observed variables and latent factors are mainly specified via equation-like syntax.The creation of syntax inlslx is highly motivated bylavaan (Rosseel, 2012), a successful package for fitting SEM.However,lslx utilizes slightly more complex, but still intuitive operators to describe relations among variables.
Example 1: Multiple Regression Model
Consider the first example of model that specifies a multiple regression model
y <= x1 + x2
In this example, an dependent variabley is predicted byx1 andx2.These three variables are all observed variables and should appear in the given data set.The operator<= means that the regression coefficients from the right-hand side (RHS) variables to the left-hand side (LHS) variables should be freely estimated.
Although it is a very simple example, at least four important things behind this example should be addressed:
For any endogenous variable (i.e., an variable that is influenced by any other variable), its residual term is not required to be specified.In this example,
lslxrecognizesyis an endogenous variable and hence the variance of corresponding residual will be set as freely estimated parameter.It is also possible to explicitly specify the variance of residual ofybyy <=> y.Here, the operator<=>indicates the covariance of the RHS and LHS variables should be freely estimated.If all of the specified equations do not contain the intercept variable
1, then the intercept of each endogenous and observed variable will be freely estimated.Since the intercept variable1doesn't appear in this example, the intercept forywill be set as a freely estimated parameter.We can explicitly set the intercept term byy <= 1.However, under the situation that many equations are specified, once the intercept variable1appears in some equation, intercept terms in other equations should be explicitly specified.Otherwise, the intercepts of endogenous and observed variables in other equations will be fixed at zero.For any set of exogeneous variables (i.e., variables that are not influenced by any other variable in the specified system),not only their variances will be freely estimated, but also their pairwise covariances will be set as freely estimated parameters.In this example,
x1andx2are both exogeneous variables.Hence, their variance and pairwise covariances will be automatically set as freely estimated parameters.These covariances can be explicitly stated by simplyx1 + x2 <=> x1 + x2.The syntax parser inlslxwill consider variance/covariance of each combination of LHS and RHS variables.The intercepts (or means) of exogeneous and observed variables are always set as freely estimated parameters.In this example, the intercepts of
x1andx2will be freely estimated.It can be stated explicitly byx1 + x2 <= 1.Also, thelslxparser will know that the intercept variable1has effect on all ofx1andx2.
The previous regression example can be equivalently represented byx1 + x2 => y.Inlslx all of the directed operators can be reversed under the stage of model specification.Users can choose the directions of operators according to their own preference.
The unique feature oflslx is that all of the parameters can be set as penalized.To penalize all of the regression coefficients, the equation can be modified as
y <~ x1 + x2
Here, the operator<~ means that the regression coefficients from the RHS variables to the LHS variables should be estimated with penalization.If only the coefficient ofx1 should be penalized, we can use prefix to partly modify the equation
y <= pen() * x1 + x2
or equivalently
y <~ x1 + free() * x2
Bothpen() andfree() are prefix to modify thelslx operators.pen() makes the corresponding parameter to be penalized andfree() makes it to be freely estimated.Inside the parentheses, starting values can be specified.Any prefix must present before some variable name and divided by asterisk*.Note that prefix can appear in the either RHS or LHS of operators and its function can be 'distributed' to the variables in the other side.For example,free() * y <~ x1 + x2 will be interpreted as that all of the coefficients should be freely estimated.However, any prefix cannot simultaneously appear on both sides of operators, which may result in an ambiguity specification.
Example 2: Factor Analysis Model
Now, we consider another example of equation specification.
y1 + y2 + y3 <=: f1
y4 + y5 + y6 <=: f2
y7 + y8 + y9 <=: f3
This example is a factor analysis model with nine observed variables and three latent factors.Inlslx, defining a latent factor can be through the operator<=: which means that the RHS factor is defined by LHS observed variables.The observed variables must be presented in the given data set.Of course,f1 can be equivalently defined byf1 :=> y1 + y2 + y3.
As addressed in the first example, thelslx parser will automatically set many parameters that are not directly presented in these equations.
In this example, all of the observed variables are directed by some latent factor and hence they are endogenous.The variances of their residuals will be set as freely estimated parameters.Also, their intercepts will be freely estimated since no intercept variable
1presents in the specified equations.The three latent factors
f1,f2, andf3are exogenous variables.Their pairwise covariances will be also set as freely estimated parameters.However, because they are latent but not observed, their intercepts will be fixed at zero.If user hope to estimate the latent factor means, they should add an additional equationf1 + f2 + f3 <= 1.After adding this equation, on the one hand, the latent intercepts will be set as free as indicated by that equation.On the other hand, since intercept variable1now presents in the specified equations, the intercepts for the endogenous and observed variables will be then fixed at zero.
So far, the specification for the factor analysis model is not complete since the scales of factors are not yet determined.In SEM, there are two common ways for scale setting.The first way is to fix some loading per factor.For example, we may respecify the model via
fix(1) * y1 + y2 + y3 <=: f1
fix(1) * y4 + y5 + y6 <=: f2
fix(1) * y7 + y8 + y9 <=: f3
The prefixfix(1) will fix the corresponding loadings to be one.Simply using1 * y1 will be also interpreted as fixing the loading ofy1 at one to mimiclavaan.The second way for scale setting is fixing the variance of latent factors, which can be achieved by specifying additional equations
fix(1) * f1 <=> f1
fix(1) * f2 <=> f2
fix(1) * f3 <=> f3
Note that in the current version oflslx, scale setting will be not made automatically.Users must accomplish it manually.
When conducting factor analysis, we may face the problem that each variable may not be influenced by only one latent factor.The semi-confirmatory factor analysis, which penalizes some part of loading matrix, can be applied in this situation.One possible model specification for the semi-confirmatory approach is
y1 + y2 + y3 <=: f1
y4 + y5 + y6 <=: f2
y7 + y8 + y9 <=: f3
y4 + y5 + y6 + y7 + y8 + y9 <~: f1
y1 + y2 + y3 + y7 + y8 + y9 <~: f2
y4 + y5 + y6 + y7 + y8 + y9 <~: f3
fix(1) * f1 <=> f1
fix(1) * f2 <=> f2
fix(1) * f3 <=> f3
In this specification, loadings in the non-independent cluster will be also estimated but with penalization.
After version 0.6.3,lslx supports basiclavaan operators. The previous model can be equivalently specified as
f1 =~ y1 + y2 + y3
f2 =~ y4 + y5 + y6
f3 =~ y7 + y8 + y9
pen() * f1 =~ y4 + y5 + y6 + y7 + y8 + y9
pen() * f2 =~ y1 + y2 + y3 + y7 + y8 + y9
pen() * f3 =~ y4 + y5 + y6 + y7 + y8 + y9
f1 ~~ 1 * f1
f2 ~~ 1 * f2
f3 ~~ 1 * f3
Example 3: Path Models with both Observed Variables and Latent Factors
In the third example, we consider a path model with both observed variables and latent factors
fix(1) * y1 + y2 + y3 <=: f1
fix(1) * y4 + y5 + y6 <=: f2
fix(1) * y7 + y8 + y9 <=: f3
f3 <= f1 + f2
f1 + f2 + f3 <~ x1 + x2
f1 <~> f2
The first three equations specify the measurement model fory1 -y9 andf1 -f3.The forth equation describes the relations among latent factor.The fifth equation sets all the coefficients fromx1 -x2 tof1 -f3 to be penalized.The final equation states that the covariance of residuals off1 andf2 is estimated with penalization, which is achieved by the operator<~>.
Like Example 1 and 2, many parameters in the current example are automatically set bylslx.
Because
y1-y9andf1-f3are all endogenous, the variances of their residuals will be treated as freely estimated parameters.Also, due to the non-presence of intercept variable1, the intercept ofy1-y9will be set as free parametersand the intercept off1-f3will be set as zero.The variance, intercepts, and pairwise covariances of exogenous and observed variables
x1-x2will be all estimated freely.
In this example, we can see that model specification inlslx is quite flexible.Like usual SEM, users can specify their models according some substantive theory.If no theory is available to guide the relationships in some part of the model,the semi-confirmatory approach can set this part as exploratory by setting the corresponding parameters as penalized.
Example 4: Multi-Group Factor Analysis Model
In the fourth example, we consider a multi-group factor analysis model.
fix(1) * y1 + y2 + y3 <=: f1
fix(1) * y4 + y5 + y6 <=: f2
fix(1) * y7 + y8 + y9 <=: f3
The syntax specifies a factor analysis model with nine observed variables and three latent factors.Loadings fory2,y3,y5,y6,y8, andy9 are freely estimated in both groups.Loadings fory1,y4, andy7 are set as fixed for scale setting in both groups.You may observe that the syntax for multi-group analysis is the same as that for single group analysis.That is true because inlslx a multi-group analysis is mainly identified by specifying a group variable.If the imported data can be divided into several samples based on some group variable (argumentgroup_variable innew method, please see the section ofInitialize Method) for group labeling,lslx will automatically conduct multi-group analysis(see example ofSemi-Confirmatory Multi-Group Factor Analysis in the Section ofExamples).
Sometimes, we may hope to specify different model structures for the two groups.It can be achieved by using vector version of prefix, which is also motivated by the syntax inlavaan.For example, if we hope to restrict the loading fory2 to be 1 in the first group but set it as freely estimate parameter in the second group.Then we may use
fix(1) * y1 + c(fix(1), free()) * y2 + y3 <=: f1
Note that the order of groups is important here.Sincelslx treats the group variable asfactor, its order is determined by the sorted name of groups.For example, if three groupsc,a, andb are considered, then the first group isa, the second isb, and the third isc.
In the current version oflslx, coefficient constraints cannot be imposed.It seems that testing coefficient invariance across groups is impossible inlslx.However, the present package parameterizes group coefficients in different way compared to other SEM software (Huang, 2018).Underlslx, each group coefficient is decomposed into a sum of a reference component and an increment component.If the reference component is assumed to be zero, the increment component represents the group coefficient, which is equivalent to the usual parameterization in other software solutions.On the other hand, if some group is set as reference (argumentreference_group innew method, please see the section ofInitialize Method),then the reference component now represents the group coefficient of the reference group and other increment components represent the differences from the reference group.The coefficient invariance across groups can be evaluated by examining the value or sparsity of the corresponding increment component.
Optimization Algorithm
Let\theta denote the vector of model parameter.lslx tries to find a PL estimate for\theta by minimizing the objective functionobjective(\theta, \lambda) = loss(\theta) + regularizer(\theta, \lambda)whereloss is the ML loss function,regularizer is a regularizer, possibly lasso (Tibshirani, 1996) or mcp (Zhang, 2010), and\lambda is a regularization parameter.The optimization algorithm for minimizing the PL criterion is based on an improvedglmnet method (Friedman, Hastie, & Tibshirani, 2010) made by Yuan, Ho, and Lin (2012).The algorithm can be understood as a quasi-Newton method with inner loop and outer loop.The inner loop of the algorithm derives a quasi-Newton direction by minimizing a quadratic approximated objective function via coordinate descent.To save the computation time, the Hessian matrix for the quadratic term is approximated by the identity matrix, the Broyden-Fletcher-Goldfarb-Shanno (BFGS) method, or the expected Hessian (Fisher scoring).Although the computational cost of BFGS approximation is much smaller than calculating expected hessian,our experience shows that the two methods perform similarly in terms of computation time because more outer iterations are required for BFGS.The inner loop stops if the change of the derived direction is quite small.The outer loop of the algorithm updates the value of parameter estimate via the derived quasi-Newton direction and Armijo's rule.The outer loop stops if the maximal absolute element of subgradient of objective function is smaller than the specified tolerance.The minimizer is the so-called PL estimates.Note that the PL estimates is a function of penalty level, i.e., PL estimates can vary under different penalty levels.An optimal penalty level can be chosen by using model selection criterion.
Inlslx, PL estimates under each penalty level and convexity level specified by user will be calculated.The convexity levels will be sorted from large to small based on the suggestion of Mazumder (2011).The previous obtained PL estimate will be used as warm start for further minimization problem.Since the solution path is continuous, the warm start can speed up the convergence of minimization (see Friedman, Hastie, & Tibshirani, 2010).
Missing Data
When conducting SEM, it is easy to encounter the problem of missing data.Inlslx, missing data can be handled by the listwise deletion method and the two-stage method (Yuan & Bentler, 2000).The listwise deletion method only uses fully complete observations for further SEM analysis.If the missing mechanism is missing completely at random (MCAR; Rubin, 1976), the listwise deletion method can yield a consistent estimator.The two-stage method first calculates the saturated moments by minimizing the likelihoods based on all of the available observations and then use the obtained saturated moment estimates for further SEM analysis.Under the assumption of missing at random (MAR; Rubin, 1976), it has been shown that the two-stage method can yield a consistent estimate.In addition, the standard errors of coefficients can be also consistently estimated if a correct asymptotic covariance of saturated moments is used.Because the two-stage approach is generally valid and efficient compared to the listwise deletion method,lslx set the two-stage method as default for handling the missing data problem.The current version also supports the use of auxiliary variables (see Savalei & Bentler, 2008).If the two-stage method is implemented, the standard error formula will be corrected for the presence of missing data (see Yuan & Lu, 2008 for technical details).
So far,lslx doesn't include the full-information maximum likelihood (FIML) method for missing values.One reason is that PL can be computationally intensive if many penalty levels are considered.The additional E-step in each iteration of FIML makes the problem worse.Another reason is that the two-step method has been shown to outperform FIML in simulation settings (Savalei & Falk, 2014).Therefore, we tend to believe that the implementation of FIML in PL may not bring further advantages over the two-step method.
Penalty Level Selection
Penalty level selection inlslx is based on optimizing the value of some information criterion.Many information criteria are available for this task.In the current version, available information criteria are
aicAkaike Information Criterion (Akaike, 1974)
AIC(\theta)=loss(\theta) - (2 / N) * df(\theta)aic3Akaike Information Criterion with Penalty Being 3 (Sclove, 1987)
AIC3(\theta)=loss(\theta) - (3 / N) * df(\theta)caicConsistent Akaike Information Criterion (Bozdogan, 1987)
CAIC(\theta)=loss(\theta) - ((log(N) + 1) / N) * df(\theta)bicBayesian Information Criterion (Schwarz, 1978)
BIC(\theta)=loss(\theta) - (log(N) / N) * df(\theta)abicAdjusted Bayesian Information Criterion (Sclove, 1987)
ABIC(\theta)=loss(\theta) - (log((N + 2) / 24 ) / N) * df(\theta)hbicHaughton Bayesian Information Criterion (Haughton, 1997)
HBIC(\theta)=loss(\theta) - (log(N / \pi ) / N) * df(\theta)
where
N: total number of sample size;G: total number of group;loss(\theta): the loss value under estimate\theta;df(\theta): the degree of freedom defined as (1)G * P * (P + 3) / 2 - e(\theta)withe(\theta)being the number of non-zero elements in\thetafor Lasso and MCP; or (2) the expectation of likelihood ratio statistics with ridge for ridge and elastic net.
Note the formula for calculating the information criteria inlslx are different to other software solutions.The loss function value is used to replace the likelihood function value and hence the penalty term is also divided by sample sizeN.For each information criterion, a robust version is calculated if raw data is available.Their corresponding names areraic,raic3,rcaic,rbic,rabic, andrhbic with "r" standing for "robust".These robust criteria use the Satorra-Bentler scaling factor for correcting degree of freedom.For the case of normal data and correctly specified model, the two versions will be the same asymptotically.
Huang, Chen, and Weng (2017) have study the asymptotic behaviors ofaic andbic under penalized estimation.They show that under suitable conditions,aic can select a model with minimum expected loss andbic can choose the most parsimonious one from models that attain the minimum expected loss.By the order of penalty term, we may expect: (1) the large sample behaviors ofaic3 andtic will be similar toaic;and (2) the asymptotic behaviors ofcaic,abic, andhbic will be similar tobic.However, their small-sample performances require further studies.
Model Fit Evaluation
Given a chosen penalty level, we may evaluate the overall model fit by using fit indices.In the current version, available fit indices for model evaluation are
rmseaRoot Mean Square Error of Approximation (Steiger, 1998; Steiger & Lind, 1980)
RMSEA(\theta)=\sqrt(G * max(loss(\theta) / df(\theta) - 1 / N, 0))cfiComparative Fit Index (Bentler, 1990)
CFI(\theta)=(max(loss_0 - df_0 / N, 0) - max(loss(\theta) - df(\theta) / N, 0)) / max(loss_0 - df_0 / N, 0)nnfiNon-Normed Fit Index (Tucker & Lewis, 1973)
NNFI(\theta)=(loss_0 / df_0 - loss(\theta) / df(\theta)) / (loss_0 / df_0 - 1 /N)srmrStandardized Root Mean of Residual (Bentler, 1995)
SRMR(\theta)=\sqrt(\sum_g w_g \sum_i \sum_{j \leq i} ((\sigma_{gij} - s_{gij})^2 / (\sigma_{gii} * \sigma_{gjj})) / (G * P * (P + 1) / 2)+\sum_g w_g \sum_i ((\mu_{gi} - m_{gi}) ^ 2 / \sigma_{gii}) / (G * P))
where
N: total number of sample size;G: total number of groups;P: number of observed variables;w_g: sample weight of groupg;loss(\theta): the loss value under estimate\theta;\#(\theta): the number of non-zero elements in\theta;df(\theta): the degree of freedom defined byG * P * (P + 3) / 2 -\#(\theta);loss_0: the loss value under baseline model;df_0: the degree of freedom under baseline model;\sigma_{gij}: the(i,j)element of model implied covariance at groupg;s_{gij}: the(i,j)element of sample covariance at groupg;\mu_{gi}: theielement of model implied mean at groupg;m_{gi}: theielement of sample mean at groupg;
Inlslx, the baseline model is the model that assumes a diagonal covariance matrix and a saturated mean.Hence, the baseline model may not be appropriate if users hope to evaluate the goodness-of-fit of mean structure.
It is also possible to test overall model fit by formal statistical test.In the current version, statistical tests for likelihood ratio (LR) and root mean square error of approximation (RMSEA) can be implemented.If raw data is available,lslx calculates mean-adjusted versions of LR statistic (Satorra & Bentler, 1994) and RMSEA intervals (Brosseau-Liard, Savalei & Li, 2012; Li & Bentler, 2006).It should be noted that the classical tests may not be valid after penalty level selection because the task of penalty level selection may destroy the sampling distribution of test statistics (see Pötscher, 1991 for discussion).Valid post model selection inference methods require further development.
Coefficient Evaluation
Given a chosen penalty level, we may evaluate the significance of coefficients (or parameters).In the current version, standard errors based on the expected/observed Fisher information matrix and the sandwich formula are available (see Yuan & Hayashi, 2006 for discussion).Because the sandwich formula is generally valid compared to the approaches based on Fisher information,lslx uses the sandwich formula as default whenever raw data is available.Note that sandwich covariance matrix inlslx is calculated based on Equation (14) in Yuan and Hayashi (2006) but not Equation (2.12a) in Browne (1984) to accommodate the potential model misspecification.Again, the significance tests may not be valid after penalty level selection.After version 0.6.4, several post-selection mehtods are available (Huang, in press), inlcuding PoSI method with Scheffe constant (Berk, Brown, Buja, Zhang, & Zhao, 2013) and Polyhedral method (Lee, Sun, Sun, & Taylor, 2016).
Initialize Method
$new(model, data, numeric_variable, ordered_variable, group_variable, reference_group, weight_variable, auxiliary_variable, sample_cov, sample_mean, sample_size, sample_moment_acov, verbose = TRUE)
- Arguments
modelA
characterwith length one to represent the model specification.dataA
data.frameof raw data.It must contains variables specified inmodel(and possibly the variables specified bygroup_variableandweight_variable).numeric_variableA
characterto specify which response variables should be transfromed intonumeric.ordered_variableA
characterto specify which response variables should be transfromed intoordered.weight_variableA
characterwith length one to specify what variable is used for sampling weight.auxiliary_variableA
characterto specify what variable(s) is used as auxiliary variable(s) for estimating saturated moments when missing data presents and two-step method is implemented.Auxiliary variable(s) must be numeric. If any categorical auxiliary is considered, please transform it into dummy variables before initialization.group_variableA
characterwith length one to specify what variable is used for labeling group.reference_groupA
characterwith length one to specify which group is set as reference.sample_covA numeric
matrix(single group case) or alistof numericmatrix(multi-group case) to represent sample covariance matrixs. It must have row and column names that match the variable names specified inmodel.sample_meanA
numeric(single group case) or alistofnumeric(multi-group case) to represent sample mean vectors.sample_sizeA
numeric(single group case) with length one or alistofnumeric(multi-group case) to represent the sample sizes.sample_moment_acovA numeric
matrix(single group case) or alistof numericmatrix(multi-group case) to represent asymptotic covariance for moments.verboseA
logicalto specify whether messages made bylslxshould be printed.
Details
$new() initializes a new object oflslx R6 class for fitting semi-confirmatory structural equation modeling (SEM).In most cases, a newlslx object is initialized by supplyingmodel anddata.For details of syntax for model specification, see the section ofModel Syntax.By default, types of response variables (numeric versusordered) will be infered according to the importeddata.frame.If users hope to transform variables types inlslx,numeric_variable andordered_variable can be used. When multi-group analysis is desired, argumentgroup_variable should be given to specify what variable is used for labeling group.Argumentreference_group can be used to set reference group.Note that if some group is set as reference, the coefficients in other groups will represent increments from the reference.When the missingness of data depends on some other variables,auxiliary_variable can be used to specify auxiliary variables for estimate saturated moments.For details of missing data, see the section ofMissing Data.If raw data is not available,lslx also supports initialization via sample moments.In that case,sample_cov andsample_size are required.Ifsample_mean is missing under moment initialization, it is assumed to be zero.
Set-Related Methods
$free_coefficient(name, start, verbose = TRUE)$penalize_coefficient(name, start, verbose = TRUE)$fix_coefficient(name, start, verbose = TRUE)$free_directed(left, right, group, verbose = TRUE)$penalize_directed(left, right, group, verbose = TRUE)$fix_directed(left, right, group, verbose = TRUE)$free_undirected(both, group, verbose = TRUE)$penalize_undirected(both, group, verbose = TRUE)$fix_undirected(both, group, verbose = TRUE)$free_block(block, group, type, verbose = TRUE)$penalize_block(block, group, type, verbose = TRUE)$fix_block(block, group, type, verbose = TRUE)$free_heterogeneity(block, group, verbose = TRUE)$penalize_heterogeneity(block, group, verbose = TRUE)$fix_heterogeneity(block, group, verbose = TRUE)
- Arguments
nameA
characterto indicate which coefficients should be reset.startA
numericto specify starting values.The length ofstartshould be one or match the length ofnameto avoid ambiguity.Ifstartis missing, the starting value will be set as(1)NAfor free or penalized coefficient; and (2)0for fixed coefficient.leftA
characterto indicate variable names in the left-hand side of operator"<-".rightA
characterto indicate variable names in the right-hand side of operator"<-".bothA
characterto indicate variable names in both side of operator"<->".groupA
characterto indicate group names that the specified relations belong to.blockA
characterwith length one to indicate a block such that the corresponding target coefficient will be reset.Its value must be"f<-1","y<-1","f<-f","f<-y","y<-f","y<-y","f<->f","f<->y","y<->f", or"y<->y".typeA
characterto indicate which type of parameter should be changed in the given block.Its value must be"free","fixed", or"pen". Iftypeis not specified, the types of all parameters in the givenblockwill be modified.verboseA
logicalto specify whether messages made bylslxshould be printed.
Details
Set-related methods include several member functions that can be used to modify the initialized model specification.Like most encapsulation objects, set-related function is used to modify the inner members of object.So far, the set-related methods are all established to modify the model.The data are protected without any modification.
$free_coefficient() /$penalize_coefficient() /$fix_coefficient() sets the coefficient namedname as FREE / PENALIZED / FIXED with starting valuestart.In the case of single group analysis, argumentname can be replaced by relations, i.e., the group name can be omitted.
$free_directed() /$penalize_directed() /$fix_directed() sets all the regression coefficients from variables inright to variables inleft at groups ingroup as FREE / PENALIZED / FIXED.
$free_undirected() /$penalize_undirected() /$fix_undirected() sets all the covariances among variables inboth at groups ingroup as FREE / PENALIZED / FIXED.Note that this method all always not modify the variance of variables specified inboth.
$free_block() /$penalize_block() /$fix_block() sets all the parameters belonging toblock atgroup withtype as FREE / PENALIZED / FIXED.
$free_heterogeneity() /$penalize_heterogeneity() /$fix_heterogeneity() sets every target coefficient as FREE / PENALIZED / FIXED.A target coefficient should satisfy that (1) it belongs toblock atgroup, and(2) it has either free or penalized reference component.The method is only available in the case of multi-group analysis with specified reference group.
Insidelslx object, every coefficient (or parameter) has its own name and belongs to some block.
The coefficient name is constructed by a relation and a group name.A relation is defined by combining a left variable name, an operator, and a right variable name.For example,
"y1<-f1"is a relation to represent the coefficient from"f1"to"y1".Note that in relation we only use operators"<-"and"<->"."->"is illegal and no distinction between"="and"~"are made.In multi-group analysis cases, a coefficient name requires explicitly specifying group name.For example,"y1<-f1/G1"is the parameter name for the path coefficient from"f1"to"y1"in group"G1".Block is defined by the types of left variable and right variable, and the operator.Inlslx,
"y"is used to indicate observed response,"f"is used for latent factor, and"1"is for intercept.Hence,"y<-f"is the block that contains all the coefficients from latent factors to observed responses.There are 10 possible distinct blocks:"f<-1","y<-1","f<-f","f<-y","y<-f","y<-y","f<->f","f<->y","y<->f", and"y<->y"
Arguments in set-related methods may rely on the naming rule of coefficent name and block to modify model specification.
Fit-Related Methods
$fit(penalty_method = "lasso", lambda_grid = "default", delta_grid = "default", step_grid = "default", loss = "default", algorithm = "default", missing_method = "default", start_method = "default", lambda_direction = "default", lambda_length = 50L, delta_length = 3L, threshold_value = 0.3, iter_out_max = 100L, iter_in_max = 50L, iter_other_max = 500L, iter_armijo_max = 100L, tol_out = 1e-3, tol_in = 1e-3, tol_other = 1e-7, step_size = 0.5, momentum = 0, armijo = 1e-5, ridge_cov = 0, ridge_hessian = 1e-4, warm_start = TRUE, positive_variance = TRUE, minimum_variance = 1e-4, enforce_cd = FALSE, random_update = TRUE, weight_matrix = NULL, verbose = TRUE)$fit_none(...)$fit_lasso(lambda_grid = "default", ...)$fit_ridge(lambda_grid = "default", ...)$fit_elastic_net(lambda_grid = "default", delta_grid = "default", ...)$fit_mcp(lambda_grid = "default", delta_grid = "default", ...)$fit_forward(step_grid = "default", ...)$fit_backward(step_grid = "default", ...)
- Arguments
penalty_methodA
characterto specify the penalty method.There are two class penalty methods can be specified.For penalized estimation with a regularizer,"lasso","ridge","elastic_net", and"mcp"can be used.For penalized estimation with stepwise search,"forward"and"backward"can be implemented. If no penalty is considered, we can setpenalty_methodas"none".lambda_gridA non-negative
numericto specify penalty levels for the regularizer.If it is set as"default", its value will be generated automatically based on the variable scales.delta_gridA non-negative
numericto specify the combination weight for"elastic_net"or the convexity level for"mcp".If it is set as"default", its value will be generated automatically.step_gridA non-negative
numericto specify a grid for stepwise search with"forward"and"backward".lossA
characterto determine the loss function.The current version supports"ml"(maximum likelihood),"uls"(unweighted least squares),"dwls"(diagonal weighted least squres), and"wls"(weighted least squares).The maximum likelihood is only available for all continuous response variables.If the argument is set as"default", then (1)"ml"will be implemented for all continuous response variables; (2)"dwls"will be implemented for ordinal or mixed types response variables.algorithmA
characterto determine the method of optimization.The current version supports"gd"(gradient descent),"bfgs"(Broyden-Fletcher-Goldfarb-Shanno),"fisher"(Fisher scoring), and"dynamic"(an adaptive algorithm).If the argument is set as"default", then"dynamic"will be implemented.missing_methodA
characterto determine the method for handling missing data (orNA).The current version supports"two_stage"and"listwise_deletion".If the argument is set as"default"and a raw data set is available, the"two_stage"will be implemented.If the argument is set as"default"and only moment data is available, the"listwise_deletion"will be used(actually, in this case no missing presences).start_methodA
characterto determine the method for calculating unspecified starting values.The current version supports"mh"(McDonald & Hartmann, 1992) and"heuristic".If the argument is set as"default", the"mh"will be implemented.lambda_directionA
characterto determine the "direction" oflambda_grid."decrease"sortslambda_gridfrom large to small. On the contrary,"increase"sortslambda_gridfrom small to large. If the argument is set as"default","increase"will be used when the smallest element oflambda_gridis larger than zero;otherwise,"decrease"is assumed.lambda_lengthA
numericto specify the length of automatically generatedlambda_gridunderlambda_grid = "default".delta_lengthA
numericto specify the length of automatically generateddelta_gridunderdelta_grid = "default".threshold_valueA
numericto specify the "largest threshold value" forlambda_gridinitialization.iter_out_maxA positive
integerto specify the maximal iterations for outer loop of the modifiedglmnetalgorithm.iter_in_maxA positive
integerto specify the maximal iterations for inner loop of the modifiedglmnetalgorith.iter_other_maxA positive
integerto specify the maximal iterations for other loop.iter_armijo_maxA positive
integerto specify the maximal iterations for searching step-size via Armijo rule.tol_outA small positive
numericto specify the tolerance (convergence criterion) for outer loop of the modifiedglmnetalgorithm.tol_inA small positive
numericto specify the tolerance (convergence criterion) for inner loop of the modifiedglmnetalgorithm.tol_otherA small positive
numericto specify the tolerance (convergence criterion) for other loop.step_sizeA positive
numericsmaller than one to specify the step-size.momentumA
numericbetween 0 and 1 for momentum parameter.armijoA small positive
numericfor the constant in Armijo rule.ridge_covA small positive
numericfor the ridge of sample covariance matrix.ridge_hessianA small positive
numericfor the ridge of approximated hessian in optimization.ridge_weightA small positive
numericfor the ridge of weight matrix in weighted least squares.warm_startA
logicalto specify whether the warm start approach should be used.positive_varianceA
logicalto specify whether the variance estimate should be constrained to be larger thanminimum_variance.minimum_varianceA
numericto specify the minimum value of variance ifpositive_variance = TRUE.enforce_cdA
logicto specify whether coordinate descent should be used when no penalty function is used. Its default value is TRUE.random_updateA
logicto specify whether coordinate descent should be conducted in a random order. Its default value is TRUE.weight_matrixA
listwith length equaling to the number of groups to specify a user-defined weight matrix for least squares loss.verboseA
logicalto specify whether messages made bylslxshould be printed....Other passing arguments for calling
$fit().
Details
Fit-related methods are used for fitting model to data.The success of these methods may depend on the specified fitting control.For details of optimization algorithm, see the section ofOptimization Algorithm.
$fit() fits the specified model to data by minimizing a penalized loss function.It is the most comprehensive fit method and hence many arguments can be specified.
$fit_none() fits the specified model to data by minimizing a loss function without penalty.It is a user convinient wrapper of$fit() withpenalty_method = "none".
$fit_lasso() fits the specified model to data by minimizing a loss function with lasso penalty (Tibshirani, 1996).It is a user convinient wrapper of$fit() withpenalty_method = "lasso".
$fit_ridge() fits the specified model to data by minimizing a loss function with ridge penalty (Hoerl & Kennard, 1970).It is a user convinient wrapper of$fit() withpenalty_method = "ridge".
$fit_elastic_net() fits the specified model to data by minimizing a loss function with elastic net penalty (Zou & Hastie, 2005).It is a user convinient wrapper of$fit() withpenalty_method = "elastic_net".
$fit_mcp() method fits the specified model to data by minimizing a loss function with mcp (Zhang, 2010).It is a user convinient wrapper of$fit() withpenalty_method = "mcp".
$fit_forward() method fits the specified model to data by minimizing a loss function with forward searching.It is a user convinient wrapper of$fit() withpenalty_method = "forward".
$fit_backward() method fits the specified model to data by minimizing a loss function with backward searching.It is a user convinient wrapper of$fit() withpenalty_method = "backward".
Summarize Method
$summarize(selector, lambda, delta, step, standard_error = "default", debias = "default", inference = "default", alpha_level = .05, include_faulty = FALSE, style = "default", mode = "default", digit = 3, interval = TRUE, output)
- Arguments
selectorA
characterto specify a selector for determining an optimal penalty level.Its value can be any one in"aic","aic3","caic","bic","abic","hbic",or their robust counterparts"raic","raic3","rcaic","rbic","rabic","rhbic"if raw data is available.lambdaA
numericto specific a chosen optimal penalty level. If the specifiedlambdais not inlambda_grid, a nearest legitimate value will be used.deltaA
numericto specific a chosen optimal convexity level.If the specifieddeltais not indelta_grid, a nearest legitimate value will be used.stepA
numericto specific a chosen step for stepwise searching.If the specifiedstepis not instep_grid, a nearest legitimate value will be used.standard_errorA
characterto specify the standard error to be used for hypothesis testing.The argument can be either"sandwich","expected_information", and"observed_information".If it is specified as"default", it will be set as(1)"sandwich"when raw data is available; (2)"observed_information"when only moment data is available.debiasA
characterto specify a debias method for obtaining a debiased estimator.Its value can be either"none"or"one_step". If it is specified as"default","none"will be used unlesspost = "polyhedral"is used.inferenceA
characterto specify the method for post selection inference.The current version supports"naive","polyhedral", and"scheffe".If it is specified as"default","naive"will be used.alpha_levelA
numericto specify the alpha level for constructing 1 - alpha confidence intervals.include_faultyA
logicalto specify whether non-convergence or non-convexity results should be removed for penalty level selection.Non-convergence result determined by examining the maximal elements of absolute objective gradient and the number of iterations.non-convexity result is determined by checking the minimum of univariate approximate hessian.styleA
characterto specify whether the style of summary.Its value must be either"default","manual","minimal", or"maximal".modeA
characterto specify the mode of summary. Its value must be"print"or"return"."print"will print the summary result and"return"will return alistof the summary result.If it is specified as"default", it will be set as"print".digitAn
integerto specify the number of digits to be displayed.intervalA
logicalto specify whether the confidence interval should be printed.
Details
$summarize() prints a summary for the fitting result under a selected peanlty/convexity level.It requires users to specify which selector should be used or a combination ofgamma andlambda..By default, the summary includes model information, numerical conditions, fit indices, coefficient estimates, and related statistical inference.It can be modified by thestyle argument. For details of evaluation and inference methods, see the sections ofModel Fit Evaluation andCoefficient Evaluation.
Test-Related Methods
$test_lr(selector, lambda, delta, step, include_faulty = FALSE)$test_rmsea(selector, lambda, delta, step, alpha_level = .05, include_faulty = FALSE)$test_coefficient(selector, lambda, delta, step, standard_error = "default", debias = "default", inference = "default", alpha_level = .05, include_faulty = FALSE)
- Arguments
selectorA
characterto specify a selector for determining an optimal penalty level.Its value can be any one in"aic","aic3","caic","bic","abic","hbic",or their robust counterparts"raic","raic3","rcaic","rbic","rabic","rhbic"if raw data is available.deltaA
numericto specific a chosen optimal weight for elastic net or convexity level for mcp.If the specifieddeltais not indelta_grid, a nearest legitimate value will be used.stepA
numericto specific a chosen step for stepwise searching.If the specifiedstepis not instep_grid, a nearest legitimate value will be used.standard_errorA
characterto specify the standard error to be used for hypothesis testing.The argument can be either"sandwich","expected_information", and"observed_information".If it is specified as"default", it will be set as(1)"sandwich"when raw data is available; (2)"observed_information"when only moment data is available.debiasA
characterto specify a debias method for obtaining a debiased estimator.Its value can be either"none"or"one_step". If it is specified as"default","none"will be used unlesspost = "polyhedral"is used.inferenceA
characterto specify the method for post selection inference.The current version supports"naive","polyhedral", and"scheffe".If it is specified as"default","naive"will be used.alpha_levelA
numericto specify the alpha level for constructing 1 - alpha confidence intervals.include_faultyA
logicalto specify whether non-convergence or non-convexity results should be removed for penalty level selection.Non-convergence result determined by examining the maximal elements of absolute objective gradient and the number of iteration.non-convexity result is determined by checking the minimum of univariate approximate hessian.
Details
Test-related methods are used to obtain the result of specific statistical test.So far, only tests for likelihood ratio (LR), root mean square error of approximation (RMSEA), and coefficients are available.
$test_lr() returns adata.frame of result for likelihood ratio test.If raw data is available, it also calculates a mean-adjusted statistic.For details of significance test method for LR, see the section ofModel Fit Evaluation.
$test_rmsea() returns adata.frame of result for rmsea confidence intervals.If raw data is available, it also calculates a mean-adjusted confidence interval (Brosseau-Liard, Savalei & Li, 2012; Li & Bentler, 2006).For details of confidence interval construction for RMSEA, see the section ofModel Fit Evaluation.
$test_coefficient() returns adata.frame of result for coefficient significance and confidence interval.For details of standard error formula for coefficients, see the section ofCoefficient Evaluation.
Plot-Related Methods
$plot_numerical_condition(condition, x_scale = "default", mode = "default")$plot_information_criterion(criterion, x_scale = "default", mode = "default")$plot_fit_index(index, x_scale = "default", mode = "default")$plot_coefficient(block, left, right, both, x_scale = "default", mode = "default")
- Arguments
conditionA
characterto specify which numerical conditions should be plotted.Its value must be"objective_value","objective_gradient_abs_max","objective_hessian_convexity","n_iter_out","loss_value","n_nonzero_coefficient", or their combination.criterionA
characterto specify which information criteria should be plotted.Its value must be"aic","aic3","caic","bic","abic","hbic","raic","raic3","rcaic","rbic","rabic","rhbic", or their combination.indexA
characterto specify which fit indices should be plotted.Its value must be"rmsea","cfi","nnfi","srmr", or their combination.blockA
characterwith length one to indicate a block such that the corresponding target coefficient will be reset.Its value must be one of"f<-1","y<-1","f<-f","f<-y","y<-f","y<-y","f<->f","f<->y","y<->f", or"y<->y".leftA
characterto specify the variables in the left-hand side of operator inblock.rightA
characterto specify the variables in the right-hand side of operator inblock.bothA
characterto specify the variables in both sides of operator inblock.lambda_scaleA
characterto specify the scale of lambda (x-axis) forcoord_trans()inggplot2.modeA
characterto specify the mode of plot. Its value must be"plot"or"return"."plot"will plot the result and"return"will return adata.framefor plot.If it is specified as"default", it will be set as"plot".
Details
Plot-related methods are used for visualizing the fitting results.
$plot_numerical_condition() plots the values of selected numerical conditions.It can be used to assess the quality of optimization.By default,"n_iter_out","objective_gradient_abs_max", and"objective_hessian_convexity" across the given penalty levels are plotted.
$plot_information_criterion() shows how the values of information criteria vary with penalty levels.By default,"aic","aic3","caic","bic","abic", and"hbic" are plotted.
$plot_fit_index() shows how the values of fit indices vary with penalty levels.By default,"rmsea","cfi","nnfi", and"srmr" are plotted.
$plot_coefficient() visualizes the solution paths of coefficients belonging to the intersection ofblock,left,right, andboth arguments.By default, all of the coefficients are plotted.
Get-Related Methods
$get_model()$get_data()$get_fitting()
Details
Get-related methods are defined to obtain a deep copy of members insidelslx.Note that all of the data members oflslx are set as private to protect the inner data structure.They cannot be assessed directly via$.
$get_model() returns a deep copy ofmodel member in the currentlslx object.
$get_data() returns a deep copy ofdata member in the currentlslx object.
$get_fitting() returns a deep copy offitting member in the currentlslx object.
Extract-Related Methods
$extract_specification()$extract_saturated_cov()$extract_saturated_mean()$extract_saturated_moment_acov()$extract_penalty_level(selector, lambda, delta, step, include_faulty = FALSE)$extract_numerical_condition(selector, lambda, delta, step, include_faulty = FALSE)$extract_information_criterion(selector, lambda, delta, step, include_faulty = FALSE)$extract_fit_index(selector, lambda, delta, step, include_faulty = FALSE)$extract_cv_error(selector, lambda, delta, step, include_faulty = FALSE)$extract_coefficient(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_debiased_coefficient(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_implied_cov(selector, lambda, delta, step, include_faulty = FALSE)$extract_implied_mean(selector, lambda, delta, step, include_faulty = FALSE)$extract_residual_cov(selector, lambda, delta, step, include_faulty = FALSE)$extract_residual_mean(selector, lambda, delta, step, include_faulty = FALSE)$extract_coefficient_matrix(selector, lambda, delta, step, block, include_faulty = FALSE)$extract_moment_jacobian(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_expected_information(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_observed_information(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_bfgs_hessian(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_score_acov(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_coefficient_acov(selector, lambda, delta, step, standard_error = "default", type = "default", include_faulty = FALSE)$extract_loss_gradient(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_regularizer_gradient(selector, lambda, delta, step, type = "default", include_faulty = FALSE)$extract_objective_gradient(selector, lambda, delta, step, type = "default", include_faulty = FALSE)
- Arguments
selectorA
characterto specify a selector for determining an optimal penalty level.Its value can be any one in"aic","aic3","caic","bic","abic","hbic",or their robust counterparts"raic","raic3","rcaic","rbic","rabic","rhbic"if raw data is available.lambdaA
numericto specific a chosen optimal penalty level. If the specifiedlambdais not inlambda_grid, a nearest legitimate value will be used.deltaA
numericto specific a chosen optimal weight for elastic net or convexity level for mcp.If the specifieddeltais not indelta_grid, a nearest legitimate value will be used.stepA
numericto specific a chosen step for stepwise searching.If the specifiedstepis not instep_grid, a nearest legitimate value will be used.standard_errorA
characterto specify the standard error to be used for hypothesis testing.The argument can be either"sandwich","expected_information", and"observed_information".If it is specified as"default", it will be set as(1)"sandwich"when raw data is available; (2)"observed_information"when only moment data is available.blockA
characterwith length one to indicate a block such that the corresponding target coefficient will be reset.Its value must be"f<-1","y<-1","f<-f","f<-y","y<-f","y<-y","f<->f","f<->y","y<->f", or"y<->y".typeA
characterto specify the type of parameters that will be used to compute the extracted quantity. The argument can be either"all","fixed","free","pen","effective"(include"free"+"selected"), and"selected"(non-zero element of"pen").If it is specified as"default", it will be set asall.include_faultyA
logicalto specify whether non-convergence or non-convexity results should be removed for penalty level selection.Non-convergence result determined by examining the maximal elements of absolute objective gradient and the number of iterations.non-convexity result is determined by checking the minimum of univariate approximate hessian.
Details
Many extract-related methods are defined to obtain quantities that can be used for further SEM applications or model diagnosis.Some of these quantities only depend on data (e.g., saturated sample covariance matrix), but some of them relies on a penalty level (e.g., gradient of objective function).An optimal penalty level can be determined by specifying aselector or a combination ofgamma andlambda.When implementing fit-related methods,lslx only records necessary results for saving memory.Therefore, the extract-related methods not only extract objects but may possibly re-compute some of them.If the extracted quantity is a function of model coefficients, note that fixed coefficient is still considered as a valid variable.For example, the sub-gradient of objective function is calculated by considering both estimated coefficients and fixed coefficients.Hence, it is not appropriate to use all the elements of the sub-gradient to evaluate the optimality of solution because the values of fixed coefficients are not optimized.Fortunately, thetype argument can be used to choose desired parameters by their types.
$extract_specification() returns adata.frame of model specification.
$extract_saturated_cov() returns alist of saturated sample covariance matrix(s).
$extract_saturated_mean() returns alist of saturated sample mean vector(s).
$extract_saturated_moment_acov() returns alist of asymptotic covariance matrix(s) of saturated moments.Note that if raw data is not available, asymptotic covariance matrix is calculated by assuming normality for data.
$extract_penalty_level() returns acharacter of the index name of the optimal penalty level.
$extract_numerical_condition() returns anumeric of the numerical conditions.
$extract_information_criterion() returns anumeric of the values of information criteria.
$extract_fit_indice() returns anumeric of the values of fit indices.
$extract_coefficient() returns anumeric of estimates of the coefficients.
$extract_implied_cov() returns alist of model-implied covariance matrix(s).
$extract_implied_mean() returns alist of model-implied mean vector(s).
$extract_residual_cov() returns alist of residual matrix(s) of covariance.
$extract_residual_mean() returns alist of residual vector(s) of mean.
$extract_coefficient_matrix() returns alist of coefficient matrix(s) specified byblock.
$extract_moment_jacobian() returns amatrix of Jacobian of moment structure.
$extract_expected_information() returns amatrix of the expected Fisher information matrix.
$extract_observed_information() returns amatrix of the observed Fisher information matrix.Note that the observed information matrix is calculated via numerical differentiation for the gradient of loss.
$extract_bfgs_hessian() returns amatrix of the BFGS Hessian matrix.
$extract_score_acov() returns amatrix of the asymptotic covariance of scores.
$extract_coefficient_acov() returns amatrix of the asymptotic covariance of coefficients.For details of standard error formula, see the section ofCoefficient Evaluation.
$extract_loss_gradient() returns amatrix of the gradient of loss function.
$extract_regularizer_gradient() returns amatrix of the sub-gradient of regularizer.
$extract_objective_gradient() returns amatrix of the sub-gradient of objective function.
Super class
lslx::prelslx ->lslx
Methods
Public methods
Inherited methods
Methodextract_specification()
Usage
lslx$extract_specification()
Methodextract_saturated_cov()
Usage
lslx$extract_saturated_cov()
Methodextract_saturated_mean()
Usage
lslx$extract_saturated_mean()
Methodextract_saturated_moment_acov()
Usage
lslx$extract_saturated_moment_acov()
Methodextract_lambda_grid()
Usage
lslx$extract_lambda_grid()
Methodextract_delta_grid()
Usage
lslx$extract_delta_grid()
Methodextract_weight_matrix()
Usage
lslx$extract_weight_matrix()
Methodextract_penalty_level()
Usage
lslx$extract_penalty_level( selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_coefficient_indicator()
Usage
lslx$extract_coefficient_indicator( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_numerical_condition()
Usage
lslx$extract_numerical_condition( selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_information_criterion()
Usage
lslx$extract_information_criterion( selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_fit_index()
Usage
lslx$extract_fit_index(selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_cv_error()
Usage
lslx$extract_cv_error(selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_coefficient()
Usage
lslx$extract_coefficient( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_debiased_coefficient()
Usage
lslx$extract_debiased_coefficient( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_implied_cov()
Usage
lslx$extract_implied_cov(selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_implied_mean()
Usage
lslx$extract_implied_mean( selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_residual_cov()
Usage
lslx$extract_residual_cov( selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_residual_mean()
Usage
lslx$extract_residual_mean( selector, lambda, delta, step, include_faulty = FALSE)
Methodextract_coefficient_matrix()
Usage
lslx$extract_coefficient_matrix( selector, lambda, delta, step, block, include_faulty = FALSE)
Methodextract_moment_jacobian()
Usage
lslx$extract_moment_jacobian( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_expected_information()
Usage
lslx$extract_expected_information( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_observed_information()
Usage
lslx$extract_observed_information( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_score_acov()
Usage
lslx$extract_score_acov( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_coefficient_acov()
Usage
lslx$extract_coefficient_acov( selector, lambda, delta, step, standard_error = "default", ridge_penalty = "default", type = "default", include_faulty = FALSE)
Methodextract_loss_gradient()
Usage
lslx$extract_loss_gradient( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_regularizer_gradient()
Usage
lslx$extract_regularizer_gradient( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodextract_objective_gradient()
Usage
lslx$extract_objective_gradient( selector, lambda, delta, step, type = "default", include_faulty = FALSE)
Methodfit()
Usage
lslx$fit( penalty_method = "mcp", lambda_grid = "default", delta_grid = "default", step_grid = "default", loss = "default", algorithm = "default", missing_method = "default", start_method = "default", lambda_direction = "default", lambda_length = 50L, delta_length = 3L, threshold_value = 0.3, subset = NULL, cv_fold = 1L, iter_out_max = 100L, iter_in_max = 50L, iter_other_max = 500L, iter_armijo_max = 20L, tol_out = 0.001, tol_in = 0.001, tol_other = 1e-07, step_size = 1, momentum = 0, armijo = 1e-05, ridge_cov = 0, ridge_hessian = 1e-04, ridge_weight = 1e-04, warm_start = TRUE, positive_variance = TRUE, minimum_variance = 1e-04, armijo_rule = TRUE, enforce_cd = TRUE, random_update = TRUE, weight_matrix = NULL, verbose = TRUE)
Methodfit_lasso()
Usage
lslx$fit_lasso(lambda_grid = "default", ...)
Methodfit_ridge()
Usage
lslx$fit_ridge(lambda_grid = "default", ...)
Methodfit_elastic_net()
Usage
lslx$fit_elastic_net(lambda_grid = "default", delta_grid = "default", ...)
Methodfit_mcp()
Usage
lslx$fit_mcp(lambda_grid = "default", delta_grid = "default", ...)
Methodfit_forward()
Usage
lslx$fit_forward(step_grid = "default", ...)
Methodfit_backward()
Usage
lslx$fit_backward(step_grid = "default", ...)
Methodfit_none()
Usage
lslx$fit_none(...)
Methodget_model()
Usage
lslx$get_model()
Methodget_data()
Usage
lslx$get_data()
Methodget_fitting()
Usage
lslx$get_fitting()
Methodplot_numerical_condition()
Usage
lslx$plot_numerical_condition( condition, x_scale = "default", x_reverse = "default", mode = "default")
Methodplot_information_criterion()
Usage
lslx$plot_information_criterion( criterion, x_scale = "default", x_reverse = "default", mode = "default")
Methodplot_fit_index()
Usage
lslx$plot_fit_index( index, x_scale = "default", x_reverse = "default", mode = "default")
Methodplot_coefficient()
Usage
lslx$plot_coefficient( block, left, right, both, x_scale = "default", x_reverse = "default", mode = "default")
Methodprint()
Usage
lslx$print()
Methodfree_block()
Usage
lslx$free_block(block, group, type, verbose = TRUE)
Methodfix_block()
Usage
lslx$fix_block(block, group, type, verbose = TRUE)
Methodpenalize_block()
Usage
lslx$penalize_block(block, group, penalty, set, type, verbose = TRUE)
Methodfree_coefficient()
Usage
lslx$free_coefficient(name, start, verbose = TRUE)
Methodfix_coefficient()
Usage
lslx$fix_coefficient(name, start, verbose = TRUE)
Methodpenalize_coefficient()
Usage
lslx$penalize_coefficient(name, start, penalty, set, weight, verbose = TRUE)
Methodset_coefficient_type()
Usage
lslx$set_coefficient_type(name, type)
Methodset_coefficient_start()
Usage
lslx$set_coefficient_start(name, start)
Methodset_data()
Usage
lslx$set_data(data, sample_cov, sample_mean, sample_size, sample_moment_acov)
Methodfree_directed()
Usage
lslx$free_directed(left, right, group, verbose = TRUE)
Methodfix_directed()
Usage
lslx$fix_directed(left, right, group, verbose = TRUE)
Methodpenalize_directed()
Usage
lslx$penalize_directed(left, right, group, penalty, set, verbose = TRUE)
Methodfree_heterogeneity()
Usage
lslx$free_heterogeneity(block, group, hold_fixed = TRUE, verbose = TRUE)
Methodfix_heterogeneity()
Usage
lslx$fix_heterogeneity(block, group, hold_fixed = TRUE, verbose = TRUE)
Methodpenalize_heterogeneity()
Usage
lslx$penalize_heterogeneity( block, group, penalty, set, hold_fixed = TRUE, verbose = TRUE)
Methodfree_undirected()
Usage
lslx$free_undirected(both, group, verbose = TRUE)
Methodfix_undirected()
Usage
lslx$fix_undirected(both, group, verbose = TRUE)
Methodpenalize_undirected()
Usage
lslx$penalize_undirected(both, group, penalty, set, verbose = TRUE)
Methodsummarize()
Usage
lslx$summarize( selector, lambda, delta, step, standard_error = "default", ridge_penalty = "default", debias = "default", inference = "default", alpha_level = 0.05, include_faulty = FALSE, style = "default", mode = "default", interval = TRUE, digit = 3L, output = list(general_information = TRUE, fitting_information = FALSE, saturated_model_information = FALSE, baseline_model_information = FALSE, numerical_condition = TRUE, information_criterion = FALSE, fit_index = TRUE, cv_error = TRUE, lr_test = TRUE, rmsea_test = TRUE, coefficient_test = TRUE))
Methodtest_lr()
Usage
lslx$test_lr(selector, lambda, delta, step, include_faulty = FALSE)
Methodtest_rmsea()
Usage
lslx$test_rmsea( selector, lambda, delta, step, alpha_level = 0.05, include_faulty = FALSE)
Methodtest_coefficient()
Usage
lslx$test_coefficient( selector, lambda, delta, step, standard_error = "default", ridge_penalty = "default", debias = "default", inference = "default", alpha_level = 0.05, include_faulty = FALSE)
Methodvalidate()
Usage
lslx$validate( selector, lambda, delta, data, subset = NULL, do_fit = "default", standard_error = "default", alpha_level = 0.05, include_faulty = FALSE, style = "default", mode = "default", interval = TRUE, digit = 3L)
Methodclone()
The objects of this class are cloneable with this method.
Usage
lslx$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
References
Akaike, H. (1974). A new look at the statistical model identification. IEEE Transactionson Automatic Control, 19(6), 716–723.
Bates, D., & Eddelbuettel, D. (2013). Fast and Elegant Numerical Linear Algebra Using the RcppEigen Package. Journal of Statistical Software, 52(5), 1–24.
Bentler, P. M. (1995). EQS structural equations program manual. Encino, CA: Multivariate Software.
Bentler, P. (1990). Comparative fit indices in structural models. Psychological Bulletin, 107(2), 238–246.
Berk, R., Brown, L., Buja, A., Zhang, K., & Zhao, L. (2013). Valid postselection inference. The Annals of Statistics, 41(2), 802–837.
Bozdogan, H. (1987). Model selection and Akaike’s Information Criterion (AIC): The general theory and its analytical extensions. Psychometrika, 52(3), 345–370.
Browne, M. W. (1984). Asymptotic distribution-free methods for the analysis of covariance structures. British Journal of Mathematical and Statistical Psychology, 37(1), 62–83.
Chang, W. (2017). R6: Classes with Reference Semantics.
Eddelbuettel, D., & François, R. (2011). Rcpp: Seamless R and C++ Integration. Journal of Statistical Software, 40(8), 1–18.
Friedman, J., Hastie, T., & Tibshirani, R. (2010). Regularization Paths for Generalized Linear Models via Coordinate Descent. Journal of Statistical Software, 33(1), 1–22.
Haughton, D. M. A., Oud, J. H. L., & Jansen, R. A. R. G. (1997). Information and other criteria in structural equation model selection. Communications in Statistics - Simulation and Computation, 26(4), 1477–1516.
Hoerl, A. E., & Kennard, R. W. (1970). Ridge Regression: Biased Estimation for Nonorthogonal Problems. Technometrics, 12(1), 55–67.
Huang, P. H. (2018). A Penalized Likelihood Method for Multi-Group Structural Equation Modeling. British Journal of Mathematical and Statistical Psychology, 71(3), 499-522.
Huang, P. H. (2020). lslx: Semi-Confirmatory Structural Equation Modeling via Penalized Likelihood. Journal of Statistical Software. 93(7), 1-37.
Huang, P. H. (in press). Post-selection inference in Structural Equation Modeling. Multivariate Behavioral Research.
Huang, P. H., Chen, H., & Weng, L. J. (2017). A Penalized Likelihood Method for Structural Equation Modeling. Psychometrika, 82(2), 329–354.
Brosseau-Liard, P. E., Savalei, V., & Li, L. (2012). An Investigation of the Sample Performance of Two Nonnormality Corrections for RMSEA. Multivariate Behavioral Research, 47(6), 904-930.
Lee, J. D., Sun, D. L., Sun, Y., & Taylor, J. E. (2016). Exact postselection inference, with application to the lasso. The Annals of Statistics, 44(3), 907–927.
Li, L., & Bentler, P. M. (2006). Robust statistical tests for evaluating the hypothesis of close fit of misspecified mean and covariance structural models.UCLA Statistics Preprint #506. Los Angeles: University of California.
Mazumder, R., Friedman, J. H., & Hastie, T. (2011). SparseNet: Coordinate Descent With Nonconvex Penalties. Journal of the American Statistical Association, 106(495), 1125–1138.
McDonald, R. P., & Hartmann, W. M. (1992). A procedure for obtaining initial values of parameters in the RAM model. Multivariate Behavioral Research, 27(1), 57–76.
Pötscher, B. M. (1991). Effects of model selection on inference. Econometric Theory, 7(2), 163-185.
Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1–36.
Rubin, D. B. (1976). Inference and Missing Data. Biometrika, 63(3), 581–592.
Satorra, A., & Bentler, P. M. (1994). Corrections to test statistics and standard errors in covariance structure analysis.In A. von Eye & C. C. Clogg (Eds.), Latent variable analysis: Applications to developmental research (pp. 399–419). Thousand Oaks, CA: Sage.
Savalei, V. & Falk, C. F. (2014). Robust two-stage approach outperforms robust full information maximum likelihood with incomplete nonnormal data. Structural Equation Modeling: A Multidisciplinary Journal, 21(2), 280-302.
Savalei, V. & Bentler, P. M. (2009). A Two-Stage Approach to Missing Data: Theory and Application to Auxiliary Variables, Structural Equation Modeling: A Multidisciplinary Journal, 16(3), 477-497.
Schwarz, G. (1978). Estimating the dimension of a model. The Annals of Statistics, 6(2), 461–464.
Sclove, S. L. (1987). Application of model-selection criteria to some problems in multivariate analysis. Psychometrika, 52(3), 333–343.
Steiger, J. H. (1998). A Note on Multiple Sample Extensions of the RMSEA Fit Index. Structural Equation Modeling-a Multidisciplinary Journal, 5(4), 411–419.
Steiger, J. H., & Lind, J. C. (1980). Statistically-based tests for the number of common factors. In Paper presented at the annual meeting of the Psychometric Society.
Tibshirani, R. (1996). Regression Selection and Shrinkage via the Lasso. Journal of the Royal Statistical Society B, 58(1), 267–288.
Tucker, L. R., & Lewis, C. (1973). A reliability coefficient for maximum likelihood factor analysis. Psychometrika, 38(1), 1–10.
Yuan, K.-H., & Bentler, P. M. (2000). Three likelihood-based methods for mean and covariance structure analysis with nonnormal missing data. Sociological Methodology, 30(1), 165–200.
Yuan, K. H., & Hayashi, K. (2006). Standard errors in covariance structure models: Asymptotics versus bootstrap. British Journal of Mathematical and Statistical Psychology, 59(2), 397–417.
Yuan, K.-H., & Lu, L. (2008). SEM with missing data and unknown population distributions using two-stage ML: Theory and its application. Multivariate Behavioral Research, 43(4), 621–652.
Yuan, G. X., Ho, C. H., & Lin, C. J. (2012). An Improved GLMNET for L1-regularized Logistic Regression. Journal of Machine Learning Research, 13(1), 1999–2030.
Zhang, C. H. (2010). Nearly unbiased variable selection under minimax concave penalty. Annals of Statistics, 38(2), 894–942.
Zou, H., & Hastie, T. (2005). Regularization and Variable Selection via the Elastic Net. Journal of the Royal Statistical Society B, 67(2), 301–320.
Examples
## EXAMPLE: Regression Analysis with Lasso Penalty ### run `vignette("regression-analysis")` to see the vignette# generate data for regression analysisset.seed(9487)x <- matrix(rnorm(2000), 200, 10)colnames(x) <- paste0("x", 1:10)y <- matrix(rnorm(200), 200, 1)data_reg <- data.frame(y, x)# specify regression model with penalized coefficientsmodel_reg <- "y <= x1 + x2 + x3 + x4 y <~ x5 + x6 + x7 + x8 + x9 + x10"# initialize lslx object via specified model and raw datalslx_reg <- lslx$new(model = model_reg, data = data_reg)# fit specified model to data with lasso under specified penalty levelslslx_reg$fit(penalty_method = "lasso", lambda_grid = seq(.00, .30, .02))# summarize fitting result under penalty level selected by 'aic'lslx_reg$summarize(selector = "aic")## EXAMPLE: Semi-Confirmatory Factor Analysis ### run `vignette("factor-analysis")` to see the vignette# specify semi-confirmatory factor analysis modelmodel_fa <- "visual :=> x1 + x2 + x3 textual :=> x4 + x5 + x6 speed :=> x7 + x8 + x9 visual :~> x4 + x5 + x6 + x7 + x8 + x9 textual :~> x1 + x2 + x3 + x7 + x8 + x9 speed :~> x1 + x2 + x3 + x4 + x5 + x6 visual <=> 1 * visual textual <=> 1 * textual speed <=> 1 * speed" # initialize lslx object via specified model and raw datalslx_fa <- lslx$new(model = model_fa, data = lavaan::HolzingerSwineford1939) # fit with mcp under specified penalty levels and convexity levelslslx_fa$fit(penalty_method = "mcp", lambda_grid = seq(.02, .60, .02), delta_grid = c(1.5, 3.0, Inf))# summarize fitting result under penalty level selected by 'bic'lslx_fa$summarize(selector = "bic")## EXAMPLE: Semi-Confirmatory Structural Equation Modeling ### run `vignette("structural-equation-modeling")` to see the vignette# specify structural equation modeling modelmodel_sem <- "fix(1) * x1 + x2 + x3 <=: ind60 fix(1) * y1 + y2 + y3 + y4 <=: dem60 fix(1) * y5 + y6 + y7 + y8 <=: dem65 dem60 <= ind60 dem65 <= ind60 + dem60"# initialize lslx object via specified model and sample momentslslx_sem <- lslx$new(model = model_sem, sample_cov = cov(lavaan::PoliticalDemocracy), sample_size = nrow(lavaan::PoliticalDemocracy))# set some covariances of errors as penalized lslx_sem$penalize_coefficient(name = c("y1<->y5", "y2<->y4", "y2<->y6", "y3<->y7", "y4<->y8", "y6<->y8"))# fit with lasso under default penalty levelslslx_sem$fit_lasso(lambda_length = 25)# summarize fitting result under penalty level selected by 'abic'lslx_sem$summarize(selector = "abic")## EXAMPLE: Factor Analysis with Missing Data ### run `vignette("missing-data-analysis")` to see the vignette# create missing values for x5 and x9 by the code in package semToolsdata_miss <- lavaan::HolzingerSwineford1939data_miss$x5 <- ifelse(data_miss$x1 <= quantile(data_miss$x1, .3), NA, data_miss$x5)data_miss$age <- data_miss$ageyr + data_miss$agemo/12data_miss$x9 <- ifelse(data_miss$age <= quantile(data_miss$age, .3), NA, data_miss$x9)# specify confirmatory factor analysis modelmodel_miss <- "visual :=> x1 + x2 + x3 textual :=> x4 + x5 + x6 speed :=> x7 + x8 + x9 visual <=> 1 * visual textual <=> 1 * textual speed <=> 1 * speed"# "ageyr" and "agemo" are set as auxiliary variableslslx_miss <- lslx$new(model = model_miss, data = data_miss, auxiliary_variable = c("ageyr", "agemo")) # penalize all covariances among residualslslx_miss$penalize_block(block = "y<->y", type = "fixed", verbose = FALSE)# fit with lasso under default penalty levelslslx_miss$fit_lasso(lambda_length = 25)# summarize fitting result under penalty level selected by 'raic'lslx_miss$summarize(selector = "raic")## EXAMPLE: Multi-Group Factor Analysis ### run `vignette("multi-group-analysis")` to see the vignette# specify multi-group factor analysis modelmodel_mgfa <- "visual :=> 1 * x1 + x2 + x3 textual :=> 1 * x4 + x5 + x6 speed :=> 1 * x7 + x8 + x9"# "school" is set as group variable and "Pasteur" is specified as referencelslx_mgfa <- lslx$new(model = model_mgfa, data = lavaan::HolzingerSwineford1939, group_variable = "school", reference_group = "Pasteur")# penalize increment components of loadings and intercepts in 'Grant-White'lslx_mgfa$penalize_heterogeneity(block = c("y<-1", "y<-f"), group = "Grant-White")# free increment components of means of latent factors in 'Grant-White'lslx_mgfa$free_block(block = "f<-1", group = "Grant-White") # fit with mcp under default penalty levels and specified convexity levelslslx_mgfa$fit_mcp(lambda_length = 25)# summarize fitting result under penalty level selected by 'hbic'lslx_mgfa$summarize(selector = "hbic")S3 interface for semi-confirmatory SEM via PL
Description
plsem() is anS3 interface for obaining a fittedlslx object.
Usage
plsem( model, data, penalty_method = "mcp", lambda_grid = "default", delta_grid = "default", numeric_variable, ordered_variable, weight_variable, auxiliary_variable, group_variable, reference_group, sample_cov, sample_mean, sample_size, sample_moment_acov, verbose = TRUE, ...)Arguments
model | A |
data | A |
penalty_method | A |
lambda_grid | A non-negative |
delta_grid | A non-negative |
numeric_variable | A |
ordered_variable | A |
weight_variable | A |
auxiliary_variable | A |
group_variable | A |
reference_group | A |
sample_cov | A numeric |
sample_mean | A |
sample_size | A |
sample_moment_acov | A numeric |
verbose | A |
... | Other arguments. For details, please see the documentation of |
Value
A fittedlslx object
Examples
## EXAMPLE: Semi-Confirmatory Factor Analysis with lavaan Style ### specify a factor analysis model with lavaan stylemodel_fa <- "visual =~ x1 + x2 + x3 textual =~ x4 + x5 + x6 speed =~ x7 + x8 + x9 pen() * visual =~ x4 + x5 + x6 + x7 + x8 + x9 pen() * textual =~ x1 + x2 + x3 + x7 + x8 + x9 pen() * speed =~ x1 + x2 + x3 + x4 + x5 + x6 visual ~~ 1 * visual textual ~~ 1 * textual speed ~~ 1 * speed" # fit with mcp under specified penalty levels and convexity levelslslx_fa <- plsem(model = model_fa, data = lavaan::HolzingerSwineford1939, penalty_method = "mcp", lambda_grid = seq(.02, .60, .02), delta_grid = c(1.5, 3.0, Inf))# summarize fitting result under the penalty level selected by 'bic'summary(lslx_fa, selector = "bic")R6 class to obtain preliminary result for semi-confirmatory structural equation modeling
Description
R6 class to obtain preliminary result for semi-confirmatory structural equation modeling
R6 class to obtain preliminary result for semi-confirmatory structural equation modeling
Value
Object ofprelslx R6 class.
Methods
Public methods
Methodnew()
Usage
prelslx$new( model, data, numeric_variable, ordered_variable, weight_variable, auxiliary_variable, group_variable, reference_group, sample_cov, sample_mean, sample_size, sample_moment_acov, verbose = TRUE)
Methodprefit()
Usage
prelslx$prefit( penalty_method = "mcp", lambda_grid = "default", delta_grid = "default", step_grid = "default", loss = "default", algorithm = "default", missing_method = "default", start_method = "default", lambda_direction = "default", lambda_length = 50L, delta_length = 3L, threshold_value = 0.3, subset = NULL, cv_fold = 1L, iter_out_max = 100L, iter_in_max = 50L, iter_other_max = 500L, iter_armijo_max = 100L, tol_out = 0.001, tol_in = 0.001, tol_other = 1e-07, step_size = 0.5, momentum = 0, armijo = 1e-05, ridge_cov = 0, ridge_hessian = 1e-04, ridge_weight = 1e-04, warm_start = TRUE, positive_variance = TRUE, minimum_variance = 1e-04, armijo_rule = TRUE, enforce_cd = TRUE, random_update = TRUE, weight_matrix = NULL, verbose = TRUE)
Methodclone()
The objects of this class are cloneable with this method.
Usage
prelslx$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
S3 method to extract residual moments fromlslx
Description
residuals.lslx() is anS3 interface for extracting residuals from alslx object.
Usage
## S3 method for class 'lslx'residuals(object, selector, lambda, delta, ...)Arguments
object | A fitted |
selector | A |
lambda | A |
delta | A |
... | Other arguments. For details, please see the |
S3 method to summarizelslx fitting results
Description
summary.lslx() is anS3 interface for summarizinglslx fitting results.
Usage
## S3 method for class 'lslx'summary(object, selector, lambda, delta, ...)Arguments
object | A fitted |
selector | A |
lambda | A |
delta | A |
... | Other arguments. For details, please see the |
S3 method to extract covariance matrix of estimates fromlslx
Description
vcov.lslx() is anS3 interface for extracting covariance matrix of parameter estimate from alslx object.
Usage
## S3 method for class 'lslx'vcov(object, selector, lambda, delta, ...)Arguments
object | A fitted |
selector | A |
lambda | A |
delta | A |
... | Other arguments. For details, please see the |