The `concentration` parameter in `decov` has no effect.
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 401
- Forks
- 136
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
Here is a model with two between variances:
library(rstanarm)
rstanarm <- stan_lmer(
y ~ 0 + Part + (1|Operator) + (1|Operator:Part), data = dat,
prior = normal(0, 100),
prior_aux = cauchy(0, 5),
prior_covariance = decov(concentration = 1000000, shape = 1, scale = 1/1),
iter = 10000
)
posterior_interval(rstanarm, prob = 95/100)
From my understanding, if the concentration parameter is high (here 1e6), the two between variances should be equal. But this is not the case:
2.5% 97.5%
PartA1 7.6725149693 10.9984804
PartA2 17.7830860979 21.1723343
...
sigma 1.5266337590 2.3625997
Sigma[Operator:Part:(Intercept),(Intercept)] 0.0004819209 3.6359430
Sigma[Operator:(Intercept),(Intercept)] 0.0251682030 10.6149320
And I don't see any significant difference when I set it to 1.
To reproduce the data:
SimAV2mixed <- function(I, J, Kij, mu=0, alphai, sigmaO=1,
sigmaPO=1, sigmaE=1, factor.names=c("Part","Operator"),
resp.name="y", keep.intermediate=FALSE){
Operator <- rep(1:J, each=I)
Oj <- rep(rnorm(J, 0, sigmaO), each=I)
Part <- rep(1:I, times=J)
Pi <- rep(alphai, times=J)
POij <- rnorm(I*J, 0, sigmaPO)
simdata0 <- data.frame(Part, Operator, Pi, Oj, POij)
simdata0$Operator <- factor(simdata0$Operator)
levels(simdata0$Operator) <-
sprintf(paste0("%0", floor(log10(J))+1, "d"), 1:J)
simdata0$Part <- factor(simdata0$Part)
levels(simdata0$Part) <- sprintf(paste0("%0", floor(log10(I))+1, "d"), 1:I)
simdata <-
as.data.frame(
sapply(simdata0, function(v) rep(v, times=Kij), simplify=FALSE))
Eijk <- rnorm(sum(Kij), 0, sigmaE)
simdata <- cbind(simdata, Eijk)
simdata[[resp.name]] <- mu + with(simdata, Oj+Pi+POij+Eijk)
levels(simdata[,1]) <- paste0("A", levels(simdata[,1]))
levels(simdata[,2]) <- paste0("B", levels(simdata[,2]))
names(simdata)[1:2] <- factor.names
if(!keep.intermediate) simdata <- simdata[,c(factor.names,resp.name)]
simdata
}
set.seed(666)
I = 2; J = 6; Kij = rpois(I*J, 1) + 3
alphai <- c(10, 20)
sigmaO <- 1
sigmaPO <- 0.5
sigmaE <- 2
dat <- SimAV2mixed(I, J, Kij, mu = 0, alphai = alphai,
sigmaO = sigmaO, sigmaPO = sigmaPO, sigmaE = sigmaE)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied stan_lmer and decov reproduction, using the provided SimAV2mixed data-generating function and posterior_interval output. Trace how changing concentration from 1 to 1e6 is represented in the covariance prior, then verify that the resulting between-group variance behavior matches the documented expectation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100