Commit fdb2904d authored by Poppy Miller's avatar Poppy Miller
Browse files

Fixed up some documentation

parent 44c53fa1
......@@ -24,7 +24,8 @@ Imports:
cluster,
stats,
gplots,
abind
SPIn,
grDevices
RoxygenNote: 5.0.1
KeepSource: TRUE
LazyData: TRUE
......@@ -11,4 +11,9 @@ export(HaldDP)
export(PoisGammaDPUpdate)
export(PoissonNode)
export(StochasticNode)
import(dplyr)
importFrom(R6,R6Class)
importFrom(SPIn,SPIn)
importFrom(grDevices,col2rgb)
importFrom(grDevices,colorRampPalette)
importFrom(stats,median)
......@@ -5,7 +5,7 @@
# Copyright: Chris Jewell 2016 #
# Purpose: Implements credible interval calculation #
#####################################################
#' @importFrom SPIn SPIn
ci_chenShao = function(x, alpha) {
n <- length(x)
sorted <- sort(x)
......@@ -27,7 +27,7 @@ ci_chenShao = function(x, alpha) {
}
return(c(
median = median(sorted),
median = stats::median(sorted),
lower = ci.lower,
upper = ci.upper
))
......@@ -42,7 +42,7 @@ ci_percentiles <- function(x, alpha) {
lower_pos <- round(n * (alpha / 2))
return(c(
median = median(x),
median = stats::median(x),
lower = sorted[lower_pos],
upper = sorted[upper_pos]
))
......@@ -51,14 +51,14 @@ ci_percentiles <- function(x, alpha) {
ci_SPIn <- function(x, alpha) {
region <- tryCatch({
SPIn(x, conf = 1 - alpha)$spin
SPIn::SPIn(x, conf = 1 - alpha)$spin
},
error = function(cond) {
print("Error calculating SPIn interval.")
return(c(NA, NA))
})
return(c(
median = median(x),
median = stats::median(x),
lower = region[1],
upper = region[2]
))
......
......@@ -5,11 +5,10 @@
# Copyright: Chris Jewell 2016 #
# Purpose: Draws a clustered heatmap #
#####################################################
are_colours <- function(object) {
sapply(object, function(x) {
tryCatch(
is.matrix(col2rgb(x)),
is.matrix(grDevices::col2rgb(x)),
error = function(e)
FALSE
)
......@@ -41,7 +40,7 @@ clusterHeatMap <- function(object, cols, xnames = 1:length(object), hclust_metho
# (when using the default white blue colour scheme),
# the higher the dissimilarity between the 2 types (i.e. the less
# often two type effects are assigned to the same group in the mcmc)
hmcols <- colorRampPalette(cols)(299)
hmcols <- grDevices::colorRampPalette(cols)(299)
heatmap_data <- as.matrix(disim_clust_g)
......
......@@ -8,19 +8,30 @@
#####################################################
#' Builds the source attribution model. Is not intended to be used by a regular user. Developers only here!
#'
#' @param y 3D array of [type, time, location] of the number of human cases
#' @param R 3D array of normalised relative prevalences for each timepoint [type, source, time]
#' @param Time a character vector of timepoint ids matching time dimension in y and R
#' @param Location a character vector of location ids matching location dimension in y
#' @param Prev a 2D array (matrix) of [source, time].
#' @param a_q concentration parameter for the DP
#' @param a_theta shape parameter for the Gamma base distribution for the DP
#' @param b_theta rate parameter for the Gamma base distribution for the DP
#' @param s vector giving group allocation for each type for the DP
#' @param theta vector giving values for each group in the DP
#' @param a_r 3D array of [type, src, time] for the hyperprior on the relative prevalences R
#' Builds the source attribution model. Is not intended to be used by a regular user.
#' Developers only here!
#' @return Object of \code{\link{R6Class}}.
#' @format \code{\link{R6Class}} object.
#' @field y 3D array of [type, time, location] of the number of human cases
#' @field X 3D array of the number of positive samples for each type, source and time
#' [type, source, time]
#' @field R 3D array of normalised relative prevalences for each timepoint
#' [type, source, time]
#' @field Time a character vector of timepoint ids matching time dimension in y and R
#' @field Location a character vector of location ids matching location dimension in y
#' @field Sources a character vector of source ids matching the source dimension in X
#' @field Type a character vector of type ids matching the type dimension in X
#' @field prev a 2D array (matrix) of [source, time].
#' @field a_q concentration parameter for the DP
#' @field a_theta shape parameter for the Gamma base distribution for the DP
#' @field b_theta rate parameter for the Gamma base distribution for the DP
#' @field a_r 3D array of [type, src, time] for the hyperprior on the relative prevalences R
#' @field a_alpha 3D array of [source, time, location] for the prior on the alpha parameters
#' @field s vector giving initial group allocation for each type for the DP
#' @field theta vector giving initial values for each group in the DP
#' @field alpha 3D array of [source, time, location] giving initial values for the alpha
#' parameters
DPModel_impl <- R6::R6Class(
"DPModel_impl",
public = list(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment