Bayesian Methods for the Physical Sciences by Stefano Andreon & Brian Weaver
Author:Stefano Andreon & Brian Weaver
Language: eng
Format: epub
Publisher: Springer International Publishing, Cham
7.7.3 Probabilistic Selection on the True Value
In this section, we would like to implement working code for the model illustrated in Sect. 7.5:
symbolic-model {
for (i in 1:length(obslnL)) {
obslnL[i] ~ dnorm(lnL[i],pow(err.lnL[i],-2)
lnL[i] ~ dnorm(lnLhat,pow(sigma.intr,-2)) phi((x-3)/2)
}
sigma.intr <- 3
lnLhat ~ dunif(-10,10)
}.
The product of a normal and a ϕ function is not among the JAGS distributions and it is not allowed in JAGS to write a line with a tilde and a product of a distribution and a function. The brute force approach is therefore compelling.
The current model is almost identical to the previous one, except for the fact that we replaced the previous sharp selection with the soft one. The latter replacement enters in three places: when we compute the soft selection p(lnL) (the correct[k] line), in the integral computation, and in the numerator of the posterior. For our comfort, we also changed the name of the variables. The model reads3:
data
{
# grid for integral evaluation
for (k in 1:400){
grid.x[k] <- (k-200.)/20.
correcc[k] <- phi((grid.x[k]-3)/2)
}
step.grid.x <-grid.x[2]-grid.x[1]
# dummy variable for zero-trick
# to sample from a distribution not available in JAGS
for (i in 1:length(obslnL)) {
dummy[i] <-0
}
}
model {
# compute the integral at denominator
for (k in 1:length(grid.x)) {
normaliz[k] <- sqrt(prec.intr/6.28)*exp(-prec.intr*
pow(lnLhat-grid.x[k],2 )/2.)*correcc[k]
}
tot.norm <- sum(normaliz[])*step.grid.x
for (i in 1:length(obslnL)) {
obslnL[i] ~ dnorm(lnL[i],prec.lnL[i])
# the following would suffice, if no selection
lnL[i] ~ dnorm(lnLhat,prec.intr)
# but selection is there. Adding the additional likelihood term
numerator[i] <- phi((lnL[i]-3)/2)
# sampling from an unavailable distribution
loglike[i] <- -log(numerator[i]/tot.norm)+C
dummy[i] ~ dpois(loglike[i])
}
C <- 10.
sigma.intr <- 3
prec.intr <- pow(sigma.intr,-2)
lnLhat ~ dunif(-10,10)
}.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Tools of Titans by Timothy Ferriss(7796)
Turbulence by E. J. Noyes(7689)
Astrophysics for People in a Hurry by Neil DeGrasse Tyson(4997)
Secrets of Antigravity Propulsion: Tesla, UFOs, and Classified Aerospace Technology by Ph.D. Paul A. Laviolette(4972)
Design of Trajectory Optimization Approach for Space Maneuver Vehicle Skip Entry Problems by Runqi Chai & Al Savvaris & Antonios Tsourdos & Senchun Chai(4837)
Room 212 by Kate Stewart(4729)
Pale Blue Dot by Carl Sagan(4610)
The David Icke Guide to the Global Conspiracy (and how to end it) by David Icke(4375)
A Journey Through Divination and Astronomy by Publishing Pottermore(4245)
Apollo 8 by Jeffrey Kluger(3507)
Goodbye Paradise(3440)
Losing the Nobel Prize by Brian Keating(3424)
COSMOS by Carl Sagan(3344)
The Five People You Meet in Heaven by Mitch Albom(3330)
Brief Answers to the Big Questions by Stephen Hawking(3237)
How to Read Water: Clues and Patterns from Puddles to the Sea (Natural Navigation) by Tristan Gooley(3235)
How to Read Nature by Tristan Gooley(3071)
The Order of Time by Carlo Rovelli(3071)
A Brief History of Time by Stephen Hawking(2817)
