merliseclyde / BAS

BAS R package for Bayesian Model Averaging and Variable Selection
https://merliseclyde.github.io/BAS/
GNU General Public License v3.0
42 stars 16 forks source link

Same Intercepts #60

Closed galalxyliu closed 2 years ago

galalxyliu commented 2 years ago

Describe the bug

Hi Merlise, nice to see you!

I find that all models' intercepts are the same. This confuses me. In my naive view, the intercepts should be significantly different because of the different model specifications.

By the way, because of the need for presentation, in the frequentist view, what's the estimator used in the Bas package (Ols or Gls)?

Thanks!

To Reproduce

rm(list=ls()) library(MASS) options(digits=22) set.seed(100) data(UScrime) crime.bic <- bas.lm(log(y) ~ log(M) + So + log(Ed) + log(Po1) + log(Po2) + log(LF) + log(M.F) + log(Pop) + log(NW) + log(U1) + log(U2) + log(GDP) + log(Ineq) + log(Prob) + log(Time), data = UScrime, n.models = 2^15, prior = "BIC", modelprior = beta.binomial(1, 1), initprobs = "eplogp", pivot = FALSE )

cog <- coef(crime.bic) means <- matrix(cog$conditionalmeans,2**15,16) intercept <- means[,1] intercept <- as.data.frame(intercept) intercept

########## we can find the all models' intercept are almost same################

Expected behavior

Could you tell me the reason why all the intercepts are same?

merliseclyde commented 2 years ago

The intercepts are all equal in this model formulation as the explanatory variables have all been centered about their respective means. When the X's are equal to their mean, then the centered predictors are all 0 and the fitted value is just the intercept, which is $\bar{y}$. See the help file for bas.lm.

The estimates are MLEs/OLS if there are no weights, and GLS/MLEs if there are weights used.