Hello ;
I have simple models to correct for winner’s curse that occurs when one selects on significance.
Here is my Stan code . I also have a write up here
I would very much appreciate any comments /suggestions/pointers to related work.
A Stan Code
// True mean parameter
Listing 1: Stan code for selection bias correction
data {
real <lower=0> sigma ; r e a l t obs ; real <lower=0> alpha ; // Known standard deviation
// Observed t e s t s t a t i s t I c
// S i g n i f i c a n c e l e v e l
}
parameters {
r e a l mu; }
model {
// Compute c r i t i c a l value f o r two−t a i l e d t e s t
r e a l t c = inv Phi (1− alpha /2) ∗ sigma ;
// Calculate s e l e c t i o n p r o b a b i l i t y
r e a l s e l e c t i o n p r o b = 1− ( Phi ( ( t c− mu)/ sigma )
− Phi((− t c− mu)/ sigma ) ) ;
// Prior
mu ˜ normal (0 , 2 ) ;
12// Adjusted l i k e l i h o o d
t a r g e t += normal lpdf ( t obs | mu, sigma )− log ( s e l e c t i o n p r o b ) ;
}
Listing 2: Stan code for hierarchical meta-analysis
data {
int <lower=0> n ; vector [ n ] t obs ; real <lower=0> sigma ; // Number of s t u d i e s
// Observed e f f e c t s i z e s
// Known measurement e r r o r
}
parameters {
r e a l mu; real <lower=0> tau ; vector [ n ] mu i ; // Overall mean e f f e c t
// Between−study het ero gene ity
// True study−s p e c i f i c e f f e c t s
}
model {
// Priors
mu ˜ normal (0 , 2 ) ; tau ˜ cauchy (0 , 1 ) ; // Weakly informative p r i o r on mean
// Half−Cauchy p r i o r on h ete roge nei ty
// H i e r a r c h i c a l s t r u c t u r e
mu i ˜ normal (mu, tau ) ; // True e f f e c t s d i s t r i b u t i o n
t obs ˜ normal ( mu i , sigma ) ; // Likelihood
generated q u a n t i t i e s {
vector [ n ] s h r u n k e n e f f e c t s = mu i ; // Shrinkage estimates
}
}
EDIT by Aki: added code block ticks