Comments (4)
There is a conflict between the force.heredity=TRUE
(the new defaults) and include.always
, but I see that is not clearly documented in the help files. That can explain part of the difference in the bas objects created from v1.5.1 and v1.5.2
The include.aways
option reorders variables that are always included to be at end of the model vector (i.e include.always
sets initprobs to 1, and then the variables are sorted so that the highest probabilities are last. This order was causing a problem with checks for parents used in the force.heredity = TRUE
, i.e. a child would not be added because the code assumed that the parents would be checked first. So for the time being the initprobs
were being overwritten to keep the order of variables in the model. This will need to be fixed to allow both options.
Will look at whether the intercept is being added to the include.always
list in the output in case that changed between versions.
from bas.
@AlexanderLyNL let me know if the new version on GitHub resolves your issue with the models/plotting (it seems to work with my limited testing; I've added a file JASP-tests.R
in the tests
directory for testing and the debug.csv
data set in inst/testdata
) so
loc = system.file("testdata", package="BAS")
d = read.csv(paste(loc, "JASP-testdata.csv", sep="/"))
simpleFormula = as.formula("contNormal ~ contGamma + contcor1 + contGamma * contcor1 ")
set.seed(1)
library(BAS)
basObj = bas.lm(simpleFormula,
data = d,
alpha = 0.125316,
prior = "JZS", include.always=as.formula("contNormal ~ contcor1"),
weights = d$facFifty)
image(basObj, rotate=FALSE)
image(basObj, rotate=FALSE, drop.always.included=TRUE)
basObj$include.always
coefficient estimates, R2, and log marginals agree, but just noticed that the posterior probabilities did not agree so there may be an issue with the re-weighting of the output. (will check which is correct :-)
cheers!
from bas.
force.heredity.bas
was using a different prior probability so posterior probabilities were not comparable. For now, function has been updated to use the same prior probabilities as with sampling, but now reweighed over the models that satisfy the heredity condition.
Future work can address asking more meaningful priors for constrained models
loc = system.file("testdata", package="BAS")
d = read.csv(paste(loc, "JASP-testdata.csv", sep="/"))
simpleFormula = as.formula("contNormal ~ contGamma + contcor1 + contGamma * contcor1 ")
library(BAS)
set.seed(1)
basObj = bas.lm(simpleFormula,
data = d,
alpha = 0.125316,
prior = "JZS",
include.always=as.formula("contNormal ~ contcor1"),
modelprior=beta.binomial(1,1),
weights = d$facFifty)
image(basObj, rotate=FALSE)
image(basObj, rotate=FALSE, drop.always.included=TRUE)
basObj$include.always
## old
##
## install.packages("BAS")
## library(BAS)
set.seed(1)
basObj.old = bas.lm(simpleFormula,
data = d,
alpha = 0.125316,
prior = "JZS",
include.always=as.formula("contNormal ~ contcor1"),
modelprior=beta.binomial(),
weights = d$facFifty, force.heredity = FALSE)
basObj.old = force.heredity.bas(basObj.old)
basObj.old$postprobs #(check order of models)
basObj$postprobs
from bas.
added unit-test in tests/testthat/test-bas-lm.R:
test_that("force.heredity", {
# based on bug #26
loc <- system.file("testdata", package = "BAS")
d <- read.csv(paste(loc, "JASP-testdata.csv", sep = "/"))
simpleFormula <- as.formula("contNormal ~ contGamma + contcor1 + contGamma * contcor1 ")
set.seed(1)
basObj <- bas.lm(simpleFormula,
data = d,
alpha = 0.125316,
prior = "JZS",
include.always = as.formula("contNormal ~ contcor1"),
modelprior = beta.binomial(1, 1),
weights = d$facFifty
)
set.seed(1)
basObj.old <- bas.lm(simpleFormula,
data = d,
alpha = 0.125316,
prior = "JZS",
include.always = as.formula("contNormal ~ contcor1"),
modelprior = beta.binomial(),
weights = d$facFifty, force.heredity = FALSE
)
basObj.old <- force.heredity.bas(basObj.old)
expect_equal(basObj$probne0, basObj.old$probne0)
})
Closing now, but comment if there are still unresolved issues or create a new issue
from bas.
Related Issues (20)
- Remove intercept in bas.lm? HOT 1
- Multithreading Problem HOT 1
- Same Intercepts HOT 1
- dropping the null model from Jeffrey's prior conflicts with include.always HOT 1
- Using pivot = FALSE in bas.lm does not create a warning on M1mac in non-full rank case HOT 1
- Add Firth logistic regression to BAS
- coef throws warnings with bas.glm objects if prior is AIC or BIC HOT 1
- `bayesglm.fit` does not check arguments `x` or `y` for correct type before calling C HOT 1
- `bas.predict` error with a single covariate HOT 2
- segmentation fault with method "MCMC+BAS" if initial (best model) arg is not the null model HOT 1
- `bas.predict` error when n<p when using `estimator= BMA` and `se.fit =T` HOT 2
- Release BAS 1.6.6 HOT 1
- valgrind identifies uninitialized variables in `glm_fit.c` HOT 1
- Release BAS 1.7.0 HOT 1
- `bas.lm` and `bas.glm` ignoring prior model probabilities that are 0 HOT 1
- uninitialized values in `hyp1f1.c` HOT 1
- Release BAS 1.7.1 HOT 1
- issue with hypergeometric1F1 HOT 1
- error in hypergeometric1F1 HOT 1
- Linux vs Windows: different results HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bas.