我正在查看一位教授对进行 Metropolis-Hastings 更新的 MCMC 代码。和是矩阵。
在他的代码中,
1) 他两次。
2)每次更新β时,他只更新一小部分。
这些技术有什么用?由于我不知道这种技术的名称,搜索一直没有结果。欢迎任何参考。
for (i in 1:S) { # Start big MCMC loop
theta <- update_theta(alpha, beta, data, theta)
if (i % 2 ==0) { # Only update beta and theta after update theta twice
alpha <- update_alpha(theta, beta, data)
beta <- update_beta(theta, alpha, data)
}
update_beta(theta, alpha, data) {
# Only consider 25% of the beta matrix for update
which_beta_to_update <- ifelse( runif(length(beta)) <= .25, 1, 0 )
deviation <- matrix(runif(length(beta), -1, 1) * which_beta_to_update, nrow = nrow(beta)
betastar <- beta + deviation
# After this, calculate MH acceptance ratio and update beta
}