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

Variable importance metric? #41

Open
1 of 3 tasks
markhwhiteii opened this issue Sep 30, 2021 · 0 comments
Open
1 of 3 tasks

Variable importance metric? #41

markhwhiteii opened this issue Sep 30, 2021 · 0 comments

Comments

@markhwhiteii
Copy link

Please specify whether your issue is about:

  • a possible bug
  • a question about package functionality
  • a suggested code or documentation change, improvement to the code, or feature request

Is there a way to get an idea of "variable importance" using the cregg package? For example, one might look at the plotted marginal means and ask me, "Well, which variable had the biggest effect?" I was thinking maybe looking at the variance of the marginal means? By way of an example, in the code below, I added a noise variable to immigration. I would want noise to perform very poorly on this variable importance metric.

Another ludicrous example might be testing profiles of political candidates where we say their party and whether or not they like macaroni and cheese. We'd want some metric that says "Political party matters X times more than whether or not they like macaroni and cheese." Is that possible to derive from the output of cj()? I wasn't sure if there is some canonical way of approaching this.

library(cregg)
library(tidyverse)
data("immigration")

set.seed(1839)
immigration$noise <- factor(sample(letters[1:5], nrow(immigration), TRUE))

f <- ChosenImmigrant ~ Gender + Education +
  LanguageSkills + CountryOfOrigin + Job + JobExperience +
  JobPlans + ReasonForApplication + PriorEntry + noise

res <- cj(immigration, f, id = ~ CaseID)

# maybe?
res %>% 
  group_by(feature) %>% 
  summarise(est_var = var(estimate)) %>% 
  arrange(desc(est_var))
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

No branches or pull requests

1 participant