Resources:
Be aware of conjugate priors.
The most important ones: Normal, Poisson, Binomial (Bernoulli), Uniform
dexp(lambda)
dgamma(r, lambda)
dnegbin(p, r)
dbeta(a,b)
ddexp(mu, tau)
dweib(v, lambda)
dcat(pi)
dcat
is not in the basic R functions!sample
instead.dmnorm(mu, Omega)
mvtnorm
: library(mvtnorm)
vector.of.means <- c(0,0)
cov.matrix <- matrix(c(1,0.8,0.8,1), 2,2)
cov.matrix
## [,1] [,2]
## [1,] 1.0 0.8
## [2,] 0.8 1.0
y <- rmvnorm(n=30, mean=vector.of.means, sigma=cov.matrix)
y
## [,1] [,2]
## [1,] 0.07406122 0.7711401
## [2,] 0.21383312 1.2389753
## [3,] -0.65975158 -0.8455882
## [4,] 0.06294699 -0.1329048
## [5,] 0.91588805 1.9713674
## [6,] -0.27463535 -0.1730642
## [7,] -1.02207667 -0.8977509
## [8,] -1.71211921 -1.2613884
## [9,] -0.11714706 0.1982714
## [10,] 0.87088801 0.9608702
## [11,] 0.89448223 0.8969777
## [12,] 0.49884529 0.4691392
## [13,] -1.38938643 -0.9791111
## [14,] 2.02378368 0.6322382
## [15,] 1.21142195 1.3581468
## [16,] -1.12736932 -0.7497353
## [17,] -0.06920579 1.0109795
## [18,] 1.13086891 0.9011587
## [19,] 1.42231005 0.9875621
## [20,] 0.26635626 0.2358371
## [21,] 0.02905458 -0.1255665
## [22,] 1.91541479 1.5091596
## [23,] 0.30478173 0.5555567
## [24,] -0.98344367 -1.1353045
## [25,] -0.96724569 -1.3300613
## [26,] 0.52097947 0.6890798
## [27,] 0.88271200 -0.4577340
## [28,] -1.52959359 -1.4126550
## [29,] 0.30544225 -0.0543552
## [30,] -0.42286507 0.1514605
plot(y)
dwish(R, k)
Precision priors for Multivariate normal.
dmulti(pi, n)
Handled by I(,)
in JAGS. See the JAGS manual.