carloscinelli / sensemakr

Suite of sensitivity analysis tools for OLS
https://carloscinelli.com/sensemakr/
88 stars 16 forks source link

Restrict choice of variables to show in plots #3

Closed chadhazlett closed 7 years ago

chadhazlett commented 7 years ago

Need argument, perhaps "showvars" to restrict which covariates get shown as benchmarks on plots. Should show up in the top level plot wrapper so that people can see the argument name. Should check is showvars%in%X and throw an error if not.

statsccpr commented 7 years ago

with the grouping feature now live

https://github.com/chadhazlett/sensemakr/blob/master/tests/test_group_feature.R

we now have the exhaustive quantities of factor levels along with quantities if any terms are grouped

@carloscinelli if you are working on the plot, you are now exposed to all the quantities in the output of sensemakr(), so you can figure out which to 'mask' or 'show'

The following two data frames are now returned from sensemakr.lm()

mod_test  <- lm(peacefactor ~ directlyharmed + female + village, data = darfur)
test2 = sensemakr.lm(model=mod_test,D='directlyharmed',
                     group_list = list(c('village','female')))
head(test2$benchmarks$benchmark_R2)
test2$benchmarks$benchmark_R2_group

Note, the user specified grouping via 'group_list' AND our internal forced grouping of any factors, say 'village' will all be output in test2$benchmarks$benchmark_R2_group

carloscinelli commented 7 years ago

Mike, I will have to revert this commit, the changes made the plots break. Then we can figure out why it broke and merge it again, I think doing in branches will definitely make this easier.

statsccpr commented 7 years ago

i think this makes sense why theres conflicts on the plotting stage

https://github.com/chadhazlett/sensemakr/commit/6531c6637daf735e0a2a2ac2d370d196ab3628d9#diff-03c02e73da934addaa02e4e28bf772b0

Discussion on user facing ‘X’ argument versus ‘group_list’ argument

The commit difference above, shows that I’ve renamed the ‘X’ argument to be used as ‘group_list’

I think the next time we meet, we could revisit what everyone thinks should be the intention of

sensemakr.lm(...,X) which is now sensemakr.lm(...,group_list)

Working on the reverted commit, I was thinking about it,

we don’t really need group_list (or X) in the sensemakr() stage, and can defer to having the user specify these arguments in the plot/summary/print stage

Since they just recombine low level quantities that were computed in the sensemakr() stage

carloscinelli commented 7 years ago

I think some functions got deleted by accident in the process too, I'm trying to identify what happened.

carloscinelli commented 7 years ago

I restored the previous version and created a branch called "groups" with your previous commit.

statsccpr commented 7 years ago

in the 'unify' branch

https://github.com/chadhazlett/sensemakr/tree/unify

showvars feature now enabled in contour plot

https://github.com/chadhazlett/sensemakr/commit/d3a17f1b2fbb80e1cea49571c02cb91b45380910

https://github.com/chadhazlett/sensemakr/commit/560bb511e0c37ef61fe7441cecd18f745f90fe1b

Three options, masked, all, and user supplied list

plot(sense,showvars='masked',lim=0.02)
plot(sense,showvars='all',lim=0.02)
plot(sense,showvars=list('village','villageMngao','age'),lim=0.02)

custom grouping example

test2 = sensemakr(model=model,treatment='directlyharmed',group_list = list(c('village','female')))
plot(test2,showvars=list('village,female','village','villageMngao','age'),lim=0.5)