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

report both change along with slope in mod_effect() output #21

Open
rpruim opened this issue Jun 26, 2018 · 1 comment
Open

report both change along with slope in mod_effect() output #21

rpruim opened this issue Jun 26, 2018 · 1 comment

Comments

@rpruim
Copy link
Contributor

rpruim commented Jun 26, 2018

@dtkaplan, how does this look?

example(mod_effect)
## 
## md_ffc> mod1 <- lm(wage ~ age * sex * educ + sector, data = mosaicData::CPS85)
## 
## md_ffc> mod_effect(mod1, ~ sex)
## # A tibble: 1 x 6
##   change sex   to_sex   age  educ sector
##    <dbl> <fct> <fct>  <dbl> <dbl> <fct> 
## 1  -1.88 M     F         35    12 prof  
## 
## md_ffc> mod_effect(mod1, ~ sector)
## # A tibble: 1 x 6
##   change sector to_sector   age sex    educ
##    <dbl> <fct>  <fct>     <dbl> <fct> <dbl>
## 1  -2.23 prof   clerical     35 M        12
## 
## md_ffc> mod_effect(mod1, ~ age, sex = "M", educ = c(10, 12, 16), age = c(30, 40))
## # A tibble: 6 x 7
##   change slope   age to_age sex    educ sector
##    <dbl> <dbl> <dbl>  <dbl> <fct> <dbl> <fct> 
## 1   1.18 0.118    30     40 M        10 prof  
## 2   1.18 0.118    40     50 M        10 prof  
## 3   1.38 0.138    30     40 M        12 prof  
## 4   1.38 0.138    40     50 M        12 prof  
## 5   1.78 0.178    30     40 M        16 prof  
## 6   1.78 0.178    40     50 M        16 prof  
## 
## md_ffc> mod_effect(mod1, ~ age, sex = "F", age = 34, step = 1)
## # A tibble: 1 x 7
##   change  slope   age to_age sex    educ sector
##    <dbl>  <dbl> <dbl>  <dbl> <fct> <dbl> <fct> 
## 1 0.0549 0.0549    34     35 F        12 prof  
## 
## md_ffc> mod_effect(mod1, ~ sex, age = 35, sex = "M", to = "F" )
## # A tibble: 1 x 6
##   change sex   to_sex   age  educ sector
##    <dbl> <fct> <fct>  <dbl> <dbl> <fct> 
## 1  -1.88 M     F         35    12 prof  
## 
## md_ffc> # For classifiers, the change in *probability* of a level is reported.
## md_ffc> mod2 <- rpart::rpart(sector ~ age + sex + educ + wage, data = mosaicData::CPS85)
## 
## md_ffc> mod_effect(mod2, ~ educ)
## # A tibble: 1 x 7
##   change_clerical slope  educ to_educ   age sex    wage
##             <dbl> <dbl> <dbl>   <dbl> <dbl> <fct> <dbl>
## 1               0     0    12      14    35 M       7.8
## 
## md_ffc> mod_effect(mod2, ~ educ, class_level = "manag")
## # A tibble: 1 x 7
##   change_manag slope  educ to_educ   age sex    wage
##          <dbl> <dbl> <dbl>   <dbl> <dbl> <fct> <dbl>
## 1            0     0    12      14    35 M       7.8
@rpruim
Copy link
Contributor Author

rpruim commented Jun 26, 2018

I see that sometimes the change column is inheriting a variable name. Do we want that? Should it be there in all cases?

rpruim added a commit that referenced this issue Jun 26, 2018
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