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.26960786 0.35670468
## [2,] -0.81878348 -0.26378987
## [3,] -0.84328122 -0.51889857
## [4,] -2.33700192 -1.53814531
## [5,] 1.47615831 1.94994443
## [6,] 0.60344098 -0.40552940
## [7,] 0.73479667 0.70395256
## [8,] 1.14760930 1.39653795
## [9,] 0.10472995 0.05611722
## [10,] 0.73576400 1.99102264
## [11,] -0.54513382 -0.49285935
## [12,] -0.78744050 -0.92701386
## [13,] -0.54907072 0.16799675
## [14,] -0.86819650 -0.56785568
## [15,] 0.34619684 -0.25481298
## [16,] -2.08807532 -1.00755908
## [17,] -1.86158479 -2.08927872
## [18,] -0.81150597 0.89170244
## [19,] 0.89711004 1.95766890
## [20,] 2.93985173 2.70652735
## [21,] -0.49080406 -0.76092781
## [22,] 0.29366391 0.29553436
## [23,] -0.90852909 -0.21999530
## [24,] 0.17480815 -0.09953676
## [25,] -1.27148452 0.03885679
## [26,] 0.26605196 0.21471893
## [27,] -0.59940374 -1.08893052
## [28,] 0.79166618 1.31627437
## [29,] 0.02983275 0.56803130
## [30,] 0.30090981 -0.36625368
plot(y)
dwish(R, k)
Precision priors for Multivariate normal.
dmulti(pi, n)
Handled by I(,)
in JAGS. See the JAGS manual.