Skip to content

Conversation

@juliuspfadt
Copy link
Collaborator

the error is fixed with this PR: jasp-stats/jaspSem#318
but this adds more tests to check that standardization and invariance testing works

@juliuspfadt juliuspfadt requested a review from Copilot July 22, 2025 13:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes errors in the confirmatory factor analysis module and adds comprehensive tests for standardization and invariance testing functionality. The fix addresses an issue referenced in a related GitHub issue while expanding test coverage to ensure standardization and group invariance testing work correctly.

  • Fixes confirmatory factor analysis error handling and functionality
  • Adds extensive tests for factor loadings with bootstrapping, standardization and group invariance
  • Updates data handling functions for better covariance matrix processing

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/testthat/test-confirmatoryfactoranalysis.R Adds comprehensive test cases for standardization and invariance testing scenarios
jaspFactor.Rproj Updates project ID for the R project file
R/principalcomponentanalysis.R Improves covariance matrix data handling and processing
R/exploratoryfactoranalysis.R Updates option references and data reading flow
R/confirmatoryfactoranalysis.R Removes deprecated bootstrap function and fixes mean structure condition

} else {
dataset[] <- lapply(dataset, function(x) as.numeric(as.character(x)))
return(dataset)
return(.readDataSetToEnd(columns.as.numeric = unlist(options$variables)))
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line appears to be duplicated logic from the .pcaAndEfaHandleData function. Consider consolidating this data reading logic to avoid code duplication.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is already in a common function

Comment on lines +92 to +96
# it seems the column names are sorted alphabetically when all columns are read
# so we need to sort the column names to match the order of the variables
sortedIndices <- sort(as.numeric(gsub(".*_(\\d+)_.*", "\\1", colnames(dataset))))
sortedNames <- paste0("JaspColumn_", sortedIndices, "_Encoded")
dataset <- dataset[, sortedNames]
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment and the following sorting logic is duplicated from .pcaAndEfaDataCovarianceCheck function. Consider extracting this into a shared utility function to reduce code duplication.

Suggested change
# it seems the column names are sorted alphabetically when all columns are read
# so we need to sort the column names to match the order of the variables
sortedIndices <- sort(as.numeric(gsub(".*_(\\d+)_.*", "\\1", colnames(dataset))))
sortedNames <- paste0("JaspColumn_", sortedIndices, "_Encoded")
dataset <- dataset[, sortedNames]
dataset <- .sortDatasetColumns(dataset, options$variables)

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code is already in a common function shared between PCA and EFA.

.efaComputeResults <- function(modelContainer, dataset, options, ready) {

corMethod <- switch(options[["baseDecompositionOn"]],
corMethod <- switch(options[["analysisBasedOn"]],
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option name changed from 'baseDecompositionOn' to 'analysisBasedOn'. Ensure this change is intentional and that all related code and documentation are updated consistently.

Copilot uses AI. Check for mistakes.
Comment on lines +966 to 996
if (options$meanStructure || options$group != "") {

Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The condition has been expanded to include group analysis. Consider adding a comment explaining why intercepts are needed when group analysis is performed, as this may not be immediately obvious to future maintainers.

Suggested change
if (options$meanStructure || options$group != "") {
# Intercepts are included when group analysis is performed (options$group != "")
# to account for group-level differences in the model. This ensures that the
# model properly estimates group-specific means for the latent variables.
if (options$meanStructure || options$group != "") {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant