View source: R/penalised_models.R
PenalisedOpenMx | R Documentation |
Runs penalised Structural Equation Modelling using implementations from
OpenMx
functions (for PenalisedOpenMx
),
or using series of penalised regressions with glmnet
(for PenalisedLinearSystem
). The function
PenalisedLinearSystem
does not accommodate latent variables.
These functions are not using stability.
PenalisedOpenMx(
xdata,
adjacency,
penalised = NULL,
residual_covariance = NULL,
Lambda,
...
)
PenalisedLinearSystem(xdata, adjacency, penalised = NULL, Lambda = NULL, ...)
xdata |
matrix with observations as rows and variables as columns.
Column names must be defined and in line with the row and column names of
|
adjacency |
binary adjacency matrix of the Directed Acyclic Graph (transpose of the asymmetric matrix A in Reticular Action Model notation). The row and column names of this matrix must be defined. |
penalised |
optional binary matrix indicating which coefficients are regularised. |
residual_covariance |
binary and symmetric matrix encoding the nonzero entries in the residual covariance matrix (symmetric matrix S in Reticular Action Model notation). By default, this is the identity matrix (no residual covariance). |
Lambda |
matrix of parameters controlling the level of sparsity. Only
the minimum, maximum and length are used in |
... |
additional parameters passed to |
A list with:
selected |
matrix of binary selection status. Rows correspond to different regularisation parameters. Columns correspond to different parameters to estimated. |
beta_full |
matrix of model coefficients. Rows correspond to different regularisation parameters. Columns correspond to different parameters to estimated. |
RegSEMsharp
SelectionAlgo
, VariableSelection
,
OpenMxMatrix
,
LinearSystemMatrix
Other underlying algorithm functions:
CART()
,
ClusteringAlgo()
,
PenalisedGraphical()
,
PenalisedRegression()
# Data simulation
pk <- c(3, 2, 3)
dag <- LayeredDAG(layers = pk)
theta <- dag
theta[2, 4] <- 0
set.seed(1)
simul <- SimulateStructural(theta = theta, pk = pk, output_matrices = TRUE)
# Running regularised SEM (OpenMx)
if (requireNamespace("OpenMx", quietly = TRUE)) {
mysem <- PenalisedOpenMx(
xdata = simul$data, adjacency = dag,
Lambda = seq(1, 10, 1)
)
OpenMxMatrix(vect = mysem$selected[3, ], adjacency = dag)
}
# Running regularised SEM (glmnet)
mysem <- PenalisedLinearSystem(
xdata = simul$data, adjacency = dag
)
LinearSystemMatrix(vect = mysem$selected[20, ], adjacency = dag)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.