| Title: | Generalized Multicomponent Latent Trait Model for Diagnosis |
|---|---|
| Description: | Provides Bayesian estimation of Item Response Theory models that decompose item difficulty into cognitive operations or rules. Implements the Linear Logistic Test Model (LLTM; Fischer (1973) <doi:10.1016/0001-6918(73)90003-6>), the Multicomponent Latent Trait Model for Diagnosis (MLTM-D; Embretson and Yang (2013) <doi:10.1007/s11336-012-9296-y>), and the Generalized Multicomponent Latent Trait Model for Diagnosis (GMLTM-D; Ramirez et al. (2024) <doi:10.3390/jintelligence12070067>). All models are estimated via Hamiltonian Monte Carlo using 'Stan' through the 'rstan' interface. Includes tools for model validation, reliability estimation, and visualization of item characteristic curves. Supports user-defined prior distributions for all model parameters. |
| Authors: | Eduar Ramirez [aut, cre], Marcos Jimenez [aut], Vithor R. Franco [aut], Jesus Alvarado [aut] |
| Maintainer: | Eduar Ramirez <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-06-30 16:47:51 UTC |
| Source: | https://github.com/cran/GMLTM |
Binary item response data from a figural analogies test used to illustrate the LLTM, MLTM-D, and GMLTM-D models.
analogyanalogy
A matrix with 149 rows (subjects) and 27 columns (items), where each cell contains a binary response (0 = incorrect, 1 = correct).
Blum, D., Holling, H., Galibert, M. S., & Forthmann, B. (2016). Task difficulty prediction of figural analogies. Intelligence, 56, 72–81. doi:10.1016/j.intell.2016.03.001
Ramirez, E. S., Jimenez, M., Franco, V. R., & Alvarado, J. M. (2024). Delving into the complexity of analogical reasoning: A detailed exploration with the Generalized Multicomponent Latent Trait Model for Diagnosis. Journal of Intelligence, 12, 67. doi:10.3390/jintelligence12070067
Verifies if the data is suitable for robust reliability analysis.
check_reliability_data_quality(fit)check_reliability_data_quality(fit)
fit |
Fitted model |
List with data quality diagnostics
Compare Conditional Reliability Between Components at Specific Theta Values
compare_conditional_reliability(cond_rel_obj, theta_points = c(-1, 0, 1))compare_conditional_reliability(cond_rel_obj, theta_points = c(-1, 0, 1))
cond_rel_obj |
An object of class |
theta_points |
Numeric vector of theta values at which to compare components.
Default is |
Invisibly returns a data frame with columns theta,
reliability, and se evaluated at the requested
theta_points. Called primarily for its side effect of
printing a formatted summary table to the console.
This function extracts the log-likelihood from a GMLTM model and computes the Leave-One-Out Cross-Validation (LOO) and the Widely Applicable Information Criterion (WAIC). LOO is a Bayesian model comparison metric based on Pareto-smoothed importance sampling, while WAIC is a fully Bayesian criterion that estimates predictive accuracy.
compute_model_validation(fit)compute_model_validation(fit)
fit |
A fitted GMLTM model or a list of fitted models. |
If a single model is provided, returns a list with LOO and WAIC results. If multiple models are provided, returns a summary table with key LOO and WAIC indices.
Vehtari, A., Gelman, A., & Gabry, J. (2017). Practical Bayesian model evaluation using LOO-CV and WAIC. Statistics and Computing, 27(5), 1413–1432. doi:10.1007/s11222-016-9696-4
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit1 <- GMLTM(data = analogy, Q = Q, components = components, iters = 200, iter_warmup = 100, chains = 1) compute_model_validation(fit1)if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit1 <- GMLTM(data = analogy, Q = Q, components = components, iters = 200, iter_warmup = 100, chains = 1) compute_model_validation(fit1)
Calculates conditional reliability using Test Information Function for 3-parameter MLTM-D models. This approach is more precise than quantile-based partitioning methods.
conditional_reliability_tif( fit, theta_range = seq(-3, 3, 0.2), component = NULL, n_samples = 1000 )conditional_reliability_tif( fit, theta_range = seq(-3, 3, 0.2), component = NULL, n_samples = 1000 )
fit |
Fitted model with |
theta_range |
Vector of |
component |
Integer or character. Specific component to analyze |
n_samples |
Integer. Number of posterior samples to use |
A list of class "conditional_reliability_tif" with elements:
thetaNumeric vector of theta values.
reliabilityNumeric vector of reliability estimates at each theta value.
informationNumeric vector of test information values at each theta value.
componentInteger indicating the model component.
fitThe original fitted model object.
Demonstration function to show how to use the optimized functions.
demo_reliability_analysis(fit)demo_reliability_analysis(fit)
fit |
Fitted model |
Invisibly returns a list with the reliability estimates computed at each step of the analysis. Called primarily for its side effect of printing a step-by-step explanation to the console.
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- GMLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) demo_reliability_analysis(fit)if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- GMLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) demo_reliability_analysis(fit)
Provides comprehensive reliability analysis for General Multicomponent Latent Trait Models for Diagnosis (GMLTM-D) using Bayesian posterior distributions. Optimized for speed and minimal dependencies.
enhanced_mltm_reliability( fit, include_conditional = FALSE, include_hierarchical = TRUE, include_comparisons = TRUE, n_samples = NULL )enhanced_mltm_reliability( fit, include_conditional = FALSE, include_hierarchical = TRUE, include_comparisons = TRUE, n_samples = NULL )
fit |
A fitted GMLTM, MLTM, or LLTM model object containing posterior samples of theta parameters. |
include_conditional |
Logical. Whether to compute conditional reliability estimates across ability levels. Default is FALSE for speed. |
include_hierarchical |
Logical. Whether to compute hierarchical reliability for the general factor. Default is TRUE. |
include_comparisons |
Logical. Whether to perform Bayesian comparisons between components. Default is TRUE. |
n_samples |
Integer. Number of posterior samples to use (for speed control). If NULL, uses all available samples. |
An object of class enhanced_mltm_reliability.
Exports results in tabular format for publications.
export_reliability_results(reliability_obj, file_name = NULL)export_reliability_results(reliability_obj, file_name = NULL)
reliability_obj |
Object of class enhanced_mltm_reliability |
file_name |
File name (optional) |
data.frame with tabulated results
This function generates interaction terms between rules within the same component, extends the Q-matrix, and evaluates the resulting matrix for collinearity issues using eigenvalues, condition indices, and variance inflation factors (VIF). If severe collinearity is detected, it attempts to iteratively remove problematic interaction terms while keeping the original rules untouched.
generate_Q_with_interactions( Q, M_list, max_condition_index = 30, min_eigenvalue = 0.1, plot_diagnostics = TRUE, verbose = TRUE, save_to_global = TRUE )generate_Q_with_interactions( Q, M_list, max_condition_index = 30, min_eigenvalue = 0.1, plot_diagnostics = TRUE, verbose = TRUE, save_to_global = TRUE )
Q |
A binary matrix of items by rules (original Q-matrix). Each row represents an item and each column represents a rule. Values should be 0 or 1. |
M_list |
A list where each element contains the indices of rules that belong to the same component/dimension. For example, list(c(1,2,3), c(4,5)) indicates that rules 1,2,3 belong to component 1 and rules 4,5 belong to component 2. |
max_condition_index |
Numeric. Maximum acceptable condition index. Default is 30. Values above this threshold indicate severe collinearity. |
min_eigenvalue |
Numeric. Minimum acceptable eigenvalue. Default is 0.1. Values below this threshold may indicate linear dependence. |
plot_diagnostics |
Logical. Whether to generate diagnostic plots. Default is TRUE. |
verbose |
Logical. Whether to print detailed diagnostic information. Default is TRUE. |
save_to_global |
Logical. Whether to save results to global environment. Default is TRUE. |
The function performs the following steps:
Validates input parameters
Generates interaction terms for rules within the same component
Performs collinearity diagnostics using multiple methods
Attempts to resolve severe collinearity by removing problematic interactions
Generates diagnostic plots and summaries
Collinearity is assessed using:
Condition indices (based on eigenvalues of correlation matrix)
Variance Inflation Factors (VIF)
Matrix rank assessment
Eigenvalue analysis
A list containing:
Q_extended |
The extended Q-matrix with interaction terms |
M_list_extended |
Updated component list including interaction terms |
diagnostics |
List with collinearity diagnostics |
removed_interactions |
Vector of removed interaction names (if any) |
plots |
List of diagnostic plots (if plot_diagnostics = TRUE) |
Belsley, D. A., Kuh, E., & Welsch, R. E. (1980). Regression diagnostics: Identifying influential data and sources of collinearity. John Wiley & Sons. O'Brien, R. M. (2007). A caution regarding rules of thumb for variance inflation factors. Quality & Quantity, 41(5), 673-690. Hair, J. F., Anderson, R. E., Tatham, R. L., & Black, W. C. (1995). Multivariate data analysis. Prentice Hall.
# Create a sample Q-matrix (5 items, 4 rules) Q <- matrix(c(1,1,0,0,0, 1,0,1,0,0, 0,1,1,0,0, 0,0,0,1,1), nrow=5, ncol=4, byrow=FALSE) # Define components (rules 1-2 in component 1, rules 3-4 in component 2) M_list <- list(c(1,2), c(3,4)) # Generate extended Q-matrix with interactions result <- generate_Q_with_interactions(Q, M_list) # Access results extended_Q <- result$Q_extended diagnostics <- result$diagnostics plots <- result$plots# Create a sample Q-matrix (5 items, 4 rules) Q <- matrix(c(1,1,0,0,0, 1,0,1,0,0, 0,1,1,0,0, 0,0,0,1,1), nrow=5, ncol=4, byrow=FALSE) # Define components (rules 1-2 in component 1, rules 3-4 in component 2) M_list <- list(c(1,2), c(3,4)) # Generate extended Q-matrix with interactions result <- generate_Q_with_interactions(Q, M_list) # Access results extended_Q <- result$Q_extended diagnostics <- result$diagnostics plots <- result$plots
Estimate the parameters of the GMLTM-D via Bayesian Hamiltonian Monte Carlo.
GMLTM( data, Q, components, iters = 2000, chains = 2, iter_warmup = 1000, quantiles = c(0.025, 0.5, 0.975), cores = parallel::detectCores() - 1, priors = list(theta = list(mu = 0, sigma = 1), eta = list(mu = 0, sigma = 1), alpha = list(mu = 0, sigma = 1), c = list(shape1 = 3, shape2 = 20)), ... )GMLTM( data, Q, components, iters = 2000, chains = 2, iter_warmup = 1000, quantiles = c(0.025, 0.5, 0.975), cores = parallel::detectCores() - 1, priors = list(theta = list(mu = 0, sigma = 1), eta = list(mu = 0, sigma = 1), alpha = list(mu = 0, sigma = 1), c = list(shape1 = 3, shape2 = 20)), ... )
data |
An |
Q |
A |
components |
A named list grouping rules into components. Each element is
a numeric vector of rule indices belonging to that component.
Example: |
iters |
Number of post-warmup MCMC iterations per chain. Default is 2000. |
chains |
Number of Markov chains. Default is 2. |
iter_warmup |
Number of warmup iterations per chain. Default is 1000. |
quantiles |
Numeric vector of probabilities for posterior quantiles.
Default is |
cores |
Number of CPU cores for parallel chains.
Default is |
priors |
A named list of prior hyperparameters with elements |
... |
Additional arguments passed to |
GMLTM estimates the Generalized Multicomponent Latent Trait Model for
Diagnosis (GMLTM-D; Ramirez et al., 2024) in its Bayesian version. This model
analyses items composed of cognitive rules or operations, incorporating three IRT
parameters. Rules can be grouped into distinct components.
Prior distributions: Ability () and rule difficulty
() receive Normal priors. Discrimination () receives a
half-Normal prior. Guessing () receives a Beta prior.
A list of class "GMLTM" with elements:
EAPPosterior mean estimates: theta, alpha,
eta, beta, guessing.
quantilesPosterior credible intervals for each parameter.
posteriorFull posterior samples and derived quantities.
fitThe stanfit object from rstan::sampling.
dataThe original data matrix.
priorsThe prior hyperparameters used.
Ramirez, E.S.; Jimenez, M.; Franco, V.R.; Alvarado, J.M. (2024). Delving into the Complexity of Analogical Reasoning: A Detailed Exploration with the Generalized Multicomponent Latent Trait Model for Diagnosis. J. Intell., 12, 67. doi:10.3390/jintelligence12070067
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- GMLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) fit$EAP$eta reliability(fit)if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- GMLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) fit$EAP$eta reliability(fit)
Integrates conditional TIF analysis with existing reliability functions.
integrate_with_enhanced_reliability( fit, include_conditional_tif = TRUE, theta_range = seq(-3, 3, 0.1), ... )integrate_with_enhanced_reliability( fit, include_conditional_tif = TRUE, theta_range = seq(-3, 3, 0.1), ... )
fit |
A fitted GMLTM, MLTM, or LLTM model object. |
include_conditional_tif |
Logical. Whether to compute conditional TIF-based
reliability. Default is |
theta_range |
Numeric vector of theta values for conditional reliability evaluation.
Default is |
... |
Additional arguments passed to |
A list combining enhanced reliability results and, optionally, conditional TIF-based reliability.
Estimate the parameters of the LLTM via Bayesian Hamiltonian Monte Carlo.
LLTM( data, Q, iters = 2000, chains = 2, iter_warmup = 1000, quantiles = c(0.025, 0.5, 0.975), cores = parallel::detectCores() - 1, priors = list(theta = list(mu = 0, sigma = 1), eta = list(mu = 0, sigma = 1)), ... )LLTM( data, Q, iters = 2000, chains = 2, iter_warmup = 1000, quantiles = c(0.025, 0.5, 0.975), cores = parallel::detectCores() - 1, priors = list(theta = list(mu = 0, sigma = 1), eta = list(mu = 0, sigma = 1)), ... )
data |
An |
Q |
A |
iters |
Number of post-warmup MCMC iterations per chain. Default is 2000. |
chains |
Number of Markov chains. Default is 2. |
iter_warmup |
Number of warmup iterations per chain. Default is 1000. |
quantiles |
Numeric vector of probabilities for posterior quantiles.
Default is |
cores |
Number of CPU cores for parallel chains.
Default is |
priors |
A named list of prior hyperparameters. Each element is a named
list with |
... |
Additional arguments passed to |
LLTM estimates the Bayesian version of the Linear Logistic Test Model
(Fischer, 1973), which extends the Rasch model by decomposing item difficulty
into cognitive rules. Item difficulty is expressed as
,
where is the i-th row of Q and is the
vector of rule difficulty parameters.
Prior distributions: Ability () and rule difficulty
() receive Normal priors. Prior sensitivity analysis is recommended.
A list of class "LLTM" with elements:
EAPPosterior mean estimates: theta, eta, beta.
quantilesPosterior credible intervals for each parameter.
posteriorFull posterior samples and derived quantities.
fitThe stanfit object from rstan::sampling.
dataThe original data matrix.
priorsThe prior hyperparameters used.
Fischer, G. H. (1973). The linear logistic test model as an instrument in educational research. Acta Psychologica, 37(6), 359–374.
Ramirez, E.S.; Jimenez, M.; Franco, V.R.; Alvarado, J.M. (2024). Delving into the Complexity of Analogical Reasoning. J. Intell., 12, 67. doi:10.3390/jintelligence12070067
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) fit <- LLTM(analogy, Q, iters = 200, iter_warmup = 100, chains = 1) fit$EAP$eta reliability(fit)if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) fit <- LLTM(analogy, Q, iters = 200, iter_warmup = 100, chains = 1) fit$EAP$eta reliability(fit)
Computes and visualizes marginal success proportions, including predicted values, confidence intervals, RMSR, SRMR, and bias estimation.
marginal_Pchecks(fit, interval = 0.95)marginal_Pchecks(fit, interval = 0.95)
fit |
MLTM object containing model results. |
interval |
Probability associated with the credibility intervals (default = 0.95). |
marginal_Pchecks calculates marginal prediction intervals and observed success proportions.
It prints a table with observed vs. predicted values, generates a forest plot for visualization, and
computes key fit indices: RMSR, SRMR, and bias.
A list containing:
items: A table of fitted values and prediction intervals for each item.
rmsr: The Root Mean Square Residual (RMSR).
srmr: The Standardized Root Mean Square Residual (SRMR).
bias: The difference between the total observed and predicted proportions.
The function also generates:
A forest plot visualizing prediction intervals and observed success probabilities.
Estimate the parameters of the MLTM-D via Bayesian Hamiltonian Monte Carlo.
MLTM( data, Q, components, iters = 2000, chains = 2, iter_warmup = 1000, quantiles = c(0.025, 0.5, 0.975), cores = parallel::detectCores() - 1, priors = list(theta = list(mu = 0, sigma = 1), eta = list(mu = 0, sigma = 1), alpha = list(mu = 0, sigma = 1)), ... )MLTM( data, Q, components, iters = 2000, chains = 2, iter_warmup = 1000, quantiles = c(0.025, 0.5, 0.975), cores = parallel::detectCores() - 1, priors = list(theta = list(mu = 0, sigma = 1), eta = list(mu = 0, sigma = 1), alpha = list(mu = 0, sigma = 1)), ... )
data |
An |
Q |
A |
components |
A named list grouping rules into components. Each element is
a numeric vector of rule indices belonging to that component.
Example: |
iters |
Number of post-warmup MCMC iterations per chain. Default is 2000. |
chains |
Number of Markov chains. Default is 2. |
iter_warmup |
Number of warmup iterations per chain. Default is 1000. |
quantiles |
Numeric vector of probabilities for posterior quantiles.
Default is |
cores |
Number of CPU cores for parallel chains.
Default is |
priors |
A named list of prior hyperparameters with elements |
... |
Additional arguments passed to |
MLTM estimates the Bayesian version of the Multicomponent Latent Trait
Model for Diagnosis (MLTM-D; Embretson & Yang, 2013). This noncompensatory model
specifies a hierarchical relationship between components and rules.
Prior distributions: Ability () and rule difficulty ()
receive Normal priors. Discrimination () receives a half-Normal prior.
A list of class "MLTM" with elements:
EAPPosterior mean estimates: theta, alpha, eta, beta.
quantilesPosterior credible intervals for each parameter.
posteriorFull posterior samples and derived quantities.
fitThe stanfit object from rstan::sampling.
dataThe original data matrix.
priorsThe prior hyperparameters used.
Embretson, S. E., & Yang, X. (2013). A multicomponent latent trait model for diagnosis. Psychometrika, 78, 14–36.
Ramirez, E.S.; Jimenez, M.; Franco, V.R.; Alvarado, J.M. (2024). Delving into the Complexity of Analogical Reasoning. J. Intell., 12, 67. doi:10.3390/jintelligence12070067
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- MLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) fit$EAP$eta reliability(fit)if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- MLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) fit$EAP$eta reliability(fit)
Creates individual plots for each component in the analysis.
plot_all_components( results, plot_type = "both", include_ci = TRUE, color_scheme = "blue", save_plots = FALSE, output_dir = NULL, ... )plot_all_components( results, plot_type = "both", include_ci = TRUE, color_scheme = "blue", save_plots = FALSE, output_dir = NULL, ... )
results |
An object of class |
plot_type |
Character. Type of plot: |
include_ci |
Logical. Whether to include credible interval bands. Default |
color_scheme |
Character. Color scheme for plots. Default |
save_plots |
Logical. Whether to save plots to disk. Default |
output_dir |
Character. Directory for saved plots. Default |
... |
Additional arguments passed to |
Invisibly returns NULL. Called for its side effect of
producing reliability plots for all model components.
Creates a single plot comparing conditional reliability across all components.
plot_components_comparison( results, include_ci = TRUE, show_optimal_points = TRUE, add_reference_lines = TRUE, color_palette = "Set2", save_plot = FALSE, filename = NULL, ... )plot_components_comparison( results, include_ci = TRUE, show_optimal_points = TRUE, add_reference_lines = TRUE, color_palette = "Set2", save_plot = FALSE, filename = NULL, ... )
results |
An object of class |
include_ci |
Logical. Whether to include credible interval bands. Default |
show_optimal_points |
Logical. Whether to mark optimal theta points. Default |
add_reference_lines |
Logical. Whether to add horizontal reference lines at 0.7, 0.8, 0.9.
Default |
color_palette |
Character. RColorBrewer palette name for component colors.
Default |
save_plot |
Logical. Whether to save the plot. Default |
filename |
Character. Output filename if |
... |
Additional graphical arguments. |
Invisibly returns NULL. Called for its side effect of
producing a comparative reliability plot across model components.
Creates plots for conditional reliability analysis with multiple visualization options
plot_conditional_reliability( results, component = NULL, plot_type = "both", include_ci = TRUE, ci_level = 0.95, color_scheme = "blue", add_reference_lines = TRUE, save_plot = FALSE, filename = NULL, ... )plot_conditional_reliability( results, component = NULL, plot_type = "both", include_ci = TRUE, ci_level = 0.95, color_scheme = "blue", add_reference_lines = TRUE, save_plot = FALSE, filename = NULL, ... )
results |
Object of class conditional_reliability_tif |
component |
Integer or character. Component to plot (NULL for first component) |
plot_type |
Character. Type of plot: "reliability", "information", "both", "comparison" |
include_ci |
Logical. Include confidence intervals |
ci_level |
Numeric. Confidence level (0.90 or 0.95) |
color_scheme |
Character. Color scheme: "blue", "viridis", "custom" |
add_reference_lines |
Logical. Add reference lines for reliability levels |
save_plot |
Logical. Save plot to file |
filename |
Character. Filename if saving plot. Default |
... |
Additional plotting parameters |
Invisibly returns NULL. Called for its side effect of
producing one or two plots (reliability curve, test information
function, or both) depending on plot_type.
Generates Item Characteristic Curves (ICCs) for a group of items displayed in a grid layout with a shared legend.
plot_ICC_grouped( fit, Q, components, page = 1, n_items_per_page = 9, ncol = 3, nrow = 3 )plot_ICC_grouped( fit, Q, components, page = 1, n_items_per_page = 9, ncol = 3, nrow = 3 )
fit |
A fitted GMLTM model object containing EAP parameter estimates. |
Q |
The Q-matrix indicating the association between items and rules. |
components |
A list where each element is a vector of rule indices per component. |
page |
Integer specifying which page of items to display. |
n_items_per_page |
Number of items to include per page. Default is 9. |
ncol |
Number of columns in the layout grid. Default is 3. |
nrow |
Number of rows in the layout grid. Default is 3. |
Displays one legend shared across all plots and ensures consistency across theta and probability axes. Ideal for publications or appendices.
A composed ICC grid with one shared legend, plotted to the active device.
Ramirez, E.S.; Jimenez, M.; Franco, V.R.; Alvarado, J.M. (2024). Delving into the Complexity of Analogical Reasoning. J. Intell., 12, 67. doi:10.3390/jintelligence12070067
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- GMLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) plot_ICC_grouped(fit, Q, components, page = 1)if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- GMLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) plot_ICC_grouped(fit, Q, components, page = 1)
Returns a list of individual ICC ggplot2 plots (one per item).
plot_ICC_individual(fit, Q, components)plot_ICC_individual(fit, Q, components)
fit |
A fitted GMLTM model object. |
Q |
The Q-matrix for rule-item associations. |
components |
A list indicating rule groupings per component. |
A list of individual ggplot objects, one per item.
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- GMLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) plots <- plot_ICC_individual(fit, Q, components) print(plots[[1]])if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) components <- list(global = c(1, 2, 3), local = c(4, 5)) fit <- GMLTM(analogy, Q, components, iters = 200, iter_warmup = 100, chains = 1) plots <- plot_ICC_individual(fit, Q, components) print(plots[[1]])
Plot Method for conditional_reliability_tif Objects
## S3 method for class 'conditional_reliability_tif' plot(x, ...)## S3 method for class 'conditional_reliability_tif' plot(x, ...)
x |
An object of class |
... |
Additional arguments passed to |
Invisibly returns NULL. Called for its side effect of
producing a reliability and/or information plot via
plot_conditional_reliability().
Creates basic plots using base R (no ggplot2 dependency).
## S3 method for class 'enhanced_mltm_reliability' plot(x, type = "marginal", component = NULL, ...)## S3 method for class 'enhanced_mltm_reliability' plot(x, type = "marginal", component = NULL, ...)
x |
Object of class |
type |
Character. Type of plot: "marginal", "conditional", "comparison". |
component |
Integer or character. Specific component for conditional plots. |
... |
Additional plotting parameters. |
Invisibly returns NULL. Called for its side effects.
This function generates posterior predictive checks by plotting the observed and simulated total scores distribution, comparing empirical data against model predictions. It also computes fitted values and prediction intervals.
ppchecks(fit, nsim = 100, interval = 0.95, ...)ppchecks(fit, nsim = 100, interval = 0.95, ...)
fit |
A fitted MLTM object containing model results. |
nsim |
Number of simulated posterior samples (default = 100). |
interval |
Probability associated with the credibility intervals (default = 0.95). |
... |
Additional graphical parameters to customize the plot. |
The function simulates multiple datasets from the posterior distribution and compares the empirical distribution of total scores with the predicted distribution. It overlays the observed and predicted distributions using a histogram with transparency.
The fitted values, along with their credibility intervals, are computed and returned.
A list containing:
items: A table of fitted values and prediction intervals for each item.
subjects: Fitted and observed mean scores per subject.
ysim: Simulated response matrices.
The function also generates:
A histogram comparing observed vs. predicted total scores.
Ramirez, E.S.; Jimenez, M.; Franco, V.R.; Alvarado, J.M. Delving into the Complexity of Analogical Reasoning: A Detailed Exploration with the Generalized Multicomponent Latent Trait Model for Diagnosis. J. Intell. 2024, 12, 67. https://doi.org/10.3390/jintelligence12070067
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) fit <- LLTM(analogy, Q, iters = 200, iter_warmup = 100, chains = 1) ppchecks(fit)if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) fit <- LLTM(analogy, Q, iters = 200, iter_warmup = 100, chains = 1) ppchecks(fit)
Print Method for Enhanced MLTM Reliability
## S3 method for class 'enhanced_mltm_reliability' print(x, digits = 3, ...)## S3 method for class 'enhanced_mltm_reliability' print(x, digits = 3, ...)
x |
An object of class |
digits |
Integer. Number of decimal places to display. Default is |
... |
Currently unused. |
Invisibly returns x. Called for its side effect of printing
the enhanced reliability analysis results to the console.
Print Method for Data Quality Diagnostics
## S3 method for class 'reliability_data_quality' print(x, ...)## S3 method for class 'reliability_data_quality' print(x, ...)
x |
An object of class |
... |
Currently unused. |
Invisibly returns x. Called for its side effect of printing
the data quality diagnostics to the console.
Print Method for Reliability Profile
## S3 method for class 'reliability_profile' print(x, ...)## S3 method for class 'reliability_profile' print(x, ...)
x |
An object of class |
... |
Currently unused. |
Invisibly returns x. Called for its side effect of printing
a formatted reliability profile summary to the console.
Ultra-fast reliability check for initial assessment.
quick_reliability_check(fit, n_samples_quick = 500)quick_reliability_check(fit, n_samples_quick = 500)
fit |
Fitted model object. |
n_samples_quick |
Integer. Number of samples for quick analysis (default 500). |
Named vector of reliability estimates.
if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) fit <- LLTM(analogy, Q, iters = 200, iter_warmup = 100, chains = 1) quick_rel <- quick_reliability_check(fit) print(quick_rel)if (!requireNamespace("rstan", quietly = TRUE)) return() data(analogy) Q <- structure( c(0,0,1,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,1, 1,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0, 1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0, 0,0,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,0, 1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1), dim = c(27L, 5L), dimnames = list(NULL, c("rot_fig","rot_trap","reflection", "subt_seg","mov_point"))) fit <- LLTM(analogy, Q, iters = 200, iter_warmup = 100, chains = 1) quick_rel <- quick_reliability_check(fit) print(quick_rel)
Estimate the the marginal reliability of the GMLTM.
reliability(fit)reliability(fit)
fit |
MLTM object. |
reliability estimates a ...
A number denoting the reliability estimate.
Ramírez, E.S.; Jiménez, M.; Franco, V.R.; Alvarado, J.M. Delving into the Complexity of Analogical Reasoning: A Detailed Exploration with the Generalized Multicomponent Latent Trait Model for Diagnosis. J. Intell. 2024, 12, 67. https://doi.org/10.3390/jintelligence12070067
Provides a quick overview of reliability characteristics for each component.
reliability_profile(cond_rel_obj)reliability_profile(cond_rel_obj)
cond_rel_obj |
An object of class |
A list of class "reliability_profile" with elements:
summaryData frame with columns theta,
reliability, lower, and upper.
componentInteger indicating which model component was analysed.
Prints detailed usage instructions.
reliability_usage_instructions()reliability_usage_instructions()
Invisibly returns NULL. Called for its side effect of
printing step-by-step usage instructions to the console.
Summary Method for Conditional Reliability Analysis
## S3 method for class 'conditional_reliability_tif' summary(object, digits = 3, ...)## S3 method for class 'conditional_reliability_tif' summary(object, digits = 3, ...)
object |
An object of class |
digits |
Integer. Number of decimal places to display. Default is |
... |
Currently unused. |
Invisibly returns object. Called for its side effect of
printing a formatted summary of conditional reliability statistics to the
console.