2

I'm trying to do a bayesian gamma regression with stan. I know the correct link function is the inverse canonical link, but if i dont use a log link parameters can be negative, and enter in a gamma distribution with a negative value, that obviously can't be possible. how can i deal with it?

parameters {
vector[K] betas; //the regression parameters
real beta0;
real<lower=0.001, upper=100 > shape; //the variance parameter
}
transformed parameters {
vector<lower=0>[N] eta; //the expected values (linear predictor)
vector[N] alpha; //shape parameter for the gamma distribution
vector[N] beta; //rate parameter for the gamma distribution

eta <- beta0 + X*betas; //using the log link 
}
model {  
beta0 ~ normal( 0 , 2^2 ); 

for(i in 2:K)
betas[i] ~ normal( 0 , 2^2 ); 

y ~ gamma(shape,shape * eta);
}
4

1 回答 1

0

几周前我一直在努力解决这个问题,虽然我不认为这是一个明确的答案,但希望它仍然有用。对于它的价值,McCullagh 和 Nelder 直接承认对规范链接功能的这种不适当的支持。他们建议必须约束betas 以正确匹配支持。这是相关的段落

规范链接函数产生足够的统计量,这些统计量是数据的线性函数,由 给出η = 1/μ。与泊松分布和二项分布的规范链接不同,倒数变换通常可以解释为过程的速率,它不会将 的范围映射μ到整个实数线上。因此,η > 0意味着限制β任何线性模型中的 s 的要求。在计算中必须采取适当的预防措施以避免β_hat负值μ_hat

——麦卡拉和内尔德(1989)。广义线性模型。页。291

这取决于您的X价值观,但据我所知(请纠正我的人!)在基于 MCMC 的贝叶斯案例中,您可以通过在betas 上使用截断先验或在截距上使用足够强的先验来实现这一点使不合适的区域在数字上无法到达。

就我而言,我最终使用了具有强正向先验截距的身份链接,这已经足够并且产生了合理的结果。

此外,链接的选择实际上取决于您的X. 正如上面的段落所暗示的,规范链接的使用假设您的线性模型位于速率空间中。使用日志或身份链接函数似乎也很常见,最终它是关于提供一个空间,为线性函数提供足够的跨度来捕获响应。

于 2018-12-13T15:46:11.007 回答