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

Wrapper function for density plots #126

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

EdoardoCostantini
Copy link
Member

@EdoardoCostantini EdoardoCostantini commented Oct 31, 2023

Hey, Hanne! I created a ggplot2 version of the mice density diagnostic plots for a paper I am writing. When I thought about using ggmice I had already dedicated quite a bit of work to it 🙈. Out of curiosity, I tried to implement my take on these gg density plots in your package. I am not sure whether my plot_density() function fits well with your vision for ggmice, but I thought it might be worth sharing with you and seeing what you think about it. If you want to check it out, here is a code example inspired by your old_friends.Rmd vignette:

# load packages
library(ggmice)
library(mice)
library(ggplot2)

# load incomplete dataset from mice
dat <- boys

# generate imputations
imp <- mice(dat, method = "pmm", printFlag = FALSE)

# original plot
mice::densityplot(imp, ~hgt)

plot

# Can make the same plot
plot_density(data = imp, vrb = "hgt")

plot-3

# Can be broken down by panels
plot_density(data = imp, vrb = "hgt", panels = TRUE)

plot-2

# Can plot arbitrary variables 
plot_density(data = imp, vrb = c("wgt", "bmi", "phb"), panels = FALSE)

plot-7

# Can plot arbitrary variables in panels
plot_density(data = imp, vrb = c("wgt", "bmi", "phb"), panels = TRUE)

plot-4

# Can plot all variables
plot_density(data = imp)

plot-5

@hanneoberman hanneoberman changed the title Density plots Wrapper function for density plots Dec 21, 2023
@hanneoberman
Copy link
Member

Status check: only requires merging new commits from main, and adding NEWS item

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