1
$\begingroup$

Package rstanarm in R, by default, centers the predictor variables. But I'm wondering in the case of a simple linear regression below, why intercept is not equal to dependent var. mean after Centering?

Here is my R code and data:

cor.norm <- function(x, r, m = 95, s = 4){
  e  = rnorm(length(x), m, s)
  return(y = round(r*x + e))
}

prof <- {                 # dataset “prof”
set.seed(1170)  
data.frame(LAA = LAA <- round(rnorm(60, 32, 4)), TOEFL = cor.norm(LAA, .3) )
}

library(rstanarm)
     fit <- stan_glm(TOEFL ~ LAA, data = prof,            
                       prior_intercept = normal(0, 10),   # prior on intercept (α)
                                 prior = normal(0, 2.5),  # prior on slope (β)
                             prior_aux = cauchy(0, 100))  # prior on sd (σ)

summary(fit) # HERE, intercept ≠ mean of TOEFL

# Intercept (α)     88.84
# mean(prof$TOEFL)  103.5833
$\endgroup$

1 Answer 1

1
$\begingroup$

Because it uncenters at the end so that the intercept corresponds to the glm parameterization. You want to be looking at the mean (over the observations) of the prior predictive distribution that is listed at the bottom of the print method output to make sure that it corresponds to the sample mean of the outcome, but it always does in Gaussian, no link, linear models.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.