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

type_ridge: joint.max=all/facet/by instead of global.max=TRUE/FALSE #292

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

zeileis
Copy link
Collaborator

@zeileis zeileis commented Jan 28, 2025

Grant @grantmcdermott, this is a follow-up to our discussion in #270

I replaced the old global.max = TRUE vs. FALSE argument with a new joint.max = "all" vs. "facet" or "by". The documentation reads as follows.

joint.max: character indicating how to scale the maximum of the densities: The default "all" indicates that all densities are scaled jointly relative to the same maximum so that the areas of all densities are comparable. Alternatively, "facet" indicates that the maximum is computed within each facet so that the areas of the densities are comparable within each facet but not necessarily across facets. Finally, "by" indicates that each row (in each facet) is scaled separately, so that the areas of the densities for by groups in the same row are comparable but not necessarily across rows.

@zeileis
Copy link
Collaborator Author

zeileis commented Jan 28, 2025

P.S.: I noticed that we don't catch the situation where certain groups are too small (1 observation or empty). It would probably be good to handle this more gracefully than throwing an error.

@grantmcdermott
Copy link
Owner

Thanks for this @zeileis. I'm happy to merge, but first want to check:

P.S.: I noticed that we don't catch the situation where certain groups are too small (1 observation or empty). It would probably be good to handle this more gracefully than throwing an error.

Is this an issue specific to to this PR, or is it a general problem?

@grantmcdermott grantmcdermott changed the title type_ridge: join.max=all/facet/by instead of global.max=TRUE/FALSE type_ridge: joint.max=all/facet/by instead of global.max=TRUE/FALSE Feb 2, 2025
@zeileis
Copy link
Collaborator Author

zeileis commented Feb 2, 2025

I think this was a general problem. Can send an example when the kids are in bed...

@zeileis
Copy link
Collaborator Author

zeileis commented Feb 2, 2025

It seems that type_ridgeplot() generally does not catch empty subgroups, be it empty factor levels directly:

iris4 <- transform(iris, Species = factor(as.character(Species), levels = c(levels(Species), "foobar")))
tinyplot(Species ~ Sepal.Width, data = iris4, type = "ridge")
## Error in bw.nrd0(x) : need at least 2 data points

Or empty interactions of factor levels:

tinyplot(cyl ~ mpg, facet = ~ vs, data = mtcars, type = "ridge")
## Error in bw.nrd0(x) : need at least 2 data points

@grantmcdermott
Copy link
Owner

Ah, I see. Do you want to try tackle as part of this PR?

No pressure. I'm happy to this PR merge as-is and address the empty subgroup issue later.

@grantmcdermott
Copy link
Owner

Looks like this is an issue also affecting density types, so let's address it separately.

> tinyplot( ~ mpg, facet = cyl ~ vs, data = mtcars, type = "density")
Error in bw.nrd0(x) : need at least 2 data points

@grantmcdermott grantmcdermott merged commit 7ed11e4 into main Feb 4, 2025
3 checks passed
@grantmcdermott grantmcdermott deleted the ridge-ymax branch February 4, 2025 01:31
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.

2 participants