If I plot the overall samples of intercept and slope (bottom two plots in
grey), they seem to work fine for both, it's just the group intercepts and
slopes in the "y ~ x + (x|group)" that I don't understand.
as.matrix(fit$stanfit)names(fit$stanfit)fit = stan_glmer(...)df['(Intercept)'][i] + df['x'][i] * np.array([-1, 7])
df['(Intercept)'][i] + df['b[(Intercept) group:a]'][i] + (df['x'][i] + df['b[x group:a]'][i]) * np.array([-1, 7])
df['(Intercept)'][i] + df['b[(Intercept) group:a]'][i] + df['x'][i] * np.array([-1, 7])
5% 95%
(Intercept) 8.52958750 11.2192503
x -1.07276581 -0.8569989
b[(Intercept) group:a] -5.28344691 -2.5955489
b[(Intercept) group:b] -0.14002830 0.1422533
b[(Intercept) group:c] -3.39296111 -0.7066493
b[(Intercept) group:d] -0.07888252 0.1730402
b[(Intercept) group:e] -1.31888695 1.3628254
b[x group:a] 0.70504964 3.4770025
b[x group:b] -0.14329447 0.1276788
b[x group:c] 2.49437147 5.2757959
b[x group:d] -0.11953980 0.1450246
b[x group:e] -2.79710230 2.8382719
sigma 0.10347701 0.1544424
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/E-7Zau2-Jno/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
To post to this group, send email to stan-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
That might be the issue. I'm not using the coef() function, I'm extracting the samples of the variables and combining the values myself.
library(rstanarm)
library(ggplot2)
library(lme4)
set.seed(0)
num_grps <- 5
num_pnts_per_grp <- 10
x <- matrix(rnorm(num_pnts_per_grp * num_grps, 1:num_grps, 0.5), nrow=num_grps)
y <- 1:num_grps * 2 + 4 + rep(-1, num_grps) * x + rnorm(x, sd=0.1)
grp <- rep(letters[1:num_grps], num_pnts_per_grp)
df <- data.frame(grp, x=c(x), y=c(y))
p <- ggplot(df, aes(x, y))
p + geom_point(aes(color = grp))
fit <- stan_lmer(y ~ x + (x|grp), data=df, seed=0, chains=8, cores=8, iter=1000)
lmfit <- lmer(y ~ x + (x|grp), data=df)
plot(fit, plotfun="hist", pars=names(fit$stanfit))
coef(fit)
coef(lmfit)
Jonah
ranef(fit)
$grp
(Intercept) x
a -3.88 0.00
b -1.88 -0.03
c -0.24 1.76
d 0.03 4.31
e -0.08 0.04
ranef(lmfit)
$grp
(Intercept) x
a -3.94 0.01
b -1.93 -0.03
c -0.30 0.10
d 1.76 0.03
e 4.41 -0.11
--
If you do full Bayes on these models and use posterior means or
medians to estimate, you wouldn't expect the same result as lme4
would you? Or did you guys implement MML in RStanARM?
Is there a writeup somewhere of the expression language for models
and the algorithms you're using?
If you do full Bayes on these models and use posterior means or
medians to estimate, you wouldn't expect the same result as lme4
would you?
Or did you guys implement MML in RStanARM?
Is there a writeup somewhere of the expression language for models
and the algorithms you're using?
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/E-7Zau2-Jno/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
Please see the zip file here: https://dl.dropboxusercontent.com/u/8802928/kastellec_replicate.zip
I tried to update, but am still having the same problem. I have version 2.9.0-3 installed -- is that the latest?
Hi John, thanks a lot for the example. Sorry for the delayed response, I was quite ill over the weekend. Regarding your results, I'm seeing the same thing as Ben (correlation of 1), so I think Ben's right that it must be an issue with the installation or the wrong version being loaded, etc. It looks like the binaries have built for the new CRAN release so you could try installing from CRAN (maybe set repos="https://cran.rstudio.com/" in your call to install.packages in case you have a different default mirror where the binaries aren't built yet). But, like Ben suggested, definitely also double check if your workspace has anything from a previous version.Jonah
--
And just to clarify, because I think I see the confusion now, it's still true that the model was being estimated correctly in the previous version. But the labelling mistake was occurring immediately after estimation when renaming the parameters (changing their names from those used in the underlying Stan code to the more substantive names returned to the user). So it was happening after estimation but before returning the fitted model object. That is, the fitted model object had the right estimates in it, they were just labeled incorrectly. The post-estimation functions were working properly, but they assumed the labels were correct.Anyway, I'm glad we got that sorted out. Thanks for your patience!