Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @DominiqueMakowski, 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!
I've implemented a fix to improve the robustness of the model_performance.lavaan function. This change specifically addresses scenarios where the lavaan model provided as input has not converged. The primary goal is to prevent errors and provide clearer feedback to the user in such situations, although there appears to be a logical inversion in the final step of setting the output values.
Highlights
- Convergence Check: I've introduced a check within the
model_performance.lavaanfunction to detect if an inputlavaanmodel has failed to converge. This is done by checking ifmodel@vcov$vcovisNULL. - Warning and Mock Model Creation: When a non-converged model is detected, a warning message is now displayed to inform the user that performance indices cannot be computed. To prevent subsequent errors, a temporary 'mock'
lavaanmodel is created and used for internal calculations. - Output Handling Discrepancy: The logic attempts to set the output performance metrics to
NAbased on the original model's convergence status. However, as currently implemented, theNAvalues are assigned when the original model did converge, which seems to contradict the PR's stated goal of handling non-converged cases.
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 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 or fill out our survey 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.
Code Review
This pull request aims to handle non-converged lavaan models by returning NA values. While the intention is good, the current implementation contains a critical logical error that causes it to nullify results for correctly converged models instead. My review provides a fix for this issue, along with a minor correction to a user-facing warning message to improve clarity.
|
Not the most elegant solution but 🤷 |
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request addresses an issue with non-converged lavaan models by adding a check and returning NA values for performance metrics. The overall approach is sound, but the implementation can be improved for robustness and clarity. I've suggested refactoring the convergence check to use the recommended lavaan::lavInspect() function and to handle non-converged models more directly by returning early, which simplifies the code. I also noted a minor discrepancy between a comment and the code.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Pull Request Overview
This PR addresses issue #847 by adding proper handling for non-converged lavaan models in the model performance function. The change prevents errors when trying to compute performance metrics on models that failed to converge.
- Added convergence check using
insight::is_converged()before computing metrics - Returns NA values with appropriate warning when model hasn't converged
- Added
drop = FALSEparameter to maintain data frame structure during subsetting
|
@DominiqueMakowski I applied the suggestion from Gemini code assist, directly returning the data frame. And I implemented a |
There was a problem hiding this comment.
Code Review
This pull request addresses an issue with non-converged lavaan models by adding a check and returning NA for performance metrics. The changes are sensible and correctly handle the non-converged case. My feedback focuses on refactoring the new logic to improve maintainability by reducing code duplication. The core idea is to separate the creation of the results data frame (with either computed values or NAs) from the logic that subsets the metrics, making the function more robust and easier to maintain.
fix #847