JAGS中的贝叶斯加权比例 - 赔率累积Logit模型

时间:2016-11-16 20:05:13

标签: r mixed-models jags ordinal

我在JAGS代码中创建多级/混合序数模型,它们通过[R]中的“runjags”包接口运行。

我正在分析的数据集还包括一组调查权重。为了使数据代表被调查人群,这些非常重要。

对于glm回归,这可以通过以下代码实现,该代码旨在减少极端响应的方差,使值更接近预期分布("偏差 - 方差权衡"): y [i] ~dnorm(拟合[i],(精度/重量[i]))

我想知道在比例 - 赔率累积Logit模型中包含调查权重的最合适方法。

请参阅下面的JAGS代码,以获取我迄今为止构建的未加权模型的示例。非常感谢显示代码的工作应用程序和/或相关引文的引用。

polr_model <- model{

## N = Number of observations
## ConditionCat = y-varaiable measured as 5-point Likert scale
## Categories = Number of y-variable categories (5)
## variable1 = numeric x-variable
## variable2 = numeric x-variable
## Geography = level-2 hierachical struture, in which observations are nested
## weights = survey weights (NOT CURRENTLY USED)

for(i in 1:N){

    ## Calculate categorical likelihood of the outcome:
    ConditionCat[i] ~ dcat(prob[i,1:Categories])

    ## The odds is fixed between observation categories
    ## This is the same as any LR except that the intercept isnt included here:

    odds[i] <- b1 * variable1[i] + b2 * variable2[i] + 
                randomeffect[Geography[i]]

    ## Each observation category is associated with a cumualtive probability called theta:
    for(k in 1:(Categories-1)){
        ## Each observation category has its own intercept - note the minus sign here NOT plus:
        logit(theta[i,k]) <- intercept[k] - odds[i]
    }
    ## With the cumulative probability of the highest category equal to 1:
    theta[i, Categories] <- 1

    ## Then calculate the non-cumulative probabilities from theta:
    prob[i,1] <- theta[i,1]
    for(k in 2:(Categories-1)){
        prob[i,k] <- theta[i,k] - theta[i,(k-1)]
    }
    prob[i, Categories] <- 1 - theta[i,(Categories-1)]
}

## These lines give the prior distributions for the numeric fixed parameters to be estimated:
b1 ~ dnorm(0, 10^-6)
b2 ~ dnorm(0, 10^-6)

## Calculate the Categories-1 independent intercepts::
for(k in 1:(Categories-1)){
    intercept[k] ~ dnorm(0, 10^-6)
}

## These lines give the prior distributions for the 'random' (hierachical/nested) parameters to be estimated:
for(iterator in 1:Nest1){
    randomeffect[iterator] ~ dnorm(0, Geography_precision)}
Geography_precision ~ dgamma(0.001, 0.001)


#data#      N, Nest1, Categories, ConditionCat, variable1, variable2,    Geography
#monitor#   intercept, b1, b2, randomeffect 
#inits#     Geography_precision, intercept, b1, b2
#modules#   glm on, lecuyer on  
}

0 个答案:

没有答案