path_model: Performs Latent Variable estimation given data and path model...

Description Usage Arguments Value

View source: R/path_model.R

Description

Performs Latent Variable estimation given data and path model specifications

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
path_model(
  data,
  connection_matrix,
  variables_in_block,
  block_names = NULL,
  estimators = NULL,
  start_node_estimator = "normalpls",
  middle_node_estimator = "normalpls",
  end_node_estimator = "endpls",
  initializers = NULL,
  start_node_initializer = "Full",
  middle_node_initializer = "Full",
  end_node_initializer = "Full",
  max_iterations = 100,
  loggers = NULL,
  unique_node_preprocessing = FALSE,
  global_preprocessors = list(),
  local_preprocessors = list(standardize),
  convergence_threshold = 1e-04,
  node_class_types = NULL,
  parallelise = FALSE,
  n_cores = NULL
)

Arguments

data

A dataframe or matrix containing the data belonging to the process that is being modelled. The rows contain the samples, the columns contain the variables.

connection_matrix

A lower triangular matrix where the non zero elements what connections exist. The rows indicate the node where the edge is going to, and the columns indicates the node where the edge is coming from.

variables_in_block

A list of lists indicating the variables corresponding to each block. The ordering of the upper list should be the same as that of the connection_matrix. The inner list values can be integers indicating the column number, or the name when column names are set in data.

block_names

An ordered list containing the names that should be assigned to each block. The ordering of the list should be the same as that of the connection_matrix. When the argument is not set, names are extracted from data, or set to dummy names based on ordering when data contains no names.

estimators

A list of functions indicating which estimator should be used for which node. The ordering of the list should be the same as that of the connection_matrix. It is advised to only use this option when you want different estimators within a level of estimation (Start, Middle, End). All estimators must implement a common interface, taking only a R6Class Node object as input, and returning nothing. Instead, this function should update the node directly.

start_node_estimator

An estimator function which estimates a R6Class Node object, or a string indicating the estimation method ("none") meant for estimation of a start type Node. All estimators must implement a common interface, taking only a R6Class Node object as input, and returning nothing. Instead, this function should update the node directly.

middle_node_estimator

An estimator function which estimates a R6Class Node object, or a string indicating the estimation method ("none") meant for estimation of a middle type Node. All estimators must implement a common interface, taking only a R6Class Node object as input, and returning nothing. Instead, this function should update the node directly.

end_node_estimator

An estimator function which estimates a R6Class Node object, or a string indicating the estimation method ("none") meant for estimation of an end type Node. All estimators must implement a common interface, taking only a R6Class Node object as input, and returning nothing. Instead, this function should update the node directly.

initializers

A list of functions indicating which initializer should be used for which node. The ordering of the list should be the same as that of the connection_matrix. It is advised to only use this option when you want different initializers within a level of nodes (Start, Middle, End). All initializers must implement a common interface, taking only a R6Class Node object as input, and returning nothing. Instead, this function should update the node directly. When set explicitly, the node_class_types argument -must- be set.

start_node_initializer

An initializer function which estimates a R6Class Node object, or a string indicating the estimation method ("normalpls", "endpls", "pca", or "none") meant for initializing a start type Node. All initializers must implement a common interface, taking only a R6Class Node object as input, and returning nothing. Instead, this function should update the node directly.

middle_node_initializer

An initializer function which estimates a R6Class Node object, or a string indicating the estimation method ("normalpls", "endpls", "pca", or "none") meant for initializing a middle type Node. All initializers must implement a common interface, taking only a R6Class Node object as input, and returning nothing. Instead, this function should update the node directly.

end_node_initializer

An initializer function which estimates a R6Class Node object, or a string indicating the estimation method ("normalpls", "endpls", "pca", or "none") meant for initializing an end type Node. All initializers must implement a common interface, taking only a R6Class Node object as input, and returning nothing. Instead, this function should update the node directly.

max_iterations

An integer indicating the maximum number of iterations before execution of LV estimation is halted when the convergence criterion is not met beforehand.

loggers

A listenv of R6Class based logger and/or reporter objects. All loggers or reports must implement a log_status() method. Implemented loggers or reporters are ComponentLogger, IterationReporter, DurationLogger, and ConvergenceLogger.

unique_node_preprocessing

A Boolean indicating whether different nodes should be preprocesed differently. If TRUE, the global_preprocessors and local_preprocessors lists should be entered as a list of list of preprocessing functions.

global_preprocessors

A list of preprocessing functions when unique_node_preprocessing is FALSE, a list of lists of preprocessing functions when unique_node_preprocessing is TRUE. The ordering of the outer list should be the same as that of the connection_matrix. The order of the inner list is only important when the function results differ when their order of application is changed. The funtions will be applied from beginning to end. The supplied function must be invariant to subsampling. User-implemented functions must take a Matrix as input, and return the preprocessed matrix.

local_preprocessors

A list of preprocessing functions when unique_node_preprocessing is FALSE, a list of lists of preprocessing functions when unique_node_preprocessing is TRUE. The ordering of the outer list should be the same as that of the connection_matrix. The order of the inner list is only important when the function results differ when their order of application is changed. The funtions will be applied from beginning to end. The supplied function is assumed to be influenced by subsampling, and therefore can be applied on subsets when (cross-)validating. User-implemented functions must take a Matrix as input, and return the preprocessed matrix. Implemented functions are: (block_scale, standardize, and mean_center)

convergence_threshold

A double indicating the maximum error before the iterations are assumed to have converged. It is compared to the difference between the latent variables of the current and previous iteration. If this difference is less, the algorithm is considered to have converged. A convergence threshold of a difference of 0.0001 between the Sum of Squared Errors of two subsequent iterations is used as a default.

node_class_types

A listenv of R6Class Node classes, or R6Classes which inherit the Node class. This option should only be set when the estimators argument is provided and other Node types are needed, or when custom path_modeling methods require new Node inheriting types.

Value

A listenv of connected, initialized, and estimated nodes


GeertPostma/pathmodelr documentation built on Oct. 5, 2021, 4:17 p.m.