winbugs中的Probit模型

时间:2013-01-12 23:44:30

标签: winbugs

我使用logit模型进行了分析,现在想要使用probit模型进行相同的操作。任何人都可以将这个winbugs logit模型变成winbugs probit模型吗?

model
 {
 for (i in 1:n) {
 # Linear regression on logit
 logit(p[i]) <- alpha + b.sex*sex[i] + b.age*age[i]
 # Likelihood function for each data point
 frac[i] ~ dbern(p[i])
 }
 alpha ~ dnorm(0.0,1.0E-4) # Prior for intercept
 b.sex ~ dnorm(0.0,1.0E-4) # Prior for slope of sex
 b.age ~ dnorm(0.0,1.0E-4) # Prior for slope of age
 }
 Data
 list(sex=c(1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0,    1,
  1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1,     1, 1, 0,
  0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0,   1, 1, 1,
  0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1),
  age= c(69, 57, 61, 60, 69, 74, 63, 68, 64, 53, 60, 58, 79, 56, 53, 74, 56, 76, 72,
  56, 66, 52, 77, 70, 69, 76, 72, 53, 69, 59, 73, 77, 55, 77, 68, 62, 56, 68, 70, 60,
  65, 55, 64, 75, 60, 67, 61, 69, 75, 68, 72, 71, 54, 52, 54, 50, 75, 59, 65, 60, 60,
  57, 51, 51, 63, 57, 80, 52, 65, 72, 80, 73, 76, 79, 66, 51, 76, 75, 66, 75, 78, 70,
  67, 51, 70, 71, 71, 74, 74, 60, 58, 55, 61, 65, 52, 68, 75, 52, 53, 70),
  frac=c(1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1,   1, 0,
  1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,    1, 1, 1,
  1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1,   1, 1, 1,
  1, 0, 1, 1, 0, 0, 1, 0, 0, 1),
  n=100)
  Initial Values
  list(alpha=0, b.sex=1, b.age=1)

1 个答案:

答案 0 :(得分:5)

WinBUGS接受多种类型的链接函数(请参阅WinBUGS manual中的第15页)。对于概率模型,将线性回归方程式更改为:

probit(p[i]) <- alpha + b.sex*sex[i] + b.age*age[i]

我建议你将年龄变量居中,否则你可能遇到一些收敛问题,所以像这样:

probit(p[i]) <- alpha + b.sex*sex[i] + b.age*(age[i] - mean(age[]))

或者,对于probit模型(如果probit函数给出了一些陷阱错误),您可以使用phi标准普通cdf函数:

 p[i] <- phi(alpha + b.sex*sex[i] + b.age*(age[i] - mean(age[])))