-
Notifications
You must be signed in to change notification settings - Fork 19
/
densityDirichlet.R
56 lines (50 loc) · 1.4 KB
/
densityDirichlet.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#' Dirichlet density (multivariate, continuous, unbounded space)
#'
#' @inherit Density
#' @param alpha Either a fixed value or a prior density for the vector parameter.
#'
#' @family Density
#'
#' @examples
#' # With fixed values for the parameters
#' Dirichlet(alpha = c(1, 1, 1))
#'
#' # With priors for the parameters
#' Dirichlet(alpha = Beta(1, 1))
Dirichlet <- function(alpha = NULL, ordered = NULL, equal = NULL, bounds = list(NULL, NULL),
trunc = list(NULL, NULL), k = NULL, r = NULL, param = NULL) {
MultivariateDensity("Dirichlet", ordered, equal, bounds, trunc, k, r, param, alpha = alpha)
}
#' @keywords internal
#' @inherit freeParameters
freeParameters.Dirichlet <- function(x) {
""
# stop("TO BE IMPLEMENTED.")
}
#' @keywords internal
#' @inherit fixedParameters
fixedParameters.Dirichlet <- function(x) {
""
# stop("TO BE IMPLEMENTED.")
}
#' @keywords internal
#' @inherit generated
generated.Dirichlet <- function(x) {
stop("TO BE IMPLEMENTED.")
}
#' @keywords internal
#' @inherit getParameterNames
getParameterNames.Dirichlet <- function(x) {
return(c("alpha"))
}
#' @keywords internal
#' @inherit logLike
logLike.Dirichlet <- function(x) {
stop("TO BE IMPLEMENTED.")
}
#' @keywords internal
#' @inherit prior
prior.Dirichlet <- function(x) {
sprintf("%s%s%s ~ dirichlet(%s);", x$param, x$k, x$r,
sprintf("[%s]'", paste(eval(x$alpha), collapse = ", ")))
}