楼主: 烟草味99
2791 1

[疑难杂症]How to Deal with Probit Model's Numerical OverFlow? [推广有奖]

  • 0关注
  • 0粉丝

已卖:1份资源

高中生

27%

还不是VIP/贵宾

-

威望
0
论坛币
7 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
82 点
帖子
8
精华
0
在线时间
36 小时
注册时间
2013-10-12
最后登录
2021-2-23

楼主
烟草味99 发表于 2013-12-17 15:16:17 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
如题,利用模拟数据构建probit回归模型,但总是出错。在winbug论坛看见如下描述,大意为probit模型超边,请问有大神遇到过同样问题么?如何解决?
a) 'undefined real result' indicates numerical overflow. Possible reasons include:
- initial values generated from a 'vague' prior distribution may be numerically extreme - specify appropriate initial values;
- numerically impossible values such as log of a non-positive number - check, for example, that no zero expectations have been given when Poisson modelling;
- numerical difficulties in sampling. Possible solutions include:
- better initial values;
- more informative priors - uniform priors might still be used but with their range restricted to plausible values;
- better parameterisation to improve orthogonality;
- standardisation of covariates to have mean 0 and standard deviation 1.
- can happen if all initial values are equal.

Probit models are particularly susceptible to this problem, i.e. generating undefined real results. If a probit is a stochastic node, it may help to put reasonable bounds on its distribution, e.g.

   probit(p) <- delta
   delta ~ dnorm(mu, tau)I(-5, 5)

This trap can sometimes be escaped from by simply clicking on the update button. The equivalent construction

   p <- phi(delta)

may be more forgiving.



程序源代码如下:library(MASS)
library(R2WinBUGS)
n.site <- 1500
g1<- rbinom(n = n.site, size=1, prob=0.4)   
c1<- rnorm(n = n.site, mean=0, sd=1)
c2<- rbinom(n = n.site, size=3, prob=0.3)
u<- rnorm(n = n.site, mean=1, sd=2)
xb <- 0+ 0.4*g1+0.6*c1-0.8*c2+u
probx <- 1/(1+exp(-xb))
x <- rbinom(n = n.site, size = 1, prob = probx)

sink("model.txt")                    #模型1-简单两阶段probit回归法
cat("
    model {
    # Priors
    alpha0 ~ dnorm(0,0.01)
    alpha1 ~ dnorm(0,0.01)
    alpha2 ~ dnorm(0,0.01)
    alpha3 ~ dnorm(0,0.01)
    alpha4 ~ dnorm(0,0.01)
    # Likelihood
    for (i in 1:n) {

    x ~ dbern(px)        # Note p before N
    probit(px) <- alpha0+alpha1*g1+alpha2*c1+alpha3*c2+alpha4*u

    }
    }
    ",fill=TRUE)
sink()

# Bundle data
win.data <- list(g1=g1,c2=c2,u=u,c1=c1,n = length(g1), x=x)

# Inits function
inits <- function(){ list(alpha0=0,alpha1=0,alpha2=0,alpha3=0,alpha4=0) }

# Parameters to estimate
params <- c("alpha0", "alpha2", "alpha1", "alpha3", "alpha4")

# MCMC settings
nc <- 3 #Number of Chains
ni <- 1200 #Number of draws from posterior
nb <- 200 #Number of draws to discard as burn-in
nt <- 2 #Thinning rate

# Start Gibbs sampling
out <- bugs(data=win.data, inits=inits, parameters.to.save=params,
model.file="model.txt", n.thin=nt, n.chains=nc, n.burnin=nb,
n.iter=ni, debug = TRUE,bugs.directory="D:/Program Files/WinBUGS14/")
print(out,dig=3)




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Numerical OverFlow numeric Probit model 模型

本帖被以下文库推荐

沙发
liuqi99 发表于 2013-12-30 20:19:03
This trap can sometimes be escaped from by simply clicking on the update button

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-18 19:59