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

mu vs intercept #133

Closed
mattansb opened this issue Mar 9, 2019 · 1 comment
Closed

mu vs intercept #133

mattansb opened this issue Mar 9, 2019 · 1 comment

Comments

@mattansb
Copy link

mattansb commented Mar 9, 2019

From the manual:

This is due to the Bayesian model centering the covariates before analysis, so the mu parameter is the mean of y rather than the expected value of the response variable when all uncentered covariates are equal to 0.

From what I can tell, only the mu parameter is computed on the centered covariates - e.g., simple slopes in an interaction model are computed on the un-centered covariates:

library(BayesFactor)

set.seed(444)

df <- data.frame(
  X1 = rnorm(50,30,10),
  X2 = rnorm(50,300,100),
  Y = rnorm(50,400,10)
)

df2 <- df
df2$X1 <- df2$X1 - mean(df2$X1)
df2$X2 <- df2$X2 - mean(df2$X2)

BF1 <- lmBF(Y ~ X1*X2, df, progress = FALSE)
BF2 <- lmBF(Y ~ X1*X2, df2, progress = FALSE)

chains1 <- as.data.frame(posterior(BF1,iterations = 10000, progress = FALSE))
chains2 <- as.data.frame(posterior(BF2,iterations = 10000, progress = FALSE))
round(cbind(unlist(lapply(chains1, median)),
            unlist(lapply(chains2, median))),4)
#>             [,1]     [,2]
#> mu      401.5490 401.5243
#> X1        0.7142  -0.1366
#> X2        0.0786   0.0020
#> X1.&.X2  -0.0028  -0.0028
#> sig2     85.5184  85.5462
#> g         0.0680   0.0688

This makes it quite difficult to calculate the predicted value at a given predictor-value.
Would it be possible to add the model's intercept to the output of the posterior? Or some center argument that can be set to TRUE/FALSE for all parameters in lmBF etc.?

@mattansb
Copy link
Author

mattansb commented Mar 9, 2019

If there's a way to recover the intercept, I've actually solved #128 :)

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

No branches or pull requests

1 participant