| Title: | Questionnaire Analysis for Epidemiology and One Health Research |
|---|---|
| Description: | Provides tools for the analysis of questionnaire and survey data in epidemiological and One Health research. The package supports data preparation, reliability assessment, exploratory factor analysis, Kaiser-Meyer-Olkin assessment, parallel analysis, visualization, reporting, and export of results using a consistent analysis workflow. The methods are based on established approaches to psychometric and multivariate analysis; see Kaiser (1974) <doi:10.1007/BF02291575>, Horn (1965) <doi:10.1007/BF02289447>, and Tabachnick and Fidell (2019, ISBN:9780134790541). |
| Authors: | Vinodh Kumar Obli Rajendran [aut, cre] (ORCID: <https://orcid.org/0000-0002-7232-4122>), Keerthi Aaradhana [aut] |
| Maintainer: | Vinodh Kumar Obli Rajendran <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.2 |
| Built: | 2026-11-01 16:19:12 UTC |
| Source: | https://github.com/cran/EpiQuestionR |
Interactive HTML Table
as_datatable(object, ...)as_datatable(object, ...)
object |
epi_kaiser object. |
... |
Additional arguments passed to other methods or currently unused. |
DT widget.
Convert Kaiser Table to flextable
as_flextable(object, ...)as_flextable(object, ...)
object |
epi_kaiser object. |
... |
Additional arguments passed to other methods or currently unused. |
A flextable object.
Convert Kaiser Table to gt
as_gt(object, ...)as_gt(object, ...)
object |
An object of class |
... |
Additional arguments passed to methods. |
A gt_tbl object.
Convert to knitr::kable
as_kable(object, ...)as_kable(object, ...)
object |
epi_kaiser object. |
... |
Additional arguments passed to other methods or currently unused. |
knitr kable.
Convert to tibble
## S3 method for class 'epi_kaiser' as_tibble(x, ..., .rows = NULL, .name_repair = "check_unique", rownames = NULL)## S3 method for class 'epi_kaiser' as_tibble(x, ..., .rows = NULL, .name_repair = "check_unique", rownames = NULL)
x |
An object of class 'epi_kaiser'. |
... |
Additional arguments passed to [tibble::as_tibble()]. |
.rows |
Optional number of rows. |
.name_repair |
Name repair specification. |
rownames |
How row names should be handled. |
A tibble.
Converts an object of class epi_kaiser to a data frame containing
the Kaiser criterion results.
## S3 method for class 'epi_kaiser' as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'epi_kaiser' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'epi_kaiser' as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'epi_kaiser' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
An object of class |
row.names |
Optional row names. Currently unused. |
optional |
Logical. Currently unused. |
... |
Additional arguments, currently unused. |
A data frame containing the Kaiser criterion results.
Converts an '"epi_map"' object to its component-level MAP results table.
## S3 method for class 'epi_map' as.data.frame(x, row.names = NULL, optional = FALSE, ...)## S3 method for class 'epi_map' as.data.frame(x, row.names = NULL, optional = FALSE, ...)
x |
An object of class '"epi_map"'. |
row.names |
Optional row names. |
optional |
Logical. Included for compatibility with [base::as.data.frame()]. |
... |
Additional arguments currently ignored. |
A data frame containing the MAP criterion results.
Extract Eigenvalue Table
## S3 method for class 'epi_kaiser' as.matrix(x, ...)## S3 method for class 'epi_kaiser' as.matrix(x, ...)
x |
An object of class |
... |
Further arguments. |
A matrix containing the eigenvalue table stored in the
table component of the epi_kaiser object. The matrix
provides a tabular representation of the eigenvalue results used to
summarize and interpret factor retention.
Adds the retained-factor recommendation as attributes.
## S3 method for class 'epi_kaiser' augment(x, data = NULL, ...)## S3 method for class 'epi_kaiser' augment(x, data = NULL, ...)
x |
An object of class |
data |
Original dataset. |
... |
Additional arguments passed to the underlying function or method. |
A tibble.
Returns component- or factor-level parallel-analysis results with additional derived quantities useful for downstream analysis, visualization, and reporting.
## S3 method for class 'epi_parallel' augment(x, data = NULL, newdata = NULL, ...)## S3 method for class 'epi_parallel' augment(x, data = NULL, newdata = NULL, ...)
x |
An object of class |
data |
Optional data argument included for compatibility with
|
newdata |
Optional new-data argument included for generic compatibility. It is currently unused. |
... |
Additional arguments. Currently unused. |
Unlike augmentation methods for regression models, rows in this output represent components or factors rather than individual observations.
A data frame containing augmented component- or factor-level results.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) generics::augment(result)set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) generics::augment(result)
Draw a scree plot for an object of class epi_kaiser.
## S3 method for class 'epi_kaiser' autoplot(object, show_cutoff = TRUE, show_labels = TRUE, ...)## S3 method for class 'epi_kaiser' autoplot(object, show_cutoff = TRUE, show_labels = TRUE, ...)
object |
An object of class |
show_cutoff |
Logical. Show the Kaiser eigenvalue cutoff at 1? |
show_labels |
Logical. Show eigenvalue labels? |
... |
Additional arguments, currently unused. |
A ggplot object.
Creates a 'ggplot2' visualization of a Velicer MAP test.
## S3 method for class 'epi_map' autoplot( object, type = c("map", "eigenvalues"), highlight = TRUE, show_line = TRUE, show_label = TRUE, title = NULL, subtitle = NULL, ... )## S3 method for class 'epi_map' autoplot( object, type = c("map", "eigenvalues"), highlight = TRUE, show_line = TRUE, show_label = TRUE, title = NULL, subtitle = NULL, ... )
object |
An object of class '"epi_map"'. |
type |
Character string specifying the plot type. One of '"map"' or '"eigenvalues"'. |
highlight |
Logical. If 'TRUE', highlights the recommended result. |
show_line |
Logical. If 'TRUE', displays a vertical reference line at the recommended number of components. |
show_label |
Logical. If 'TRUE', annotates the recommended number of components. |
title |
Optional plot title. |
subtitle |
Optional plot subtitle. If 'NULL', a subtitle is generated automatically. |
... |
Additional arguments currently ignored. |
The default '"map"' plot displays the MAP criterion against the number of partialled components and highlights the recommended dimensionality.
The '"eigenvalues"' plot creates a scree plot with a horizontal Kaiser reference line at an eigenvalue of 1.
A 'ggplot' object.
set.seed(123) dat <- matrix( rnorm(1000), ncol = 10 ) fit <- map_test(dat) ggplot2::autoplot(fit) ggplot2::autoplot( fit, type = "eigenvalues" )set.seed(123) dat <- matrix( rnorm(1000), ncol = 10 ) fit <- map_test(dat) ggplot2::autoplot(fit) ggplot2::autoplot( fit, type = "eigenvalues" )
Creates a publication-ready ggplot2 visualization of Horn's Parallel Analysis results.
## S3 method for class 'epi_parallel' autoplot( object, type = c("parallel", "scree", "variance", "retention"), reference = c("criterion", "percentile", "mean", "both"), title = NULL, subtitle = NULL, caption = NULL, legend_position = "bottom", base_size = 12, ... )## S3 method for class 'epi_parallel' autoplot( object, type = c("parallel", "scree", "variance", "retention"), reference = c("criterion", "percentile", "mean", "both"), title = NULL, subtitle = NULL, caption = NULL, legend_position = "bottom", base_size = 12, ... )
object |
An object of class |
type |
Character string specifying the plot type. Supported values are
|
reference |
Character string specifying the simulated reference series.
Supported values are |
title |
Optional plot title. |
subtitle |
Optional plot subtitle. |
caption |
Optional plot caption. |
legend_position |
Position of the plot legend. |
base_size |
Base font size. |
... |
Additional arguments. Currently unused. |
Available plot types include:
"parallel"Observed versus simulated eigenvalue curves.
"variance"Percentage variance explained by each component.
"retention"Observed-minus-reference eigenvalue differences.
A ggplot object.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) ggplot2::autoplot(result) ggplot2::autoplot( result, type = "parallel", reference = "both" ) ggplot2::autoplot( result, type = "variance" ) ggplot2::autoplot( result, type = "retention" )set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) ggplot2::autoplot(result) ggplot2::autoplot( result, type = "parallel", reference = "both" ) ggplot2::autoplot( result, type = "variance" ) ggplot2::autoplot( result, type = "retention" )
Bayesian Information Criterion
bic(object)bic(object)
object |
epi_efa object. |
Numeric.
Extract Eigenvalues
## S3 method for class 'epi_kaiser' coef(object, ...)## S3 method for class 'epi_kaiser' coef(object, ...)
object |
An object of class |
... |
Additional arguments passed to other methods or currently unused. |
A named numeric vector containing the eigenvalues from the
epi_kaiser object. The elements are named PC1, PC2,
and so on, corresponding to successive principal components or factors.
Each value represents the variance associated with the corresponding
component.
Extracts the number of components recommended by Velicer's MAP test.
## S3 method for class 'epi_map' coef(object, ...)## S3 method for class 'epi_map' coef(object, ...)
object |
An object of class '"epi_map"'. |
... |
Additional arguments currently ignored. |
A named integer containing the recommended number of components.
set.seed(123) dat <- matrix( rnorm(500), ncol = 5 ) fit <- map_test(dat) coef(fit)set.seed(123) dat <- matrix( rnorm(500), ncol = 5 ) fit <- map_test(dat) coef(fit)
Extracts eigenvalue-based results from an "epi_parallel" object.
## S3 method for class 'epi_parallel' coef( object, type = c("observed", "simulated_mean", "simulated_percentile", "difference", "retained", "all"), ... )## S3 method for class 'epi_parallel' coef( object, type = c("observed", "simulated_mean", "simulated_percentile", "difference", "retained", "all"), ... )
object |
An object of class |
type |
Character string specifying the values to extract.
Supported values are |
... |
Additional arguments passed to or from other methods. |
By default, the method returns observed eigenvalues. Other available outputs include mean simulated eigenvalues, percentile reference eigenvalues, differences between observed and reference eigenvalues, and retained component or factor indices.
Depending on type, returns a numeric vector, integer vector,
or data frame.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) coef(result) coef(result, type = "simulated_mean") coef(result, type = "simulated_percentile") coef(result, type = "difference") coef(result, type = "retained") coef(result, type = "all")set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) coef(result) coef(result, type = "simulated_mean") coef(result, type = "simulated_percentile") coef(result, type = "difference") coef(result, type = "retained") coef(result, type = "all")
Communalities
communalities(object)communalities(object)
object |
epi_efa object. |
Numeric vector.
Draw a publication-quality bar chart of item communalities.
communality_plot( object, sort = TRUE, horizontal = TRUE, fill = "#2C7FB8", title = "Communalities" )communality_plot( object, sort = TRUE, horizontal = TRUE, fill = "#2C7FB8", title = "Communalities" )
object |
Object of class |
sort |
Logical. Sort communalities from highest to lowest? |
horizontal |
Logical. Draw horizontal bars? |
fill |
Fill colour. |
title |
Plot title. |
A ggplot object.
set.seed(123) latent <- rnorm(200) example_data <- data.frame( Q1 = 0.8 * latent + rnorm(200, sd = 0.5), Q2 = 0.8 * latent + rnorm(200, sd = 0.5), Q3 = 0.7 * latent + rnorm(200, sd = 0.5), Q4 = 0.7 * latent + rnorm(200, sd = 0.5), Q5 = 0.6 * latent + rnorm(200, sd = 0.5) ) fit <- efa( example_data, items = paste0("Q", 1:5), nfactors = 1 ) communality_plot(fit)set.seed(123) latent <- rnorm(200) example_data <- data.frame( Q1 = 0.8 * latent + rnorm(200, sd = 0.5), Q2 = 0.8 * latent + rnorm(200, sd = 0.5), Q3 = 0.7 * latent + rnorm(200, sd = 0.5), Q4 = 0.7 * latent + rnorm(200, sd = 0.5), Q5 = 0.6 * latent + rnorm(200, sd = 0.5) ) fit <- efa( example_data, items = paste0("Q", 1:5), nfactors = 1 ) communality_plot(fit)
Item Complexity
complexity(object)complexity(object)
object |
epi_efa object. |
Numeric vector.
Performs Exploratory Factor Analysis (EFA) for questionnaire data.
efa( data, items, nfactors = NULL, extraction = "minres", rotation = "oblimin", scores = TRUE )efa( data, items, nfactors = NULL, extraction = "minres", rotation = "oblimin", scores = TRUE )
data |
Data frame. |
items |
Character vector of questionnaire items. |
nfactors |
Number of factors. If NULL, parallel analysis is used. |
extraction |
Extraction method. One of "minres","pa","ml","uls","gls","wls". |
rotation |
Rotation method. One of "varimax","promax","oblimin","quartimin", "none". |
scores |
Calculate factor scores? |
Features: - KMO Measure - Bartlett Test - Parallel Analysis - Automatic Factor Selection - Multiple Extraction Methods - Multiple Rotations
Object of class
epi_efa
data(questionnaire_data) efa( questionnaire_data, items = paste0("Q", 1:5), nfactors = 1 )data(questionnaire_data) efa( questionnaire_data, items = paste0("Q", 1:5), nfactors = 1 )
EFA Fit Statistics
efa_fit(object)efa_fit(object)
object |
epi_efa object. |
Data frame.
Publication-quality eigenvalue plot.
eigenvalue_plot(object, criterion = 1)eigenvalue_plot(object, criterion = 1)
object |
epi_efa object. |
criterion |
Kaiser cutoff. |
ggplot object.
Eigenvalues
eigenvalues(x, ...)eigenvalues(x, ...)
x |
An object of class |
... |
Additional arguments passed to methods. |
A numeric vector containing the eigenvalues from the
epi_kaiser object. Each element represents the amount of variance
associated with the corresponding component or factor and is used in the
Kaiser criterion for factor retention.
Exports the Kaiser criterion results to a CSV file.
export_kaiser_csv( object, file = tempfile(pattern = "kaiser_results_", fileext = ".csv"), digits = object$digits )export_kaiser_csv( object, file = tempfile(pattern = "kaiser_results_", fileext = ".csv"), digits = object$digits )
object |
An object of class |
file |
Character. Output CSV filename. |
digits |
Number of decimal places. |
Invisibly returns the normalized output filename.
Exports the Kaiser criterion results to an Excel workbook.
export_kaiser_excel( object, file = tempfile(pattern = "kaiser_results_", fileext = ".xlsx"), digits = 3 )export_kaiser_excel( object, file = tempfile(pattern = "kaiser_results_", fileext = ".xlsx"), digits = 3 )
object |
An object of class |
file |
Character. Output Excel filename. |
digits |
Number of decimal places. |
Invisibly returns the normalized output filename.
Export Kaiser Results to JSON
export_kaiser_json( object, file = tempfile(pattern = "kaiser_results_", fileext = ".json") )export_kaiser_json( object, file = tempfile(pattern = "kaiser_results_", fileext = ".json") )
object |
epi_kaiser object. |
file |
Output JSON filename. |
Invisibly returns the filename.
Export Markdown Report
export_kaiser_markdown( object, file = tempfile(pattern = "kaiser_report_", fileext = ".md"), digits = object$digits )export_kaiser_markdown( object, file = tempfile(pattern = "kaiser_report_", fileext = ".md"), digits = object$digits )
object |
epi_kaiser object. |
file |
Output markdown filename. |
digits |
Number of decimal places. |
Invisibly returns the filename.
Export Kaiser Results to YAML
export_kaiser_yaml( object, file = tempfile(pattern = "kaiser_results_", fileext = ".yml") )export_kaiser_yaml( object, file = tempfile(pattern = "kaiser_results_", fileext = ".yml") )
object |
epi_kaiser object. |
file |
Output YAML filename. |
Invisibly returns the filename.
Exports results from a Velicer Minimum Average Partial (MAP) test to a file.
export_map(x, file, format = NULL, digits = 4L, overwrite = FALSE, ...)export_map(x, file, format = NULL, digits = 4L, overwrite = FALSE, ...)
x |
An object of class '"epi_map"'. |
file |
Character string specifying the output file path. |
format |
Character string specifying the export format. One of '"csv"', '"xlsx"', or '"txt"'. If 'NULL', the format is inferred from the file extension. |
digits |
Number of decimal places used for numeric results. |
overwrite |
Logical. If 'TRUE', an existing file may be overwritten. |
... |
Additional arguments passed to the corresponding export method. |
Supported formats include CSV, Excel, and plain-text reports.
The normalized path to the exported file, invisibly.
fit <- map_test(USArrests) csv_file <- tempfile(fileext = ".csv") xlsx_file <- tempfile(fileext = ".xlsx") txt_file <- tempfile(fileext = ".txt") export_map( fit, file = csv_file ) export_map( fit, file = xlsx_file ) export_map( fit, file = txt_file ) file.exists(csv_file) file.exists(xlsx_file) file.exists(txt_file)fit <- map_test(USArrests) csv_file <- tempfile(fileext = ".csv") xlsx_file <- tempfile(fileext = ".xlsx") txt_file <- tempfile(fileext = ".txt") export_map( fit, file = csv_file ) export_map( fit, file = xlsx_file ) export_map( fit, file = txt_file ) file.exists(csv_file) file.exists(xlsx_file) file.exists(txt_file)
Exports the component-level MAP criterion table to a CSV file.
export_map_csv(x, file, digits = 4L, overwrite = FALSE, row.names = FALSE, ...)export_map_csv(x, file, digits = 4L, overwrite = FALSE, row.names = FALSE, ...)
x |
An object of class '"epi_map"'. |
file |
Character string specifying the output CSV file. |
digits |
Number of decimal places used for MAP values. |
overwrite |
Logical. If 'TRUE', overwrite an existing file. |
row.names |
Logical. Passed to [utils::write.csv()]. |
... |
Additional arguments passed to [utils::write.csv()]. |
The normalized output path, invisibly.
fit <- map_test(USArrests) file <- tempfile(fileext = ".csv") export_map_csv( fit, file )fit <- map_test(USArrests) file <- tempfile(fileext = ".csv") export_map_csv( fit, file )
Exports MAP analysis results to an Excel workbook containing separate worksheets for the analysis summary, MAP criterion results, eigenvalues, settings, and metadata.
export_map_excel(x, file, digits = 4L, overwrite = FALSE, ...)export_map_excel(x, file, digits = 4L, overwrite = FALSE, ...)
x |
An object of class '"epi_map"'. |
file |
Character string specifying the output '.xlsx' file. |
digits |
Number of decimal places used for numeric values. |
overwrite |
Logical. If 'TRUE', overwrite an existing file. |
... |
Additional arguments reserved for future extensions. |
The normalized output path, invisibly.
fit <- map_test(USArrests) file <- tempfile(fileext = ".xlsx") export_map_excel( fit, file )fit <- map_test(USArrests) file <- tempfile(fileext = ".xlsx") export_map_excel( fit, file )
Writes a publication-ready textual report of a Velicer MAP analysis to a plain-text file.
export_map_report( x, file, style = c("standard", "apa", "brief"), digits = 4L, overwrite = FALSE, ... )export_map_report( x, file, style = c("standard", "apa", "brief"), digits = 4L, overwrite = FALSE, ... )
x |
An object of class '"epi_map"'. |
file |
Character string specifying the output text file. |
style |
Reporting style passed to [report_map()]. |
digits |
Number of decimal places used for the MAP value. |
overwrite |
Logical. If 'TRUE', overwrite an existing file. |
... |
Additional arguments passed to [report_map()]. |
The normalized output path, invisibly.
fit <- map_test(USArrests) file <- tempfile(fileext = ".txt") export_map_report( fit, file )fit <- map_test(USArrests) file <- tempfile(fileext = ".txt") export_map_report( fit, file )
Saves a complete "epi_parallel" object to an RDS file. This preserves
the full object structure, including results, settings, metadata, matrices,
diagnostics, and other stored elements.
export_parallel(x, file, compress = TRUE)export_parallel(x, file, compress = TRUE)
x |
An object of class |
file |
Character scalar specifying the destination RDS file. |
compress |
Compression method passed to |
Invisibly returns the normalized output file path.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) export_parallel( result, file = tempfile(fileext = ".rds") )set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) export_parallel( result, file = tempfile(fileext = ".rds") )
Generates and exports a text report from an "epi_parallel" object.
export_parallel_report(x, file, digits = 3, overwrite = FALSE)export_parallel_report(x, file, digits = 3, overwrite = FALSE)
x |
An object of class |
file |
Character scalar specifying the destination text file. |
digits |
Number of decimal places used in reported numeric values. |
overwrite |
Logical. Whether an existing file may be overwritten. |
The exported report contains methods, results, interpretation, and recommendation sections.
Invisibly returns the normalized output file path.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) tmp <- tempfile(fileext = ".txt") export_parallel_report( result, file = tmp ) file.exists(tmp)set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) tmp <- tempfile(fileext = ".txt") export_parallel_report( result, file = tmp ) file.exists(tmp)
Exports tables generated from an "epi_parallel" object as CSV files.
export_parallel_tables( x, path = ".", prefix = "parallel_analysis", digits = 3, include_variance = TRUE, include_retention = TRUE, create_dir = TRUE, overwrite = FALSE )export_parallel_tables( x, path = ".", prefix = "parallel_analysis", digits = 3, include_variance = TRUE, include_retention = TRUE, create_dir = TRUE, overwrite = FALSE )
x |
An object of class |
path |
Directory where CSV files will be written. |
prefix |
Character prefix used for exported file names. |
digits |
Number of decimal places used for numeric output. |
include_variance |
Logical. Export the variance table. |
include_retention |
Logical. Export the retention table. |
create_dir |
Logical. Create |
overwrite |
Logical. Whether existing files may be overwritten. |
The function can export the analysis summary, component-level parallel analysis results, variance-explained results, and retention decisions.
Invisibly returns a named character vector containing exported file paths.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) export_parallel_report( result, file = tempfile(fileext = ".txt") )set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) export_parallel_report( result, file = tempfile(fileext = ".txt") )
Draw a heatmap of the factor correlation matrix (Phi).
factor_correlation_plot( object, digits = 2, low = "#2166AC", mid = "white", high = "#B2182B" )factor_correlation_plot( object, digits = 2, low = "#2166AC", mid = "white", high = "#B2182B" )
object |
Object of class |
digits |
Number of decimal places. |
low |
Colour for negative correlations. |
mid |
Colour for zero. |
high |
Colour for positive correlations. |
This plot is only available for oblique rotations such as
"oblimin", "promax", "quartimin", etc.
ggplot object.
Extract Factor Loadings
factor_loadings(object)factor_loadings(object)
object |
epi_efa object. |
Matrix of factor loadings.
Factor Scores
factor_scores(object)factor_scores(object)
object |
epi_efa object. |
Data frame.
Returns a one-row summary suitable for model comparison.
## S3 method for class 'epi_kaiser' glance(x, ...)## S3 method for class 'epi_kaiser' glance(x, ...)
x |
An object of class |
... |
Additional arguments passed to the underlying function or method. |
A tibble.
Returns a one-row summary of a Velicer Minimum Average Partial (MAP) test.
## S3 method for class 'epi_map' glance(x, ...)## S3 method for class 'epi_map' glance(x, ...)
x |
An object of class '"epi_map"'. |
... |
Additional arguments currently ignored. |
A one-row data frame containing the recommended number of components, minimum MAP value, criterion, number of observations, number of variables, input type, correlation method, and maximum number of components evaluated.
set.seed(123) dat <- matrix(rnorm(1000), ncol = 10) fit <- map_test(dat) generics::glance(fit)set.seed(123) dat <- matrix(rnorm(1000), ncol = 10) fit <- map_test(dat) generics::glance(fit)
Returns a one-row summary of Horn's Parallel Analysis, including dataset dimensions, simulation settings, retention criterion, and the recommended number of retained components or factors.
## S3 method for class 'epi_parallel' glance(x, ...)## S3 method for class 'epi_parallel' glance(x, ...)
x |
An object of class |
... |
Additional arguments. Currently unused. |
A one-row data frame containing model-level summary information.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) generics::glance(result)set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) generics::glance(result)
APA Caption
kaiser_caption(object)kaiser_caption(object)
object |
epi_kaiser object. |
Character string.
Determines the recommended number of factors using the Kaiser criterion (retain factors with eigenvalues greater than 1).
kaiser_criterion( data, items = NULL, correlation = "auto", use = "pairwise.complete.obs", digits = 3, verbose = TRUE )kaiser_criterion( data, items = NULL, correlation = "auto", use = "pairwise.complete.obs", digits = 3, verbose = TRUE )
data |
A data frame or numeric matrix. |
items |
Character vector of variable names. If NULL, all variables are used. |
correlation |
Correlation method. One of "auto", "pearson", "spearman", "kendall", "polychoric", "tetrachoric", or "mixed". |
use |
Missing-value handling passed to
|
digits |
Number of digits to print. |
verbose |
Logical. |
An object of class epi_kaiser.
data(bfi, package = "psych") dat <- bfi[ complete.cases(bfi[, 1:6]), 1:6 ] res <- kaiser_criterion( dat[1:200, ], verbose = FALSE ) print(res) summary(res)data(bfi, package = "psych") dat <- bfi[ complete.cases(bfi[, 1:6]), 1:6 ] res <- kaiser_criterion( dat[1:200, ], verbose = FALSE ) print(res) summary(res)
Kaiser Table Footnote
kaiser_footnote(object)kaiser_footnote(object)
object |
epi_kaiser object. |
Character string.
Table Notes
kaiser_notes(object)kaiser_notes(object)
object |
epi_kaiser object. |
Character vector.
Kaiser Summary Table
kaiser_summary_table(object)kaiser_summary_table(object)
object |
epi_kaiser object. |
data.frame
Create a publication-ready table summarizing the Kaiser criterion results.
kaiser_table(object, digits = object$digits, retain_label = "Yes")kaiser_table(object, digits = object$digits, retain_label = "Yes")
object |
An object of class |
digits |
Number of decimal places. |
retain_label |
Label for retained components. |
A data.frame.
Load Kaiser Object
load_kaiser(file)load_kaiser(file)
file |
RDS filename. |
Object of class epi_kaiser.
Draws a publication-quality heatmap of factor loadings.
loading_heatmap(object, cutoff = 0.3, absolute = FALSE, digits = 2)loading_heatmap(object, cutoff = 0.3, absolute = FALSE, digits = 2)
object |
Object of class |
cutoff |
Minimum loading to display. |
absolute |
Logical. Plot absolute loadings? |
digits |
Number of decimals. |
ggplot object.
set.seed(123) latent <- rnorm(200) example_data <- data.frame( Q1 = 0.8 * latent + rnorm(200, sd = 0.5), Q2 = 0.8 * latent + rnorm(200, sd = 0.5), Q3 = 0.7 * latent + rnorm(200, sd = 0.5), Q4 = 0.7 * latent + rnorm(200, sd = 0.5), Q5 = 0.6 * latent + rnorm(200, sd = 0.5) ) fit <- efa( example_data, items = paste0("Q", 1:5), nfactors = 1 ) loading_heatmap(fit)set.seed(123) latent <- rnorm(200) example_data <- data.frame( Q1 = 0.8 * latent + rnorm(200, sd = 0.5), Q2 = 0.8 * latent + rnorm(200, sd = 0.5), Q3 = 0.7 * latent + rnorm(200, sd = 0.5), Q4 = 0.7 * latent + rnorm(200, sd = 0.5), Q5 = 0.6 * latent + rnorm(200, sd = 0.5) ) fit <- efa( example_data, items = paste0("Q", 1:5), nfactors = 1 ) loading_heatmap(fit)
Demonstrates a complete workflow for dimensionality assessment using Velicer's Minimum Average Partial (MAP) test.
map_analysis_example()map_analysis_example()
The example generates simulated questionnaire data containing an underlying latent component structure and applies both the original and revised MAP criteria.
A named list containing:
Simulated questionnaire data.
Results from the original MAP criterion.
Results from the revised MAP criterion.
A comparison table of recommendations.
example <- map_analysis_example() example$original summary(example$original) map_table(example$original) map_eigenvalue_table(example$original) plot(example$original) report_map(example$original)example <- map_analysis_example() example$original summary(example$original) map_table(example$original) map_eigenvalue_table(example$original) plot(example$original) report_map(example$original)
Returns eigenvalues and explained-variance information from an '"epi_map"' object.
map_eigenvalue_table(x, digits = 4L, percentage = FALSE)map_eigenvalue_table(x, digits = 4L, percentage = FALSE)
x |
An object of class '"epi_map"'. |
digits |
Number of decimal places used for rounding. |
percentage |
Logical. If 'TRUE', variance proportions are expressed as percentages. |
A data frame containing component numbers, eigenvalues, variance proportions, and cumulative variance.
fit <- map_test(USArrests) map_eigenvalue_table(fit)fit <- map_test(USArrests) map_eigenvalue_table(fit)
Generates a concise textual interpretation of the dimensionality recommendation from Velicer's MAP test.
map_interpretation(x, include_value = TRUE, digits = 4L)map_interpretation(x, include_value = TRUE, digits = 4L)
x |
An object of class '"epi_map"'. |
include_value |
Logical. If 'TRUE', includes the minimum MAP criterion value in the interpretation. |
digits |
Number of decimal places used for the MAP value. |
A character string containing the interpretation.
fit <- map_test(USArrests) map_interpretation(fit)fit <- map_test(USArrests) map_interpretation(fit)
Creates a compact one-row summary suitable for manuscripts, supplementary tables, or export.
map_report_table(x, digits = 4L)map_report_table(x, digits = 4L)
x |
An object of class '"epi_map"'. |
digits |
Number of decimal places used for numeric values. |
A one-row data frame summarizing the MAP analysis.
fit <- map_test(USArrests) map_report_table(fit)fit <- map_test(USArrests) map_report_table(fit)
Extracts a publication-friendly table of MAP criterion values from an '"epi_map"' object.
map_table(x, digits = 4L, labels = TRUE)map_table(x, digits = 4L, labels = TRUE)
x |
An object of class '"epi_map"'. |
digits |
Number of decimal places used to round the MAP criterion. |
labels |
Logical. If 'TRUE', adds human-readable recommendation labels. |
A data frame containing the MAP results.
fit <- map_test(USArrests) map_table(fit)fit <- map_test(USArrests) map_table(fit)
Performs Velicer's Minimum Average Partial (MAP) test to estimate the optimal number of components to retain in dimensionality assessment.
map_test( data, method = c("original", "revised"), correlation = c("pearson", "spearman", "kendall"), use = "pairwise.complete.obs", is_corr = FALSE, max_components = NULL, tolerance = sqrt(.Machine$double.eps), ... )map_test( data, method = c("original", "revised"), correlation = c("pearson", "spearman", "kendall"), use = "pairwise.complete.obs", is_corr = FALSE, max_components = NULL, tolerance = sqrt(.Machine$double.eps), ... )
data |
A numeric data frame or matrix containing observations in rows and variables in columns. Alternatively, a correlation matrix when 'is_corr = TRUE'. |
method |
Character string specifying the MAP criterion. One of '"original"' or '"revised"'. The original criterion uses squared partial correlations, whereas the revised criterion uses fourth-power partial correlations. |
correlation |
Character string specifying the correlation coefficient used when 'data' contains raw observations. Currently '"pearson"' and '"spearman"' are supported. |
use |
Character string specifying the missing-value handling method passed to [stats::cor()]. Common options include '"everything"', '"complete.obs"', and '"pairwise.complete.obs"'. |
is_corr |
Logical. If 'TRUE', 'data' is treated as a correlation matrix. If 'FALSE', a correlation matrix is computed from the raw data. |
max_components |
Optional integer specifying the maximum number of components to evaluate. By default, up to 'p - 1' components are considered, where 'p' is the number of variables. |
tolerance |
Numeric tolerance used when handling very small eigenvalues and numerical instability. |
... |
Additional arguments reserved for future extensions. |
The MAP procedure sequentially partials principal components from a correlation matrix. After each component is removed, the average squared partial correlation among variables is calculated. The number of components associated with the minimum average partial correlation is selected as the recommended dimensionality.
A revised MAP criterion based on the average fourth power of the partial correlations is also available.
Velicer's MAP procedure begins with the original correlation matrix and computes an average measure of the off-diagonal correlations. Principal components are then sequentially removed. At each step, a residual covariance matrix is reconstructed and standardized to obtain a partial correlation matrix.
For the original MAP criterion, the statistic at step is the mean
squared off-diagonal partial correlation.
For the revised MAP criterion, the statistic is the mean fourth power of the off-diagonal partial correlations.
The recommended number of components corresponds to the step with the smallest MAP statistic. Step zero represents the unpartialled correlation matrix and therefore allows the procedure to recommend zero components.
The MAP test is commonly used alongside parallel analysis when determining the dimensionality of questionnaire and psychometric data.
An object of class '"epi_map"' containing:
Recommended number of components.
Minimum MAP statistic.
MAP criterion used.
A data frame containing the number of partialled components and corresponding MAP statistics.
Eigenvalues of the input correlation matrix.
Correlation matrix used in the analysis.
Analysis settings.
Information about the input data.
Matched function call.
Velicer, W. F. (1976). Determining the number of components from the matrix of partial correlations. Psychometrika, 41, 321-327.
Velicer, W. F., Eaton, C. A., & Fava, J. L. (2000). Construct explication through factor or component analysis: A review and evaluation of alternative procedures for determining the number of factors or components. In R. D. Goffin & E. Helmes (Eds.), Problems and Solutions in Human Assessment.
[parallel_analysis()]
set.seed(123) dat <- data.frame( item1 = rnorm(300), item2 = rnorm(300), item3 = rnorm(300), item4 = rnorm(300), item5 = rnorm(300) ) # Original MAP fit <- map_test(dat) fit # Revised MAP fit_revised <- map_test( dat, method = "revised" ) fit_revised # Correlation matrix input R <- cor(dat) fit_cor <- map_test( R, is_corr = TRUE )set.seed(123) dat <- data.frame( item1 = rnorm(300), item2 = rnorm(300), item3 = rnorm(300), item4 = rnorm(300), item5 = rnorm(300) ) # Original MAP fit <- map_test(dat) fit # Revised MAP fit_revised <- map_test( dat, method = "revised" ) fit_revised # Correlation matrix input R <- cor(dat) fit_cor <- map_test( R, is_corr = TRUE )
Number of Retained Factors
nfactors(x, ...)nfactors(x, ...)
x |
An object of class |
... |
Additional arguments passed to other methods or currently unused. |
A single non-negative integer giving the number of factors retained by
the Kaiser criterion. For an object of class epi_kaiser, this
value is obtained from the nfactors component of the object.
Performs Horn's parallel analysis to estimate the number of principal components or common factors to retain. Observed eigenvalues are compared with eigenvalues obtained from simulated random datasets.
parallel_analysis( data, analysis = c("pca", "fa"), correlation = c("auto", "pearson", "spearman", "polychoric", "tetrachoric", "mixed"), n_iter = 1000L, criterion = c("percentile", "mean"), percentile = 95, extraction = "minres", use = "pairwise.complete.obs", n_cores = 1L, seed = NULL, simulate = c("normal", "permutation"), adjust_pd = TRUE, diagnostics = TRUE, progress = interactive(), verbose = TRUE, ... )parallel_analysis( data, analysis = c("pca", "fa"), correlation = c("auto", "pearson", "spearman", "polychoric", "tetrachoric", "mixed"), n_iter = 1000L, criterion = c("percentile", "mean"), percentile = 95, extraction = "minres", use = "pairwise.complete.obs", n_cores = 1L, seed = NULL, simulate = c("normal", "permutation"), adjust_pd = TRUE, diagnostics = TRUE, progress = interactive(), verbose = TRUE, ... )
data |
A data frame, matrix, or correlation matrix. |
analysis |
Character. Either |
correlation |
Character. Correlation method. One of
|
n_iter |
Integer. Number of random datasets to simulate. |
criterion |
Character. Retention criterion used to compare observed
and simulated eigenvalues. Either |
percentile |
Numeric. Percentile of simulated eigenvalues used as the retention threshold. Must be strictly between 0 and 100. |
extraction |
Character. Factor extraction method passed to
|
use |
Character. Missing-value handling passed to |
n_cores |
Integer. Number of CPU cores. Values greater than 1 enable multicore execution on supported platforms. |
seed |
Integer or NULL. Random seed used for reproducible simulations. |
simulate |
Character. Simulation strategy. Either
|
adjust_pd |
Logical. If TRUE, non-positive-definite correlation matrices are adjusted. |
diagnostics |
Logical. If TRUE, diagnostic information is calculated. |
progress |
Logical. If TRUE, display progress in serial execution. |
verbose |
Logical. If TRUE, print informative messages. |
... |
Additional arguments passed to correlation routines where appropriate. |
The function supports PCA and factor-analysis retention criteria, Pearson, Spearman, polychoric, tetrachoric, and mixed correlation matrices, serial and multicore simulation, reproducible random-number generation, and optional diagnostic information.
An object of class "epi_parallel".
Generates a human-readable interpretation of an
"epi_parallel" object.
parallel_interpret( x, style = c("brief", "publication", "detailed"), digits = 3 )parallel_interpret( x, style = c("brief", "publication", "detailed"), digits = 3 )
x |
An object of class |
style |
Character string specifying the reporting style. Supported
values are |
digits |
Number of decimal places used when reporting eigenvalues. |
Three reporting styles are available:
"brief"Returns a concise statement of the recommended number of dimensions.
"publication"Returns manuscript-ready results text.
"detailed"Returns a more detailed interpretation including analysis settings, retention criterion, retained indices, and recommendation.
A character scalar containing the interpretation.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) parallel_interpret(result)set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) parallel_interpret(result)
Creates a plot comparing the observed eigenvalues from an exploratory factor analysis with simulated reference eigenvalues from Horn's parallel analysis. The plot can be used to assess the number of factors that should be retained.
parallel_plot(object)parallel_plot(object)
object |
An object of class |
A ggplot object. The plot displays observed eigenvalues and
simulated reference eigenvalues across components or factors. Components
for which the observed eigenvalue exceeds the relevant simulated reference
value are candidates for retention.
Generates a structured report from an "epi_parallel" object suitable
for manuscript preparation, thesis reporting, technical reports, or
reproducible analysis pipelines.
parallel_report( x, digits = 3, include_variance = TRUE, include_retention = TRUE )parallel_report( x, digits = 3, include_variance = TRUE, include_retention = TRUE )
x |
An object of class |
digits |
Number of decimal places used in reported numeric values. |
include_variance |
Logical. Whether to include the variance table. |
include_retention |
Logical. Whether to include the retention table. |
The returned object contains methods text, results text, interpretation, recommendation, analysis settings, and publication-ready tables.
An object of class "epi_parallel_report" containing:
Methods-section text.
Results-section text.
Detailed interpretation.
Recommended dimensional solution.
One-row analysis summary table.
Component- or factor-level results table.
Optional variance-explained table.
Optional retention-decision table.
Analysis settings.
Analysis metadata.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) report <- parallel_report(result)set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) report <- parallel_report(result)
Extracts selected narrative sections from an
"epi_parallel_report" object.
parallel_report_text( x, section = c("all", "methods", "results", "interpretation", "recommendation") )parallel_report_text( x, section = c("all", "methods", "results", "interpretation", "recommendation") )
x |
An object of class |
section |
Character string specifying the report section to extract.
Supported values are |
A character scalar.
Creates a table focused on the component or factor retention decision.
parallel_retention_table(x, digits = 3)parallel_retention_table(x, digits = 3)
x |
An object of class |
digits |
Number of decimal places. |
A data frame.
Creates a compact one-row summary of the parallel analysis.
parallel_summary_table(x)parallel_summary_table(x)
x |
An object of class |
A one-row data frame.
Extracts a clean component-level results table from an
"epi_parallel" object.
parallel_table(x, digits = 3, include_decision = TRUE)parallel_table(x, digits = 3, include_decision = TRUE)
x |
An object of class |
digits |
Number of decimal places used for rounding numeric values. |
include_decision |
Logical. Include a human-readable retention decision column. |
A data frame containing parallel analysis results.
Creates a table containing observed eigenvalues, percentage variance explained, cumulative variance, and retention decisions.
parallel_variance_table(x, digits = 2)parallel_variance_table(x, digits = 2)
x |
An object of class |
digits |
Number of decimal places. |
A data frame.
Eigenvalue Bar Plot
plot_eigenvalues(object)plot_eigenvalues(object)
object |
epi_kaiser object. |
A ggplot object containing a bar plot of the eigenvalues from the
epi_kaiser object. Each bar represents the eigenvalue associated
with a component or factor, allowing the relative magnitude of the
eigenvalues to be visually assessed.
Plot Dispatcher
plot_kaiser(object, which = c("scree", "eigenvalues", "variance"))plot_kaiser(object, which = c("scree", "eigenvalues", "variance"))
object |
epi_kaiser object. |
which |
Character string: "scree", "eigenvalues", "variance". |
The plot generated for the selected value of which. If
which = "scree", which = "eigenvalues", or
which = "variance", the corresponding plot is displayed.
The function returns the result invisibly, where applicable, primarily
for its plotting side effect.
Creates a plot showing the proportion of variance explained by each retained or available component or factor.
plot_variance(object)plot_variance(object)
object |
An object containing the factor or component analysis results required for the plot. |
A plot showing the proportion of variance explained by each component or factor. The plot is generated for visual interpretation of the contribution of each component or factor and is returned invisibly, where applicable.
Produces publication-ready EFA graphics.
## S3 method for class 'epi_efa' plot(x, type = c("scree", "parallel"), ...)## S3 method for class 'epi_efa' plot(x, type = c("scree", "parallel"), ...)
x |
Object of class |
type |
Plot type. One of:
|
... |
Additional arguments passed to the underlying function or method. |
A plot.
Creates a scree plot with the Kaiser cut-off (Eigenvalue = 1).
## S3 method for class 'epi_kaiser' plot( x, type = c("base", "ggplot"), show_cutoff = TRUE, show_labels = TRUE, point_size = 19, line_size = 2, ... )## S3 method for class 'epi_kaiser' plot( x, type = c("base", "ggplot"), show_cutoff = TRUE, show_labels = TRUE, point_size = 19, line_size = 2, ... )
x |
An object of class |
type |
Plot type ("base" or "ggplot"). |
show_cutoff |
Logical; draw Eigenvalue = 1 line. |
show_labels |
Logical; display eigenvalue labels. |
point_size |
Point size. |
line_size |
Line width. |
... |
Additional arguments passed to the underlying function or method. |
For type = "base", no return value. The function is called for its
side effect of producing a scree plot showing the eigenvalues and the
Kaiser cut-off at Eigenvalue = 1. For type = "ggplot", returns a
ggplot object representing the same scree plot, which can be
further modified or displayed.
Creates a base R plot for an object returned by [map_test()].
## S3 method for class 'epi_map' plot( x, type = c("map", "eigenvalues"), main = NULL, xlab = NULL, ylab = NULL, highlight = TRUE, show_line = TRUE, show_label = TRUE, ... )## S3 method for class 'epi_map' plot( x, type = c("map", "eigenvalues"), main = NULL, xlab = NULL, ylab = NULL, highlight = TRUE, show_line = TRUE, show_label = TRUE, ... )
x |
An object of class '"epi_map"'. |
type |
Character string specifying the plot type. One of '"map"' or '"eigenvalues"'. |
main |
Optional character string specifying the plot title. |
xlab |
Optional character string specifying the x-axis label. |
ylab |
Optional character string specifying the y-axis label. |
highlight |
Logical. If 'TRUE', highlights the recommended number of components. |
show_line |
Logical. If 'TRUE', draws a vertical reference line at the recommended number of components. |
show_label |
Logical. If 'TRUE', displays a text label identifying the recommended number of components. |
... |
Additional graphical parameters passed to [graphics::plot()]. |
The default plot displays the MAP criterion across the number of partialled components. The recommended number of components is highlighted at the minimum MAP value.
An eigenvalue scree plot can also be requested.
The input object 'x', invisibly.
set.seed(123) dat <- matrix( rnorm(1000), ncol = 10 ) fit <- map_test(dat) plot(fit) plot( fit, type = "eigenvalues" )set.seed(123) dat <- matrix( rnorm(1000), ncol = 10 ) fit <- map_test(dat) plot(fit) plot( fit, type = "eigenvalues" )
Creates a base R visualization of Horn's Parallel Analysis results.
## S3 method for class 'epi_parallel' plot( x, type = c("parallel", "scree", "variance", "retention"), reference = c("criterion", "percentile", "mean", "both"), main = NULL, xlab = "Component / Factor", ylab = NULL, legend = TRUE, ... )## S3 method for class 'epi_parallel' plot( x, type = c("parallel", "scree", "variance", "retention"), reference = c("criterion", "percentile", "mean", "both"), main = NULL, xlab = "Component / Factor", ylab = NULL, legend = TRUE, ... )
x |
An object of class |
type |
Character string specifying the plot type. Supported values are
|
reference |
Character string specifying the simulated reference series
for the parallel plot. Supported values are |
main |
Optional plot title. |
xlab |
Label for the x-axis. |
ylab |
Optional label for the y-axis. |
legend |
Logical. If |
... |
Additional graphical parameters passed to plotting functions. |
The default plot compares observed eigenvalues with simulated reference eigenvalues. Components or factors are retained when their observed eigenvalues exceed the selected simulated reference criterion.
Invisibly returns x.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) plot(result) plot(result, type = "parallel") plot(result, type = "variance") plot(result, type = "retention") plot(result, reference = "both")set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) plot(result) plot(result, type = "parallel") plot(result, type = "variance") plot(result, type = "retention") plot(result, reference = "both")
Print EFA Results
## S3 method for class 'epi_efa' print(x, digits = 3, ...)## S3 method for class 'epi_efa' print(x, digits = 3, ...)
x |
Object of class |
digits |
Number of decimal places. |
... |
Additional arguments passed to the underlying function or method. |
Prints EFA summary.
Print Kaiser Criterion Results
## S3 method for class 'epi_kaiser' print(x, digits = x$digits, ...)## S3 method for class 'epi_kaiser' print(x, digits = x$digits, ...)
x |
An object of class |
digits |
Integer specifying the number of decimal places used when displaying numeric results. |
... |
Additional arguments passed to other methods or currently unused. |
No visible return value. The epi_kaiser object is returned
invisibly after a formatted summary of the Kaiser criterion results is
printed to the console. The printed output summarizes the eigenvalue-based
factor-retention results.
Prints a concise summary of the results from Velicer's Minimum Average Partial (MAP) test.
## S3 method for class 'epi_map' print(x, digits = 4L, ...)## S3 method for class 'epi_map' print(x, digits = 4L, ...)
x |
An object of class '"epi_map"'. |
digits |
Number of significant digits used when printing numeric results. |
... |
Additional arguments currently ignored. |
The input object 'x', invisibly.
set.seed(123) dat <- data.frame( item1 = rnorm(300), item2 = rnorm(300), item3 = rnorm(300), item4 = rnorm(300), item5 = rnorm(300) ) fit <- map_test(dat) print(fit)set.seed(123) dat <- data.frame( item1 = rnorm(300), item2 = rnorm(300), item3 = rnorm(300), item4 = rnorm(300), item5 = rnorm(300) ) fit <- map_test(dat) print(fit)
Prints a concise summary of a Horn's Parallel Analysis result produced by EpiQuestionR.
## S3 method for class 'epi_parallel' print(x, digits = max(3L, getOption("digits") - 3L), ...)## S3 method for class 'epi_parallel' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
An object of class |
digits |
Number of digits used when displaying numeric values. |
... |
Additional arguments passed to or from other methods. |
The print method reports the analysis method, number of variables, simulation settings, retention criterion, and the recommended number of components or factors.
Invisibly returns x.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) print(result)set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) print(result)
Prints a structured report generated by parallel_report().
## S3 method for class 'epi_parallel_report' print(x, ...)## S3 method for class 'epi_parallel_report' print(x, ...)
x |
An object of class |
... |
Additional arguments passed to or from other methods. |
Invisibly returns x.
Prints a formatted summary of an object returned by
summary.epi_parallel().
## S3 method for class 'summary_epi_parallel' print(x, digits = max(3L, getOption("digits") - 3L), ...)## S3 method for class 'summary_epi_parallel' print(x, digits = max(3L, getOption("digits") - 3L), ...)
x |
An object of class |
digits |
Number of digits used for numeric output. |
... |
Additional arguments passed to or from other methods. |
Invisibly returns x.
Prints a detailed summary of an object returned by 'summary.epi_map()'.
## S3 method for class 'summary.epi_map' print(x, digits = 4L, ...)## S3 method for class 'summary.epi_map' print(x, digits = 4L, ...)
x |
An object of class '"summary.epi_map"'. |
digits |
Number of significant digits used when displaying numeric results. |
... |
Additional arguments currently ignored. |
The input object 'x', invisibly.
Simulated questionnaire data included with EpiQuestionR.
A data frame with 100 rows and 5 variables:
Likert score (1-5)
Likert score (1-5)
Likert score (1-5)
Likert score (1-5)
Likert score (1-5)
Simulated data
data(questionnaire_data) head(questionnaire_data)data(questionnaire_data) head(questionnaire_data)
Reporting Sentence
report_kaiser(object)report_kaiser(object)
object |
epi_kaiser object. |
Character string.
Generates a publication-ready narrative report of a Velicer Minimum Average Partial (MAP) analysis.
report_map( x, style = c("standard", "apa", "brief"), digits = 4L, include_sample = TRUE, include_method = TRUE )report_map( x, style = c("standard", "apa", "brief"), digits = 4L, include_sample = TRUE, include_method = TRUE )
x |
An object of class '"epi_map"'. |
style |
Character string specifying the reporting style. One of '"standard"', '"apa"', or '"brief"'. |
digits |
Number of decimal places used when reporting the MAP value. |
include_sample |
Logical. If 'TRUE', includes the number of observations when available. |
include_method |
Logical. If 'TRUE', includes information about the correlation and MAP methods. |
A character string containing a report-ready interpretation.
set.seed(123) dat <- matrix( rnorm(1000), ncol = 10 ) fit <- map_test(dat) report_map(fit) report_map( fit, style = "apa" )set.seed(123) dat <- matrix( rnorm(1000), ncol = 10 ) fit <- map_test(dat) report_map(fit) report_map( fit, style = "apa" )
Residual Correlation Matrix
residual_matrix(object)residual_matrix(object)
object |
epi_efa object. |
Matrix.
Extract the indices of components retained by the Kaiser criterion.
retained_components(object)retained_components(object)
object |
An object of class |
An integer vector containing the indices of retained components.
RMSEA
rmsea(object)rmsea(object)
object |
epi_efa object. |
Numeric.
RMSR
rmsr(object)rmsr(object)
object |
epi_efa object. |
Numeric.
Export a publication-quality communality plot.
save_communality_plot( object, filename = tempfile(pattern = "communality_plot_", fileext = ".tiff"), width = 6, height = 5, dpi = 600 )save_communality_plot( object, filename = tempfile(pattern = "communality_plot_", fileext = ".tiff"), width = 6, height = 5, dpi = 600 )
object |
epi_efa object. |
filename |
Output filename. |
width |
Width in inches. |
height |
Height in inches. |
dpi |
Resolution. |
Invisibly returns the filename.
Save EFA Plot
save_efa_plot( object, filename = tempfile(pattern = "efa_plot_", fileext = ".tiff"), type = "scree", width = 6, height = 5, dpi = 600 )save_efa_plot( object, filename = tempfile(pattern = "efa_plot_", fileext = ".tiff"), type = "scree", width = 6, height = 5, dpi = 600 )
object |
An object of class |
filename |
Character string giving the output filename. If omitted, a temporary file is created automatically. |
type |
Plot type. |
width |
Width in inches. |
height |
Height in inches. |
dpi |
Resolution. |
Invisibly returns a character string containing the path to the saved plot file. The function is primarily called for its side effect of writing the selected EFA plot to the specified output file.
Saves the eigenvalue plot to an image file.
save_eigenvalue_plot( object, filename = tempfile(pattern = "eigenvalues_", fileext = ".tiff"), width = 6, height = 5, dpi = 600 )save_eigenvalue_plot( object, filename = tempfile(pattern = "eigenvalues_", fileext = ".tiff"), width = 6, height = 5, dpi = 600 )
object |
An object of class |
filename |
Character. Output filename. |
width |
Numeric. Width of the saved plot in inches. |
height |
Numeric. Height of the saved plot in inches. |
dpi |
Numeric. Resolution of the saved plot in dots per inch. |
Invisibly returns the saved plot.
Saves the factor correlation plot to an image file.
save_factor_correlation_plot( object, filename = tempfile(pattern = "factor_correlation_", fileext = ".tiff"), width = 6, height = 6, dpi = 600 )save_factor_correlation_plot( object, filename = tempfile(pattern = "factor_correlation_", fileext = ".tiff"), width = 6, height = 6, dpi = 600 )
object |
An object of class |
filename |
Character. Output filename. |
width |
Numeric. Width of the saved plot in inches. |
height |
Numeric. Height of the saved plot in inches. |
dpi |
Numeric. Resolution of the saved plot in dots per inch. |
Invisibly returns the saved plot.
Saves the complete epi_kaiser object to an RDS file.
save_kaiser( object, file = tempfile(pattern = "kaiser_results_", fileext = ".rds") )save_kaiser( object, file = tempfile(pattern = "kaiser_results_", fileext = ".rds") )
object |
An object of class |
file |
Character. Output RDS filename. |
Invisibly returns the normalized output filename.
Save Loading Heatmap
save_loading_heatmap( object, filename = tempfile(pattern = "loading_heatmap_", fileext = ".tiff"), width = 7, height = 6, dpi = 600 )save_loading_heatmap( object, filename = tempfile(pattern = "loading_heatmap_", fileext = ".tiff"), width = 7, height = 6, dpi = 600 )
object |
epi_efa object. |
filename |
Character string giving the output filename. If omitted, a temporary file is created automatically. |
width |
Width in inches. |
height |
Height in inches. |
dpi |
Resolution. |
Invisibly returns the normalized path to the saved heatmap file as a character string. The function is primarily called for its side effect of writing the loading heatmap to the specified output file.
Export a publication-quality uniqueness plot.
save_uniqueness_plot( object, filename = tempfile(pattern = "uniqueness_plot_", fileext = ".tiff"), width = 7, height = 6, dpi = 600 )save_uniqueness_plot( object, filename = tempfile(pattern = "uniqueness_plot_", fileext = ".tiff"), width = 7, height = 6, dpi = 600 )
object |
Object of class |
filename |
Output filename. |
width |
Plot width (inches). |
height |
Plot height (inches). |
dpi |
Resolution. |
Invisibly returns the filename.
Save the variance explained plot as a publication-quality figure.
save_variance_explained_plot( object, filename = tempfile(pattern = "variance_explained_", fileext = ".tiff"), width = 7, height = 5, dpi = 600 )save_variance_explained_plot( object, filename = tempfile(pattern = "variance_explained_", fileext = ".tiff"), width = 7, height = 5, dpi = 600 )
object |
Object of class |
filename |
Output filename. |
width |
Width (inches). |
height |
Height (inches). |
dpi |
Resolution. |
Invisibly returns the filename.
Draw a scree plot for exploratory factor analysis or Kaiser criterion results.
scree_plot(object) scree_plot(object)scree_plot(object) scree_plot(object)
object |
An object of class |
For an epi_kaiser object, a ggplot object. For an
epi_efa object, the plot is drawn using base graphics.
Repeats Horn's parallel analysis across alternative simulation counts, percentile thresholds, or analysis specifications.
sensitivity_analysis( data, percentiles = c(0.9, 0.95, 0.99), n_iters = c(100, 500, 1000), analyses = c("pca", "fa"), correlation = "auto", seed = 123, n_cores = 1L, verbose = FALSE, ... )sensitivity_analysis( data, percentiles = c(0.9, 0.95, 0.99), n_iters = c(100, 500, 1000), analyses = c("pca", "fa"), correlation = "auto", seed = 123, n_cores = 1L, verbose = FALSE, ... )
data |
A data frame, matrix, or correlation matrix. |
percentiles |
Numeric vector of percentile thresholds. |
n_iters |
Integer vector of simulation counts. |
analyses |
Character vector containing |
correlation |
Character. Correlation method. |
seed |
Integer or NULL. |
n_cores |
Integer. Number of CPU cores. |
verbose |
Logical. |
... |
Additional arguments passed to |
A data frame of sensitivity-analysis results with class
"epi_parallel_sensitivity".
Generates a reproducible synthetic questionnaire dataset with a latent multidimensional correlation structure. The resulting data can be used to demonstrate parallel analysis and related dimensionality functions in EpiQuestionR.
simulate_parallel_data( n = 300, n_items = 12, n_factors = 3, loading = 0.7, seed = NULL, ordinal = FALSE, categories = 5 )simulate_parallel_data( n = 300, n_items = 12, n_factors = 3, loading = 0.7, seed = NULL, ordinal = FALSE, categories = 5 )
n |
Number of respondents. |
n_items |
Number of questionnaire items. |
n_factors |
Number of latent factors used to generate the data. |
loading |
Numeric value controlling the approximate primary factor loading. |
seed |
Optional integer random seed. |
ordinal |
Logical. If |
categories |
Number of ordinal response categories when
|
This function is intended for examples, demonstrations, tutorials, and package testing. It should not be used as a substitute for real data in substantive analyses.
A data frame with n rows and n_items columns.
questionnaire_data <- simulate_parallel_data( n = 300, n_items = 12, n_factors = 3, seed = 123 ) head(questionnaire_data)questionnaire_data <- simulate_parallel_data( n = 300, n_items = 12, n_factors = 3, seed = 123 ) head(questionnaire_data)
Summary of EFA
## S3 method for class 'epi_efa' summary(object, digits = 3, cutoff = 0.3, ...)## S3 method for class 'epi_efa' summary(object, digits = 3, cutoff = 0.3, ...)
object |
epi_efa object. |
digits |
Number of decimals. |
cutoff |
Loading cutoff. |
... |
Additional arguments passed to the underlying function or method. |
Prints detailed summary.
Summarize a Kaiser Criterion Analysis
## S3 method for class 'epi_kaiser' summary(object, digits = object$digits, ...)## S3 method for class 'epi_kaiser' summary(object, digits = object$digits, ...)
object |
An object of class |
digits |
Number of decimal places to display. |
... |
Additional arguments, currently unused. |
An object of class summary.epi_kaiser.
Creates a detailed summary of an '"epi_map"' object produced by [map_test()].
## S3 method for class 'epi_map' summary(object, ...)## S3 method for class 'epi_map' summary(object, ...)
object |
An object of class '"epi_map"'. |
... |
Additional arguments currently ignored. |
An object of class '"summary.epi_map"' containing the MAP recommendation, MAP criterion values, eigenvalue information, settings, metadata, and original function call.
set.seed(123) dat <- data.frame( item1 = rnorm(300), item2 = rnorm(300), item3 = rnorm(300), item4 = rnorm(300), item5 = rnorm(300) ) fit <- map_test(dat) summary(fit)set.seed(123) dat <- data.frame( item1 = rnorm(300), item2 = rnorm(300), item3 = rnorm(300), item4 = rnorm(300), item5 = rnorm(300) ) fit <- map_test(dat) summary(fit)
Produces a structured summary of a Horn's Parallel Analysis result.
## S3 method for class 'epi_parallel' summary(object, ...)## S3 method for class 'epi_parallel' summary(object, ...)
object |
An object of class |
... |
Additional arguments passed to or from other methods. |
The returned summary includes analysis settings, observed eigenvalues, simulated reference eigenvalues, retention decisions, and optional variance information.
An object of class "summary_epi_parallel" containing:
The original function call.
Parallel analysis settings.
Number of variables analyzed.
Number of observations, when available.
Recommended number of retained components or factors.
Indices of retained components or factors.
Component-level parallel analysis results.
Optional variance-explained table.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) summary(result)set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) summary(result)
Convert a epi_kaiser object into a tidy tibble.
## S3 method for class 'epi_kaiser' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)## S3 method for class 'epi_kaiser' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An object of class |
conf.int |
Ignored. |
conf.level |
Ignored. |
... |
Additional arguments passed to the underlying function or method. |
A tibble with one row per component.
Converts the component-level results of a Velicer Minimum Average Partial (MAP) test into a tidy data frame.
## S3 method for class 'epi_map' tidy(x, ...)## S3 method for class 'epi_map' tidy(x, ...)
x |
An object of class '"epi_map"'. |
... |
Additional arguments currently ignored. |
A data frame with one row for each number of partialled components. The output contains the component number, MAP criterion value, minimum indicator, recommendation indicator, and criterion used.
set.seed(123) dat <- matrix(rnorm(1000), ncol = 10) fit <- map_test(dat) generics::tidy(fit)set.seed(123) dat <- matrix(rnorm(1000), ncol = 10) fit <- map_test(dat) generics::tidy(fit)
Converts component- or factor-level results from Horn's Parallel Analysis into a tidy data frame.
## S3 method for class 'epi_parallel' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)## S3 method for class 'epi_parallel' tidy(x, conf.int = FALSE, conf.level = 0.95, ...)
x |
An object of class |
conf.int |
Logical. Included for compatibility with common broom-style workflows. Confidence intervals are not defined for standard parallel-analysis eigenvalue output and are therefore not added to the returned table. |
conf.level |
Numeric confidence level. Included for interface compatibility. Must be between 0 and 1. |
... |
Additional arguments. Currently unused. |
Each row represents one component or factor. The output includes observed eigenvalues, simulated mean eigenvalues, simulated percentile eigenvalues, the reference eigenvalue used for retention, the difference between the observed and reference eigenvalues, and the retention decision.
A data frame with one row per component or factor and columns:
Component or factor index.
Observed eigenvalue.
Mean simulated eigenvalue.
Percentile-based simulated eigenvalue.
Reference eigenvalue used for the retention decision.
Observed eigenvalue minus the reference eigenvalue.
Logical retention indicator.
Human-readable retention decision.
set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) generics::tidy(result)set.seed(123) dat <- data.frame( item1 = rnorm(30), item2 = rnorm(30), item3 = rnorm(30), item4 = rnorm(30), item5 = rnorm(30) ) result <- parallel_analysis(dat, n_iter = 100) generics::tidy(result)
Converts an object returned by 'summary.epi_map()' into a tidy component-level data frame.
## S3 method for class 'summary.epi_map' tidy(x, ...)## S3 method for class 'summary.epi_map' tidy(x, ...)
x |
An object of class '"summary.epi_map"'. |
... |
Additional arguments currently ignored. |
A tidy data frame.
Tucker Lewis Index
tli(object)tli(object)
object |
epi_efa object. |
Numeric.
Uniqueness
uniqueness(object)uniqueness(object)
object |
epi_efa object. |
Numeric vector.
Draw a publication-quality bar chart of item uniqueness values.
uniqueness_plot( object, sort = TRUE, horizontal = TRUE, fill = "#D95F02", title = "Uniqueness", digits = 2 )uniqueness_plot( object, sort = TRUE, horizontal = TRUE, fill = "#D95F02", title = "Uniqueness", digits = 2 )
object |
Object of class |
sort |
Logical. Sort uniqueness values from highest to lowest? |
horizontal |
Logical. Draw horizontal bars? |
fill |
Fill colour. |
title |
Plot title. |
digits |
Number of decimal places for labels. |
Uniqueness represents the proportion of variance not explained by the extracted common factors (Uniqueness = 1 - Communality).
A ggplot object.
set.seed(123) latent <- rnorm(200) example_data <- data.frame( Q1 = 0.8 * latent + rnorm(200, sd = 0.5), Q2 = 0.8 * latent + rnorm(200, sd = 0.5), Q3 = 0.7 * latent + rnorm(200, sd = 0.5), Q4 = 0.7 * latent + rnorm(200, sd = 0.5), Q5 = 0.6 * latent + rnorm(200, sd = 0.5) ) fit <- efa( example_data, items = paste0("Q", 1:5), nfactors = 1 ) uniqueness_plot(fit)set.seed(123) latent <- rnorm(200) example_data <- data.frame( Q1 = 0.8 * latent + rnorm(200, sd = 0.5), Q2 = 0.8 * latent + rnorm(200, sd = 0.5), Q3 = 0.7 * latent + rnorm(200, sd = 0.5), Q4 = 0.7 * latent + rnorm(200, sd = 0.5), Q5 = 0.6 * latent + rnorm(200, sd = 0.5) ) fit <- efa( example_data, items = paste0("Q", 1:5), nfactors = 1 ) uniqueness_plot(fit)
Variance Explained
variance_explained(x, ...)variance_explained(x, ...)
x |
An object of class |
... |
Additional arguments passed to other methods or currently unused. |
A numeric vector containing the proportion of total variance explained by
each component or factor in the epi_kaiser object. Each value
represents the relative contribution of the corresponding component or
factor to the total variance and can be used to assess its importance.
Draw a publication-quality plot showing the percentage of variance explained by each extracted factor and the cumulative percentage of variance explained.
variance_explained_plot( object, cumulative = TRUE, bar_fill = "#4C78A8", line_colour = "#D62728", point_colour = "#D62728", title = "Variance Explained" )variance_explained_plot( object, cumulative = TRUE, bar_fill = "#4C78A8", line_colour = "#D62728", point_colour = "#D62728", title = "Variance Explained" )
object |
Object of class |
cumulative |
Logical. Display cumulative variance line? |
bar_fill |
Fill colour for bars. |
line_colour |
Colour for cumulative variance line. |
point_colour |
Colour for cumulative variance points. |
title |
Plot title. |
A ggplot object.
set.seed(123) latent <- rnorm(200) example_data <- data.frame( Q1 = 0.8 * latent + rnorm(200, sd = 0.5), Q2 = 0.8 * latent + rnorm(200, sd = 0.5), Q3 = 0.7 * latent + rnorm(200, sd = 0.5), Q4 = 0.7 * latent + rnorm(200, sd = 0.5), Q5 = 0.6 * latent + rnorm(200, sd = 0.5) ) fit <- efa( example_data, items = paste0("Q", 1:5), nfactors = 1 ) variance_explained_plot(fit)set.seed(123) latent <- rnorm(200) example_data <- data.frame( Q1 = 0.8 * latent + rnorm(200, sd = 0.5), Q2 = 0.8 * latent + rnorm(200, sd = 0.5), Q3 = 0.7 * latent + rnorm(200, sd = 0.5), Q4 = 0.7 * latent + rnorm(200, sd = 0.5), Q5 = 0.6 * latent + rnorm(200, sd = 0.5) ) fit <- efa( example_data, items = paste0("Q", 1:5), nfactors = 1 ) variance_explained_plot(fit)
Extracts the variance explained from an exploratory factor analysis object.
## S3 method for class 'epi_efa' variance_explained(x, ...)## S3 method for class 'epi_efa' variance_explained(x, ...)
x |
An object of class |
... |
Additional arguments, currently unused. |
A data frame containing variance explained statistics.
Variance Explained Table
variance_table(object)variance_table(object)
object |
epi_kaiser object. |
data.frame