-
-
Notifications
You must be signed in to change notification settings - Fork 40
Running EFA from a correlation matrix #1119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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_analysisfunction can now directly acceptmatrixobjects 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 existingfactor_analysis.data.frameimplementation, 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
-
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. ↩
There was a problem hiding this 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.
R/factor_analysis.R
Outdated
|
|
||
|
|
||
| #' @export | ||
| factor_analysis.matrix <- factor_analysis.data.frame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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|
@gemini-code-assist review |
There was a problem hiding this 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.}
There was a problem hiding this 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.
man/reduce_parameters.Rd
Outdated
| \item{x}{A data frame or a statistical model. For \code{closes_component()}, the | ||
| output of the \code{principal_components()} function.} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man/reshape_loadings.Rd
Outdated
| \item{x}{A data frame or a statistical model. For \code{closes_component()}, the | ||
| output of the \code{principal_components()} function.} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #1118