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

Modify model priors when using include.always #41

Merged
merged 2 commits into from
Nov 5, 2019

Conversation

vandenman
Copy link
Contributor

A possible fix for #40.

At the start of an analyses no_prior_inclusion_is_1(p, probs) counts the number of the initprobs that are 1, denoted noInclusionIs1. This number is passed to all calls to compute_prior_probs which reduces the model space and number of predictors by noInclusionIs1.

For example, this PR will change the prior model probabilities to:

res <- bas.lm(Y ~ ., data = Hald, modelprior = beta.binomial(1, 1), 
              include.always = ~ 1 + X1 + X2)
modeldim <- lengths(res$which)
ord <- order(modeldim)
cbind(modeldim, prior = res$priorprobs[ord])
modeldim  prior
    3     0.333
    4     0.167
    4     0.167
    5     0.333

whereas the current master branch returns:

cbind(modeldim, prior = res$priorprobs[ord])
modeldim  prior
    3     0.033
    4     0.050
    4     0.050
    5     0.200 # <- most prior mass on the most complex model!

I also added a unit test to test-model-priors.R that checks this.

I hope this helps, if anything is unclear please let me know. All comments and/ or feedback are welcome!

@codecov
Copy link

codecov bot commented Apr 17, 2019

Codecov Report

Merging #41 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
+ Coverage   91.56%   91.58%   +0.02%     
==========================================
  Files          54       54              
  Lines        5771     5787      +16     
==========================================
+ Hits         5284     5300      +16     
  Misses        487      487
Impacted Files Coverage Δ
src/lm_sampleworep.c 97.57% <100%> (ø) ⬆️
src/model_probabilities.c 97.61% <100%> (+0.25%) ⬆️
src/glm_sampleworep.c 100% <100%> (ø) ⬆️
src/lm_mcmcbas.c 96.98% <100%> (ø) ⬆️
src/lm_deterministic.c 99.14% <100%> (ø) ⬆️
src/glm_deterministic.c 100% <100%> (ø) ⬆️
src/glm_mcmcbas.c 90.36% <100%> (+0.04%) ⬆️
src/glm_mcmc.c 100% <100%> (ø) ⬆️
src/lm_mcmc.c 97.83% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d99b3d3...abb73a6. Read the comment docs.

Copy link
Owner

@merliseclyde merliseclyde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@merliseclyde merliseclyde merged commit 689b107 into merliseclyde:master Nov 5, 2019
@vandenman vandenman deleted the fixModelPriors branch January 10, 2020 12:40
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