| Title: | N-LCS: Normative Latent Cognitive Structure |
|---|---|
| Description: | Provides functions to construct a normative latent cognitive structure (N-LCS) from cognitive test data standardized to healthy controls, and to compute cognitive deviation magnitude (CDM) and cognitive deviation angle (CDA). Methods are described in Chen (2026) <doi:10.1080/23279095.2026.2691088>. |
| Authors: | Chen Chen [aut, cre] |
| Maintainer: | Chen Chen <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0 |
| Built: | 2026-09-22 00:23:45 UTC |
| Source: | https://github.com/cran/nlcs |
Computes cognitive deviation magnitude (CDM) and cognitive deviation angle (CDA) relative to a fitted healthy-control reference model.
compute_nlcs_metrics(nlcs_result, data_z, ids = NULL)compute_nlcs_metrics(nlcs_result, data_z, ids = NULL)
nlcs_result |
An object of class |
data_z |
A complete, finite numeric matrix or data frame standardized using the same healthy-control reference as the model. Rows are subjects. Columns must have the model's test names and are reordered to model order. |
ids |
An optional vector of subject identifiers, with
one identifier per row of |
A data.frame with one row per input subject, in input
row order, containing:
Subject identifiers, included only when
ids is supplied.
A numeric cognitive deviation measure.
When CDM_type is "axis_projection", this is
the signed projection of the healthy-control-centered,
whitened score vector onto the fitted unit axis. Its sign
follows the orientation of the fitted loadings.
When CDM_type is "whitened_magnitude", it is
the nonnegative Euclidean length of that vector,
representing distance from the healthy-control center in
healthy-control covariance-standardized coordinates.
The numeric angle in degrees, between 0 and
180, from the whitened score vector to the fitted axis.
Smaller angles indicate closer directional alignment.
The angle is NA when the whitened score vector
has zero length.
Numeric CDA_raw minus the median raw
healthy-control angle stored in the model. Positive values
indicate angles above the healthy-control median; negative
values indicate angles below it. Undefined raw angles
remain NA.
A character column containing
"axis_projection" or "whitened_magnitude",
as determined by the model.
set.seed(42) ability <- rnorm(100) hc <- sapply(seq_len(4), function(j) { ability + rnorm(100, sd = 0.4) }) colnames(hc) <- paste0("test", seq_len(4)) new <- hc[1:3, , drop = FALSE] - 0.5 std <- standardize_normative(hc, new) # Few iterations keep the example fast; use the default for analysis. model <- fit_nlcs(std$hc_z, parallel_iter = 10L) scores <- compute_nlcs_metrics( model, std$new_z, ids = c("A", "B", "C") ) scoresset.seed(42) ability <- rnorm(100) hc <- sapply(seq_len(4), function(j) { ability + rnorm(100, sd = 0.4) }) colnames(hc) <- paste0("test", seq_len(4)) new <- hc[1:3, , drop = FALSE] - 0.5 std <- standardize_normative(hc, new) # Few iterations keep the example fast; use the default for analysis. model <- fit_nlcs(std$hc_z, parallel_iter = 10L) scores <- compute_nlcs_metrics( model, std$new_z, ids = c("A", "B", "C") ) scores
Fits a one-factor normative latent cognitive structure (N-LCS) when both parallel analysis and the original MAP procedure recommend one factor.
fit_nlcs(hc_z, parallel_iter = 1000L, loading_tolerance = 1e-8)fit_nlcs(hc_z, parallel_iter = 1000L, loading_tolerance = 1e-8)
hc_z |
A complete, finite numeric matrix or data frame of
healthy-control scores standardized using
|
parallel_iter |
Number of parallel-analysis iterations. |
loading_tolerance |
Absolute loading threshold below which loadings are treated as zero when selecting the cognitive deviation magnitude (CDM) definition. |
Parallel analysis uses random simulations. Use set.seed()
for reproducibility. Factor-retention recommendations are
reported as messages.
A named list of class nlcs_result containing:
A character vector of test names in model order.
A named numeric vector of healthy-control means in standardized units.
The numeric healthy-control sample covariance matrix.
The numeric symmetric inverse square root of the healthy-control covariance matrix. This transforms centered scores into healthy-control covariance-standardized coordinates.
The one-factor fit returned by psych::fa(),
with classes psych and fa.
A named numeric vector of one-factor loadings.
A named numeric unit vector defining the fitted latent axis in whitened space. Its orientation follows the fitted loadings.
The full parallel-analysis result from
psych::fa.parallel(), with classes psych and
parallel.
The full MAP result from
EFAtools::N_FACTORS(), with classes efa_retain
and N_FACTORS.
A list containing integer factor counts
parallel_analysis and map_tr2. Both equal one
in a successfully returned model.
The numeric loading threshold used to classify loading signs.
A character string:
"axis_projection" when all nonzero loadings have the
same sign, or "whitened_magnitude" when they have
mixed signs.
The numeric median raw healthy-control cognitive deviation angle in degrees, excluding undefined angles. This is subtracted when computing adjusted CDA.
The model defines the healthy-control reference geometry used by
compute_nlcs_metrics. An error is raised if either
retention procedure does not recommend one factor.
set.seed(42) ability <- rnorm(100) hc <- sapply(seq_len(4), function(j) { ability + rnorm(100, sd = 0.4) }) colnames(hc) <- paste0("test", seq_len(4)) std <- standardize_normative(hc) # Few iterations keep the example fast; use the default for analysis. model <- fit_nlcs(std$hc_z, parallel_iter = 10L) model$loadings model$retentionset.seed(42) ability <- rnorm(100) hc <- sapply(seq_len(4), function(j) { ability + rnorm(100, sd = 0.4) }) colnames(hc) <- paste0("test", seq_len(4)) std <- standardize_normative(hc) # Few iterations keep the example fast; use the default for analysis. model <- fit_nlcs(std$hc_z, parallel_iter = 10L) model$loadings model$retention
Prints the number of cognitive tests, factor-retention results, and the cognitive deviation magnitude (CDM) definition.
## S3 method for class 'nlcs_result' print(x, ...)## S3 method for class 'nlcs_result' print(x, ...)
x |
An object of class |
... |
Additional arguments, currently unused. |
The input x, a named list of class nlcs_result,
returned invisibly and unchanged. Its components describe the fitted
healthy-control reference model and are documented in
fit_nlcs.
The function is called for the side effect of printing a concise model summary to the console.
set.seed(42) ability <- rnorm(100) hc <- sapply(seq_len(4), function(j) { ability + rnorm(100, sd = 0.4) }) colnames(hc) <- paste0("test", seq_len(4)) std <- standardize_normative(hc) # Few iterations keep the example fast; use the default for analysis. model <- fit_nlcs(std$hc_z, parallel_iter = 10L) print(model)set.seed(42) ability <- rnorm(100) hc <- sapply(seq_len(4), function(j) { ability + rnorm(100, sd = 0.4) }) colnames(hc) <- paste0("test", seq_len(4)) std <- standardize_normative(hc) # Few iterations keep the example fast; use the default for analysis. model <- fit_nlcs(std$hc_z, parallel_iter = 10L) print(model)
Uses healthy-control means and sample standard deviations as the normative reference for both healthy controls and new subjects.
standardize_normative(hc_data, new_data = NULL)standardize_normative(hc_data, new_data = NULL)
hc_data |
A complete, finite numeric matrix or data frame. Rows are healthy controls and columns are cognitive tests. Column names are required. At least two healthy controls are required, and each test must have a nonzero sample standard deviation. |
new_data |
An optional complete, finite numeric matrix or
data frame for new subjects, with the same test names as
|
Data cleaning, test selection, missing-data handling, and direction recoding must be completed before using this function.
A named list of class nlcs_standardization containing:
A numeric matrix of standardized healthy-control
scores, with the same dimensions and column names as
hc_data.
A numeric matrix of standardized new-subject
scores, with columns in healthy-control order, or NULL
if new_data is omitted.
A named numeric vector of healthy-control test means.
A named numeric vector of healthy-control sample standard deviations.
A character vector of test names in healthy-control column order.
Each standardized score is the original score minus the healthy-control mean, divided by the healthy-control sample standard deviation. Positive values are above the healthy-control mean and negative values are below it. Whether higher scores indicate better performance depends on the original test coding.
hc <- cbind( test1 = c(8, 10, 12, 14, 16), test2 = c(3, 5, 4, 7, 6) ) new <- cbind(test1 = c(9, 13), test2 = c(4, 6)) std <- standardize_normative(hc, new) std$hc_z std$new_z std$means std$sdshc <- cbind( test1 = c(8, 10, 12, 14, 16), test2 = c(3, 5, 4, 7, 6) ) new <- cbind(test1 = c(9, 13), test2 = c(4, 6)) std <- standardize_normative(hc, new) std$hc_z std$new_z std$means std$sds