Skip to content

Conversation

@strengejacke
Copy link
Member

Fixes #1118

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @strengejacke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request extends the factor_analysis function within the parameters package to support direct input of matrix objects, specifically enabling EFA to be run from a correlation matrix. This change enhances the function's flexibility and usability for researchers working with pre-computed correlation matrices.

Highlights

  • Enhanced Functionality: The factor_analysis function can now directly accept matrix objects as input, allowing users to perform Exploratory Factor Analysis (EFA) from a correlation matrix, addressing issue #1118.
  • Code Reusability: A new S3 method, factor_analysis.matrix, has been introduced which reuses the existing factor_analysis.data.frame implementation, promoting code efficiency and consistency.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request adds a method for performing factor analysis directly on a matrix, which enhances the flexibility of the factor_analysis function. A suggestion was made to add documentation to the new method.



#' @export
factor_analysis.matrix <- factor_analysis.data.frame
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Consider adding a brief description or documentation for this function, similar to what's done for factor_analysis.data.frame above. This will improve code maintainability and understanding.

#' @export
#' @description Factor analysis method for matrix inputs.
factor_analysis.matrix <- factor_analysis.data.frame

@strengejacke strengejacke requested a review from Copilot June 27, 2025 12:35
@strengejacke
Copy link
Member Author

@gemini-code-assist review

Copy link
Contributor

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 addresses issue #1118 by updating the default behavior of factor analysis and improving related documentation. The key changes include:

  • Changing the default rotation in factor_analysis() from "none" to "oblimin" and adding the factor_method parameter.
  • Introducing a new S3 method, factor_analysis.matrix, to support analyses using correlation matrices with additional arguments (n_obs and n_matrix).
  • Updating documentation and NEWS.md to reflect these API changes.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/testthat/test-pca.R Updated factor_analysis() invocation with explicit rotation value.
tests/testthat/test-factor_analysis.R Added tests for factor analysis using correlation matrices.
man/reshape_loadings.Rd Enhanced the parameter description to reference the component output.
man/reduce_parameters.Rd Updated documentation to mention principal_components() output.
man/principal_components.Rd Extended documentation and added alias for factor_analysis.matrix.
R/principal_components.R Modified doc-comments to include new parameter details.
R/factor_analysis.R Changed default rotation, added factor_method, and implemented matrix method.
NEWS.md Documented the default rotation change and new factor_analysis.matrix method.
NAMESPACE Registered the new S3 method for factor_analysis.matrix.
DESCRIPTION Version bump to 0.26.0.9.
Comments suppressed due to low confidence (2)

man/reshape_loadings.Rd:17

  • The documentation refers to 'closes_component()' while examples and other parts of the code use 'closest_component()'. Please update the function name for consistency.
output of the \code{principal_components()} function.}

man/principal_components.Rd:74

  • There is an inconsistency between 'closes_component()' in the parameter documentation and 'closest_component()' used in examples. Consider standardizing on one function name.
output of the \code{principal_components()} function.}

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the factor_analysis.matrix method to run EFA from a correlation matrix and changes the default rotation in factor_analysis to "oblimin". A critical issue was found in the implementation of the new factor_analysis.matrix method that leads to incorrect results when a correlation matrix is provided, and some minor documentation typos were identified. The logic in factor_analysis.matrix needs to be corrected.

Comment on lines 13 to 14
\item{x}{A data frame or a statistical model. For \code{closes_component()}, the
output of the \code{principal_components()} function.}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Typo: closes_component() should be closest_component().

\item{x}{A data frame or a statistical model. For \code{closest_component()}, the
output of the \code{principal_components()} function.}

Comment on lines 16 to 17
\item{x}{A data frame or a statistical model. For \code{closes_component()}, the
output of the \code{principal_components()} function.}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Typo: closes_component() should be closest_component().

\item{x}{A data frame or a statistical model. For \code{closest_component()}, the
output of the \code{principal_components()} function.}

@strengejacke strengejacke merged commit 7c633c7 into main Jun 27, 2025
17 of 23 checks passed
@strengejacke strengejacke deleted the strengejacke/issue1118 branch June 27, 2025 20:59
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.

Running EFA from a correlation matrix

2 participants