Closed muraiki closed 7 years ago
This should now be fixed in the current version here on github (problem I believe with predict using a new dataframe with one row)
library(devtools)
install_github("merliseclyde/BAS")
library(BAS)
set.seed(42)
d <- data.frame(
likes.cats = c(rep("yes", 60), rep("no", 40)),
likes.dogs = c(rep("yes", 30), rep("no", 70)),
fish.eaten.per.year = c(rnorm(100, mean=20, sd=5)),
donated.to.cats = c(rnorm(50, mean=50, sd=10), rep(0, 50))
)
m <- bas.lm(donated.to.cats ~ likes.cats + likes.dogs + fish.eaten.per.year,
data=d, prior="BIC", modelprior=uniform())
nd <- data.frame("yes", "no", 100, 50)
colnames(nd) <- colnames(d)
dnd <- rbind(d, nd)
fit <- predict(m, dnd[101,], se.fit=TRUE)
confint(fit)
produces output
2.5 % 97.5 % pred
[1,] 0.005899873 66.47635 33.35064
attr(,"Probability")
[1] 0.95
attr(,"class")
[1] "confint.bas"
Output is:
This only happens when
predict
is used withestimator = "BMA"
, which is the default.