Learn R Programming

lvnet (version 0.3.5)

lvnetSearch: Step-wise exploratory search for optimal fitting model

Description

Performs stepwise search to optimize the structure of omega_theta, omega_psi, theta or psi. Starts at empty or full structure and iteratively adds or removes edges to optimize the criterion.

Usage

lvnetSearch(data, matrix = c("omega_theta", "omega_psi", "theta", "psi"), 
          criterion = c("bic", "ebic","chisq","aic"), 
          start =  c("default","empty","full"),  alpha = 0.05, lambda, sampleSize, 
          maxIter,  nCores = 1, maxChange = 1, ...,  verbose = TRUE, file, 
          startValues = list())

Arguments

data

The data argument as used in lvnet

matrix

Character string indicating the matrix to be optimized. Can be "omega_theta", "omega_psi", "theta" and "psi".

criterion

Character string indicating the criterion to be used. "AIC" and "BIC" optimize the AIC or BIC respectively, and "chisq" performs chi-square tests to see if adding an edge significantly improves model fit or removing an edges does not significantly reduce model fit.

start

A character string indicating the structure of the matrix at the start of the algorithm. "empty" starts with a matrix with only zeroes and "full" starts with a matrix in which all elements are free to estimate. "lvglasso" employs the lvglasso algorithm (EBIClvglasso to find a starting structure for omega_theta and "glasso" employs the glasso algorithm to find a starting point for omega_psi (EBICglasso). "default" will lead to a full matrix if omega_psi or psi is optimized, and an empty matrix if omega_theta or theta is optimized.

alpha

The alpha level for chi-square significance testing.

lambda

The lambda argument as used in lvnet

sampleSize

The sample size, only used if data is a covariance matrix.

maxIter

The maximum number of edges to test. Defaults to M(M-1)/2

nCores

Number of cores to use in parallel estimation.

maxChange

Set to higher than one to change multiple edges in each run. Each iteration, maxChange is reset to max(number of changed edges - 1, 1). Can result in instable results when searching "omega_theta".

Arguments sent to lvnet

verbose

Logical if progress should be printed to the consile.

file

An optional character string containing a file name to store temporary results in.

startValues

A list containing start values as used in lvnet

Value

An object of class lvnetSearch, which is a list containing:

best

The lvnet object of the best fitting model

modList

A list containing the chain of fitted models

niter

The number of iterations used

See Also

lvnet

Examples

Run this code
# NOT RUN {
# Load dataset:
library("lavaan")
data(HolzingerSwineford1939)
Data <- HolzingerSwineford1939[,7:15]

# Measurement model:
Lambda <- matrix(0, 9, 3)
Lambda[1:3,1] <- NA
Lambda[4:6,2] <- NA
Lambda[7:9,3] <- NA

# Search best fitting omega_psi:
# }
# NOT RUN {
res <- lvnetSearch(Data, "omega_psi", lambda = Lambda)
res$best
# }

Run the code above in your browser using DataLab