-
Notifications
You must be signed in to change notification settings - Fork 16
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
always.include works differently in 1.5.2 (github version) #26
Comments
There is a conflict between the The Will look at whether the intercept is being added to the |
@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 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! |
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 |
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 |
Hi Merlise,
I’ve been playing with the GitHub version of BAS (1.5.2) and compared this to the CRAN version (1.5.1). In both versions I added contcor1 to the null model:
The CRAN version (1.5.1) gives me the following:
which I think is correct. When I apply the new image function (1.5.2) with drop.always.included=TRUE to the cranBasObject I get the following:
Only the intercept is removed, but not contcor1.
————————
On the other hand, the GitHub version (1.5.2) gives me:
which seems to be quite different, and note that contcor1 is not included in some of the models. The new feature drop.always.included=TRUE does remove contcor1, but not the intercept.
The estimates also differ. Do you know whether there’s something wrong with my installation? Or did I specify the include.always variables incorrectly? Here’s the R script:
https://www.dropbox.com/s/jjqlsm7u9qtyp94/basIncludeAlwaysGithubVersion.R?dl=0
https://www.dropbox.com/s/varuoy0pf2ud8a6/cranBasObj.RData?dl=0
Cheers,
Alexander
The text was updated successfully, but these errors were encountered: