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

Calculate models for all combinations of covariates #21

Closed
hp2500 opened this issue Mar 31, 2021 · 2 comments
Closed

Calculate models for all combinations of covariates #21

hp2500 opened this issue Mar 31, 2021 · 2 comments

Comments

@hp2500
Copy link

hp2500 commented Mar 31, 2021

Hi there,

I am trying to run specifications for all possible combinations of covariates. Currently I only get specifications for each individual covariate and then an additional one that has all covariates. I would like to look at all possible subsets as well.

As a workaround, I have generated all combinations and pasted them into model formula strings using helper code I wrote myself (e.g.: 'cov1 + cov2 + cov3', 'cov1 + cov2', 'cov1 + cov2', etc.). When passing this to the covariates arguments it seems to calculate the respective models. However, there are two issues: 1) It crashes once I use a high number of model specifications (e.g. >4000). 2) In the plot it doesn't correctly show which covariates were used. Instead, it always just colors the "all_covariates" option.

e.g.

covariates <- c("airport_dist", "conservative", 'male', 'age', 'popdens',
                'manufact', 'tourism', 'academics', 'medinc', 'healthcare',
                'y_centroid_county', 'evanrate')


spec_results <- run_specs(df = df_us_slope_prev, 
                     y = c("onset_prev"), 
                     x = c("pers_e"), 
                     model = c("lm"), 
                     controls = covariates)

dim(spec_results)

gives me dimensions of 14x12 but it shoould be 4095x12 if all combinations were considered.

Guidance would be greatly appreciated!

@hp2500 hp2500 changed the title Calculate all combinations of covariates Calculate models for all combinations of covariates Mar 31, 2021
@masurp
Copy link
Owner

masurp commented Apr 6, 2021

Hi,

we intentionally decided to only include these three options (none, all, each individually) per default as we believe that the multiverse of results can otherwise be too overwhelming and less informative. A lot of these combination are almost the same and hardly tell a separate story.

That being said, the development version of specr added a new argument to the run_specs() function which allows to compute all combinations. Simply, install the dev version from this github page, add all.comb = TRUE to the function and you will get the desired results.

Best,
Philipp

@hp2500
Copy link
Author

hp2500 commented Apr 6, 2021

Excellent hint, thanks a lot!

@masurp masurp closed this as completed May 3, 2021
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

2 participants