Skip to content
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

Bugfix tidy.Mclust() for one-dimensional models. Fixes #489 #490

Closed
wants to merge 5 commits into from

Conversation

ltobalina
Copy link

For one-dimensional models, return the mean for each component in one column.

The previous code was returning the mean of each component in different columns, and all of them reported in the row corresponding to the last component, while the values for the other rows were filled filled with NAs.

Now, if the model is one-dimensional, the mean for each component is stored in a column vector, which is added to the final table ret as a new column named mean.

For one-dimensional models, return the mean for each component in one column.

For one-dimensional models, the previous code was returning the mean of each component in different columns, and all of them reported in the row corresponding to the last component, while the values for the other rows were filled filled with NAs.
Now, if the model is one-dimensional, the mean for each component is stored in a column vector, which is added to the final table `ret` as a new column named `mean`.
@alexpghayes
Copy link
Collaborator

Thank you for this! I need to update the modelgenerics dependency, which should get the AppVeyor test passing, and then I'll take a closer look!

@alexpghayes
Copy link
Collaborator

The modelgenerics update has been taken care of! Would you be willing to write a quick test to confirm that the change you've made fixes the bug? Then you could update NEWS, add yourself as a contributor, and I'd merge once the test was passing!

ltobalina added 4 commits Nov 5, 2018
The case of giving a one-dimensional vector to `Mclust()` was missing.
The previous fix was leading to an error if we only asked for one component
when calling `Mclust()`.
`augment.Mclust()` gives an error if the data stored in the object returned
by `Mclust()` is a vector.
@ltobalina
Copy link
Author

Hi. Sorry for the delayed response. I've added a couple of tests to check the correct behaviour when the input to Mclust() is a one-dimensional vector. The previous fix broke the correct behaviour for when the G parameter of Mclust() was set to 1. It should work correctly now.

However, if the input data to Mclust() is an unnamed vector, augment.Mclust() will throw an error. I've added a test case for this, but I haven't found the fix yet.

@alexpghayes
Copy link
Collaborator

What about inspecting the data element of the Mclust object and just throwing an informative error?

@alexpghayes
Copy link
Collaborator

I finished this up in #630. I tried to just push the commits to this PR but my git-fu wasn't good enough, apologies.

@alexpghayes alexpghayes closed this Mar 6, 2019
@ltobalina
Copy link
Author

Thanks a lot!

@github-actions
Copy link

github-actions bot commented Mar 9, 2021

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants