Last active
April 4, 2018 14:45
-
-
Save cbrown5/74c9c0f243f356e251198516512b97e2 to your computer and use it in GitHub Desktop.
Visualise PC prior in INLA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(INLA) | |
nprec <- 100000 | |
prec <- seq(0.05, 1000, length.out = nprec) #precisions | |
sd <- 1/sqrt(prec) | |
U <- 1 | |
alpha <- 0.025 | |
lambda <- -log(alpha)/U #rate for exponential on sd | |
pr_prec <- inla.pc.dprec(prec, U, alpha) #Density for the precision. | |
pr_sd <- dexp(sd, rate = lambda) #Density for sd | |
#nb see inla.pc.dprec for how to get density for the precision. | |
par(mfrow = c(1,2)) | |
plot(prec, pr_prec, type = 'l', xlab = "precision", ylab = "density") | |
plot(sd, pr_sd, type = 'l', xlab = "sd", ylab = "density", | |
main = "PC prior with U = 1, alpha = 0.025") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment