|
a |
|
b/man/custom_likelihoods.Rd |
|
|
1 |
% Generated by roxygen2: do not edit by hand |
|
|
2 |
% Please edit documentation in R/custom_likelihoods.R |
|
|
3 |
\name{custom_likelihoods} |
|
|
4 |
\alias{custom_likelihoods} |
|
|
5 |
\alias{print.custom_likelihoods} |
|
|
6 |
\title{Customise likelihood functions for outbreaker} |
|
|
7 |
\usage{ |
|
|
8 |
custom_likelihoods(...) |
|
|
9 |
|
|
|
10 |
\method{print}{custom_likelihoods}(x, ...) |
|
|
11 |
} |
|
|
12 |
\arguments{ |
|
|
13 |
\item{...}{a named list of functions, each computing a log-likelihood component.} |
|
|
14 |
|
|
|
15 |
\item{x}{an \code{outbreaker_config} object as returned by \code{create_config}.} |
|
|
16 |
} |
|
|
17 |
\value{ |
|
|
18 |
A named list of list(function, arity) pairs with the class |
|
|
19 |
\code{custom_likelihood}, each function implementing a customised |
|
|
20 |
log-likelihood component of outbreaker. Functions which are not |
|
|
21 |
customised will result in a list(NULL, 0) component. Any function with |
|
|
22 |
arity 3 must have the third parameter default to NULL. |
|
|
23 |
|
|
|
24 |
a list of named functions |
|
|
25 |
} |
|
|
26 |
\description{ |
|
|
27 |
This function is used to specify customised likelihood functions for |
|
|
28 |
outbreaker. Custom functions are specified as a named list or series of |
|
|
29 |
comma-separated, named arguments, indicating which log-likelihood component |
|
|
30 |
they compute. Values currently available are: |
|
|
31 |
} |
|
|
32 |
\details{ |
|
|
33 |
\itemize{ |
|
|
34 |
|
|
|
35 |
\item \code{genetic}: the genetic likelihood; by default, the function |
|
|
36 |
\code{cpp_ll_genetic} is used. |
|
|
37 |
|
|
|
38 |
\item \code{timing_sampling}: the likelihood of sampling times; by default, the function |
|
|
39 |
\code{cpp_ll_timing_sampling} is used. |
|
|
40 |
|
|
|
41 |
\item \code{timing_infections}: the likelihood of infection times; by default, the function |
|
|
42 |
\code{cpp_ll_timing_infections} is used. |
|
|
43 |
|
|
|
44 |
\item \code{reporting}: the likelihood of the reporting process; by default, |
|
|
45 |
the function \code{cpp_ll_reporting} is used. |
|
|
46 |
|
|
|
47 |
\item \code{contact}: the likelihood of the contact tracing data; by default, |
|
|
48 |
the function \code{cpp_ll_contact} is used. |
|
|
49 |
} |
|
|
50 |
|
|
|
51 |
All log-likelihood functions should have the following arguments, in this |
|
|
52 |
order: |
|
|
53 |
|
|
|
54 |
\itemize{ |
|
|
55 |
|
|
|
56 |
\item \code{data}: a list of named items containing input data as returned by |
|
|
57 |
\code{\link{outbreaker_data}} |
|
|
58 |
|
|
|
59 |
\item \code{param}: a list of parameters with the class |
|
|
60 |
\code{\link{create_param}} |
|
|
61 |
|
|
|
62 |
} |
|
|
63 |
} |
|
|
64 |
\examples{ |
|
|
65 |
|
|
|
66 |
## specify a null model by disabling all likelihood components |
|
|
67 |
f_null <- function(data, param) { |
|
|
68 |
return(0.0) |
|
|
69 |
} |
|
|
70 |
|
|
|
71 |
null_model <- custom_likelihoods(genetic = f_null, |
|
|
72 |
timing_sampling = f_null, |
|
|
73 |
timing_infections = f_null, |
|
|
74 |
reporting = f_null, |
|
|
75 |
contact = f_null) |
|
|
76 |
|
|
|
77 |
null_config <- list(find_import = FALSE, |
|
|
78 |
n_iter = 100, |
|
|
79 |
sample_every = 1) |
|
|
80 |
|
|
|
81 |
## load data |
|
|
82 |
x <- fake_outbreak |
|
|
83 |
data <- outbreaker_data(dates = x$sample, dna = x$dna, w_dens = x$w) |
|
|
84 |
|
|
|
85 |
res_null <- outbreaker(data = data, |
|
|
86 |
config = null_config, |
|
|
87 |
likelihoods = null_model) |
|
|
88 |
|
|
|
89 |
## visualise ancestries to see if all transmission trees have been explored |
|
|
90 |
plot(res_null, type = "alpha") |
|
|
91 |
} |
|
|
92 |
\seealso{ |
|
|
93 |
See \href{http://www.repidemicsconsortium.org/outbreaker2/articles/customisation.html#customizing-likelihood}{customization vignette} for detailed examples on how to customize likelihoods. |
|
|
94 |
} |
|
|
95 |
\author{ |
|
|
96 |
Thibaut Jombart (\email{thibautjombart@gmail.com}) |
|
|
97 |
} |