Dears
thanks for rstanarm! This is wonderful - exactly what we (ecologists) need! Really great.
I am sorry to bother you with maybe a very stupid question. I am interested in the difference between males and females in mean wing length of Snowfinches.
I have only few data, but in addition I have for each group a mean with a SE from the literature that I would like to use as prior information.
When I fit two indepenent models for each group and use a normal prior for the intercept I get a reasonable posterior distribution. However, when I fit the model to both groups separately excluding the intercept so that the two parameters correspond to the group means, the resulting residual variance is way too large (see r-code below). I could not find the reason for this. In my opinion the sigma in the combined analyses should be something between 2.5 and 5.2 which are the group-specific residual standard deviations. Because I am interested in the difference between the two means, I need to fit the combined model to obtain the joint posterior distribution of the two means.
I am happy about any hint on what I do wrong. Thanks so much in advance!
Fränzi
# some data
group <- c("M", "M", "M", "W", "W", "W", "W", "W", "W")
y <- c(125, 122, 121, 119, 119.5, 116, 121, 121, 117.5)
dat <- data.frame(group=group, y=y)
# values from the literature (m SE)
mm <- 123.8
semm <- 0.381
mw <- 116.7
semw <- 0.387
# fit a model to the data without prior information
mod <- lm(y~group-1)
mod
# Coefficients:
# groupM groupW
# 122.7 119.0
summary(mod)$sigma
#[1] 2.005944
# include prior information for the two means using rstanarm
library(rstanarm)
stanmod <- stan_glm(y~group-1, data=dat,
prior = normal(c(mm, mw), scale=c(semm, semw)),
prior_intercept = NULL)
print(stanmod)
# Estimates:
# Median MAD_SD
# groupM 123.8 1.9
# groupW 116.7 2.0
# sigma 118.0 27.3 THIS SIGMA IS OVBIOUSLY WAY TOO LARGE
stanmod <- stan_glm(y~1, data=dat[dat$group=="M",],
prior = NULL,
prior_intercept = normal(mm, scale=semm))
print(stanmod)
# Estimates:
# Median MAD_SD
# (Intercept) 123.7 0.4
# sigma 2.5 1.1 THIS SIGMA SEEMS REASONABLE
stanmod <- stan_glm(y~1, data=dat[dat$group=="W",],
prior = NULL,
prior_intercept = normal(mm, scale=semm))
print(stanmod)
# Estimates:
# Median MAD_SD
# (Intercept) 123.6 0.4
# sigma 5.2 1.5 THIS SIGMA SEEMS REASONABLE