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,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28, 29,29,30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,41, 41,42,42,43,43,44,44,45,45,46,46,47,47,48,48,49,49,50,50,51,51,52,52,53,53, 54,54,55,55,56,56,57,57,58,58,59,59,60,60,61,61,62,62,63,63,64,64,65,65,66, 66,67,67,68,68,69,69,70,70,71,71,72,72,73,73,74,74,75,75,76,76,77,77,78,78, 79,79,80,80,81,81,82,82,83,83,84,84,85,85,86,86,87,87,88,88,89,89,90,90,91, 91,92,92,93,93,94,94), CR=c(NA,NA,1.41,0.85,1.13,0.65,NA,NA,2.13,1.61,7.31,3.8,1.65,2.32,1.13,2.3 ,0.99,1.5,1.32,3.95,7.2,2.97,0.83,1.55,NA,6.5,0.89,1.2,1.52,7,8.68,7.41,NA,0.86,NA,1.92,NA,1.31,7.8,1.78,NA ,1.67,NA,NA,NA,NA,NA,2.25,0.98,0.82,3.94,1.14,12,2.58,2.42,2.59,NA,NA,NA,6.6,3.22,NA,2.02,2.43,1.96 ,0.82,1.64,1.81,1.53,1.01,5.21,8.33,1.14,1.49,6,5.6,2,3.33,4.08,NA,NA,1.14,1.25,0.85,5.42,0.85,0.65,1。02,1.33,1.1,1.12,NA,NA,1.53,1.76,2,0.85,2.9,5,4.09,2.68,0.98,1.48,0.66,0.57,5.72,2.34,0.93,2.39,1.39,1.44,4.77, 2.39,1.79,1.2,0.81,1.25,4.69,1.22,1.92,1.48,2.46,NA,NA,2.53,1.12,1.74,3.45,1.22,1.27,2.61,1.75,0.82,NA,1.4,NA,5.1, 1.24,1.5,1.94,1.24,1.04,1.24,NA,2.39,NA,2.07,2.19,1.6,6,6.38,1.17,1.2,5.62,6.39,1.82,1.31,NA,1.18,3.71,2.03,5.4, 2.17,NA,1.94,1.57,1.44,1.35,1.63,1.24,1.54,1.5,NA,NA,NA,NA,1.44,NA,2.19,7.98,2.15,1.71,1.45,NA,0.98,2.37,1.58) , N = 188)2.19,7.98,2.15,1.71,1.45,NA,0.98,2.37,1.58), N = 188)2.19,7.98,2.15,1.71,1.45,NA,0.98,2.37,1.58), N = 188)

我知道错误是因为变量“CR”中的“NA”,但我不知道如何解决它。我会很感激任何帮助。

4

1 回答 1

1

您有 2 个选项:

1)去掉缺失的CR和n、dgf、subject的对应元素(并相应减少N)。

2) 在模型中定义 CR 的随机关系,以便模型估计缺失的 CR 并在逻辑回归中使用这些估计。就像是:

for(i in 1:N){
   CR[i] ~ dnorm(CR_mu, CR_tau)
}
CR_mu ~ dnorm(0, 10^-6)
CR_tau ~ drama(0.001, 0.001)

CR_mu 和 CR_tau 可能不感兴趣,但如果您愿意,可以对其进行监控。

请注意,这两种方法都假设 CR 是随机缺失的(而不是例如被审查) - 如果 CR 不是随机缺失,这会给您带来有偏差的结果。

马特

于 2017-03-26T11:21:43.847 回答