Validates that input data meets the requirements for SignalY analysis. Performs comprehensive checks on data types, dimensions, missing values, and numeric properties.
validate_input(
y,
X = NULL,
time_index = NULL,
na_action = c("fail", "omit", "interpolate"),
min_obs = 10,
verbose = FALSE
)A list with validated and potentially transformed data:
Validated numeric vector of target signal
Validated matrix of predictors (or NULL)
Vector of time indices
Number of observations
Number of predictor variables (or 0)
Names of predictor variables (or NULL)
Indices of removed observations (if any)
Numeric vector representing the target signal. Must be a numeric
vector with no infinite values. Missing values (NA) are handled according
to the na_action parameter.
Optional matrix or data frame of candidate predictors. If provided, must have the same number of rows as length(y).
Optional vector of time indices. If NULL, sequential integers will be used.
Character string specifying how to handle missing values. Options are "fail" (stop with error), "omit" (remove observations with NA), or "interpolate" (linear interpolation).
Minimum number of observations required. Default is 10.
Logical indicating whether to print diagnostic messages.
This function implements defensive programming principles to ensure data integrity before computationally intensive analyses. The validation process includes:
Type checking: Ensures y is numeric and X (if provided) is numeric matrix/data.frame
Dimension checking: Verifies compatible dimensions between y and X
Missing value handling: Processes NA values according to specified action
Finiteness checking: Removes or flags infinite values
Minimum sample size: Ensures sufficient observations for analysis