Skip to content

Conversation

@strengejacke
Copy link
Member

Fixes #136

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 significantly enhances the parameters R package by integrating robust support for psych::omega models. It involves a substantial refactoring of the model_parameters.omega function to provide a richer, more structured output, alongside improvements to the display and printing functionalities, ensuring that users can easily access and interpret the key results from their omega analyses.

Highlights

  • New Feature: psych::omega Model Support: This pull request introduces comprehensive support for psych::omega models, allowing their parameters to be processed and displayed within the parameters package.
  • Refactored model_parameters.omega Function: The core model_parameters.omega function has been significantly refactored. It now returns factor loadings as its primary output, while storing omega coefficients and variance summaries as attributes. This new structure provides a more flexible and detailed representation of the model results.
  • Enhanced Display and Print Methods: Dedicated display and print methods have been added or updated for parameters_omega and parameters_omega_summary classes. These methods now leverage existing EFA (Exploratory Factor Analysis) display logic for loadings and provide a more structured and informative output for omega coefficients and variance summaries, improving readability for users.
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

This pull request introduces support for psych::omega models, including a new model_parameters.omega method and S3 methods for printing and summarizing. I recommend removing the unused verbose argument and initializing caption1 and caption2 to NULL before the if blocks.

@strengejacke strengejacke requested a review from Copilot June 19, 2025 08:47

This comment was marked as outdated.

@strengejacke
Copy link
Member Author

@profandyfield

This is the current state. Maybe we can discuss the parameters related stuff for omega here. Anything important missing in this output? Other things will go into performance::model_performance().

model <- psych::omega(mtcars, nfactors = 3, plot = FALSE)
#> Loading required namespace: GPArotation

parameters::model_parameters(model)
#> # Rotated loadings from Omega (oblimin-rotation)
#> 
#> Variable |        g |   F1* |      F2* |       F3* |   h2 |   u2 |       p2 | Complexity
#> ----------------------------------------------------------------------------------------
#> mpg-     |     0.58 | -0.67 |     0.09 |      0.29 | 0.88 | 0.12 |     0.38 |       2.40
#> cyl      |     0.70 | -0.61 |     0.28 |      0.07 | 0.96 | 0.04 |     0.52 |       2.33
#> disp     |     0.59 | -0.71 |     0.18 |      0.11 | 0.89 | 0.11 |     0.39 |       2.13
#> hp       |     0.77 | -0.31 |     0.23 |      0.36 | 0.87 | 0.13 |     0.68 |       2.00
#> drat-    |     0.27 | -0.79 |     0.06 |     -0.07 | 0.71 | 0.29 |     0.10 |       1.26
#> wt       |     0.43 | -0.79 |    -0.04 |      0.31 | 0.91 | 0.09 |     0.20 |       1.87
#> qsec-    |     0.81 |  0.19 |     0.50 |      0.06 | 0.95 | 0.05 |     0.70 |       1.81
#> vs-      |     0.74 | -0.27 |     0.38 |      0.05 | 0.77 | 0.23 |     0.71 |       1.81
#> am-      | 8.38e-03 | -0.89 |    -0.15 | -9.51e-03 | 0.81 | 0.19 | 8.63e-05 |       1.06
#> gear     |     0.03 |  0.87 | 9.01e-03 |      0.32 | 0.87 | 0.13 | 9.03e-04 |       1.27
#> carb     |     0.68 |  0.06 |     0.10 |      0.63 | 0.87 | 0.13 |     0.53 |       2.06

parameters::model_parameters(model) |> summary()
#> # Omega Statistics
#> 
#> Statistic            | Coefficient
#> ----------------------------------
#> Alpha                |        0.88
#> G.6                  |        0.97
#> Omega (hierachical)  |        0.57
#> Omega (asymptotic H) |        0.58
#> Omega (total)        |        0.97
#> 
#> # Omega Coefficients
#> 
#> Composite | Omega (total) | Omega (hierarchical) | Omega (group)
#> ----------------------------------------------------------------
#> g         |          0.97 |                 0.57 |          0.26
#> F1*       |          0.90 |                 0.31 |          0.59
#> F2*       |          0.91 |                 0.69 |          0.22
#> F3*       |          0.87 |                 0.60 |          0.28
#> 
#> # Variances
#> 
#> Composite | Total (%) | General Factor (%) | Group Factor (%)
#> -------------------------------------------------------------
#> g         |     97.28 |              56.64 |            26.42
#> F1*       |     90.12 |              31.07 |            59.05
#> F2*       |     91.37 |              69.32 |            22.04
#> F3*       |     87.36 |              59.65 |            27.71

Created on 2025-06-19 with reprex v2.1.1

@strengejacke
Copy link
Member Author

Thresholds:

model <- psych::omega(mtcars, nfactors = 3, plot = FALSE)
#> Loading required namespace: GPArotation

parameters::model_parameters(model)
#> # Rotated loadings from Omega (oblimin-rotation)
#> 
#> Variable |        g |   F1* |      F2* |       F3* |   h2 |   u2 |       p2 | Complexity
#> ----------------------------------------------------------------------------------------
#> mpg-     |     0.58 | -0.67 |     0.09 |      0.29 | 0.88 | 0.12 |     0.38 |       2.40
#> cyl      |     0.70 | -0.61 |     0.28 |      0.07 | 0.96 | 0.04 |     0.52 |       2.33
#> disp     |     0.59 | -0.71 |     0.18 |      0.11 | 0.89 | 0.11 |     0.39 |       2.13
#> hp       |     0.77 | -0.31 |     0.23 |      0.36 | 0.87 | 0.13 |     0.68 |       2.00
#> drat-    |     0.27 | -0.79 |     0.06 |     -0.07 | 0.71 | 0.29 |     0.10 |       1.26
#> wt       |     0.43 | -0.79 |    -0.04 |      0.31 | 0.91 | 0.09 |     0.20 |       1.87
#> qsec-    |     0.81 |  0.19 |     0.50 |      0.06 | 0.95 | 0.05 |     0.70 |       1.81
#> vs-      |     0.74 | -0.27 |     0.38 |      0.05 | 0.77 | 0.23 |     0.71 |       1.81
#> am-      | 8.38e-03 | -0.89 |    -0.15 | -9.51e-03 | 0.81 | 0.19 | 8.63e-05 |       1.06
#> gear     |     0.03 |  0.87 | 9.01e-03 |      0.32 | 0.87 | 0.13 | 9.03e-04 |       1.27
#> carb     |     0.68 |  0.06 |     0.10 |      0.63 | 0.87 | 0.13 |     0.53 |       2.06

parameters::model_parameters(model, threshold = 0.3)
#> # Rotated loadings from Omega (oblimin-rotation)
#> 
#> Variable |    g |   F1* |  F2* |  F3* |   h2 | u2 |       p2 | Complexity
#> -------------------------------------------------------------------------
#> mpg-     | 0.58 | -0.67 |      |      | 0.88 |    |     0.38 |       2.40
#> cyl      | 0.70 | -0.61 |      |      | 0.96 |    |     0.52 |       2.33
#> disp     | 0.59 | -0.71 |      |      | 0.89 |    |     0.39 |       2.13
#> hp       | 0.77 | -0.31 |      | 0.36 | 0.87 |    |     0.68 |       2.00
#> drat-    |      | -0.79 |      |      | 0.71 |    |     0.10 |       1.26
#> wt       | 0.43 | -0.79 |      | 0.31 | 0.91 |    |     0.20 |       1.87
#> qsec-    | 0.81 |       | 0.50 |      | 0.95 |    |     0.70 |       1.81
#> vs-      | 0.74 |       | 0.38 |      | 0.77 |    |     0.71 |       1.81
#> am-      |      | -0.89 |      |      | 0.81 |    | 8.63e-05 |       1.06
#> gear     |      |  0.87 |      | 0.32 | 0.87 |    | 9.03e-04 |       1.27
#> carb     | 0.68 |       |      | 0.63 | 0.87 |    |     0.53 |       2.06

Created on 2025-06-19 with reprex v2.1.1

@strengejacke
Copy link
Member Author

And in markdown:

model <- psych::omega(mtcars, nfactors = 3, plot = FALSE)
#> Loading required namespace: GPArotation

parameters::model_parameters(model) |> insight::display()
Variable g F1* F2* F3* h2 u2 p2 Complexity
mpg- 0.58 -0.67 0.09 0.29 0.88 0.12 0.38 2.40
cyl 0.70 -0.61 0.28 0.07 0.96 0.04 0.52 2.33
disp 0.59 -0.71 0.18 0.11 0.89 0.11 0.39 2.13
hp 0.77 -0.31 0.23 0.36 0.87 0.13 0.68 2.00
drat- 0.27 -0.79 0.06 -0.07 0.71 0.29 0.10 1.26
wt 0.43 -0.79 -0.04 0.31 0.91 0.09 0.20 1.87
qsec- 0.81 0.19 0.50 0.06 0.95 0.05 0.70 1.81
vs- 0.74 -0.27 0.38 0.05 0.77 0.23 0.71 1.81
am- 8.38e-03 -0.89 -0.15 -9.51e-03 0.81 0.19 8.63e-05 1.06
gear 0.03 0.87 9.01e-03 0.32 0.87 0.13 9.03e-04 1.27
carb 0.68 0.06 0.10 0.63 0.87 0.13 0.53 2.06

Rotated loadings from Omega (oblimin-rotation)

parameters::model_parameters(model, threshold = 0.3) |> insight::display()
Variable g F1* F2* F3* h2 u2 p2 Complexity
mpg- 0.58 -0.67 0.88 0.38 2.40
cyl 0.70 -0.61 0.96 0.52 2.33
disp 0.59 -0.71 0.89 0.39 2.13
hp 0.77 -0.31 0.36 0.87 0.68 2.00
drat- -0.79 0.71 0.10 1.26
wt 0.43 -0.79 0.31 0.91 0.20 1.87
qsec- 0.81 0.50 0.95 0.70 1.81
vs- 0.74 0.38 0.77 0.71 1.81
am- -0.89 0.81 8.63e-05 1.06
gear 0.87 0.32 0.87 9.03e-04 1.27
carb 0.68 0.63 0.87 0.53 2.06

Rotated loadings from Omega (oblimin-rotation)

parameters::model_parameters(model) |> insight::display(threshold = 0.3)
Variable g F1* F2* F3* h2 u2 p2 Complexity
mpg- 0.58 -0.67 0.88 0.38 2.40
cyl 0.70 -0.61 0.96 0.52 2.33
disp 0.59 -0.71 0.89 0.39 2.13
hp 0.77 -0.31 0.36 0.87 0.68 2.00
drat- -0.79 0.71 0.10 1.26
wt 0.43 -0.79 0.31 0.91 0.20 1.87
qsec- 0.81 0.50 0.95 0.70 1.81
vs- 0.74 0.38 0.77 0.71 1.81
am- -0.89 0.81 8.63e-05 1.06
gear 0.87 0.32 0.87 9.03e-04 1.27
carb 0.68 0.63 0.87 0.53 2.06

Rotated loadings from Omega (oblimin-rotation)

Created on 2025-06-19 with reprex v2.1.1

@profandyfield
Copy link

nothing important missing that I can see .... looks great!

@strengejacke
Copy link
Member Author

Great! We can still add / modify things, if needed. Fit indices go into performance.

@strengejacke strengejacke requested a review from Copilot June 19, 2025 11:40
@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 adds support for psych::omega models by extending functionality across tests, documentation, and S3 methods for model parameters and factor scores.

  • Introduces new tests for omega models in testthat and updates snapshot files.
  • Updates function documentation, print methods, and S3 registrations to incorporate psych::omega support.
  • Bumps the package version to 0.26.0.5.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/testthat/test-factor_analysis.R Added tests for omega models using psych::omega
tests/testthat/_snaps/factor_analysis.md Updated snapshot tests to include omega model outputs
man/model_parameters.principal.Rd Revised documentation to mention psych::omega support
man/factor_scores.Rd Updated documentation for factor_scores to include omega models
R/utils_pca_efa.R Added and modified functions to handle omega summary formatting
R/print_md.R Added printing methods for omega summaries
R/methods_psych.R Updated model_parameters.omega to support omega, corrected test usage
R/factor_scores.R Added new S3 methods for omega model scores
R/display.R Registered built-in S3 display functions for omega
NEWS.md Updated news to reflect added support for Omega models
NAMESPACE Registered new S3 methods for omega support
DESCRIPTION Bumped package version to 0.26.0.5
Comments suppressed due to low confidence (1)

man/model_parameters.principal.Rd:100

  • The term 'hierachical' appears in the documentation; please update the spelling to 'hierarchical' to match standard terminology.
of \code{0.20} suggests that \verb{20\%} or that variable's variance is not shared

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 support for psych::omega models, aligning their handling with existing EFA and PCA model support within the parameters package. The changes are comprehensive, including refactoring model_parameters.omega for richer output, adding and updating print and summary methods, and ensuring documentation and tests are current. A minor typo was found in a user-facing string within the summary output.

@strengejacke strengejacke merged commit 6acb602 into main Jun 19, 2025
17 of 23 checks passed
@strengejacke strengejacke deleted the strengejacke/issue136 branch June 19, 2025 12:23
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.

Support for psych::omega models

3 participants