Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of alpha #831

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions R/opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,12 @@ backcalc_opts <- function(prior = c("reports", "none", "infections"),
#' this is smaller.
#'
#' @param alpha_mean Numeric, defaults to 0. The mean of the magnitude parameter
#' of the Gaussian process kernel. Should be approximately the expected variance
#' of the logged Rt.
#' of the Gaussian process kernel. Should be approximately the expected standard
#' deviation of the logged Rt.
#'
#' @param alpha_sd Numeric, defaults to 0.01. The standard deviation of the
#' magnitude parameter of the Gaussian process kernel. Should be approximately
#' the expected standard deviation of the logged Rt.
#' @param alpha_sd Numeric, defaults to 0.1. The standard deviation of the
#' magnitude parameter of the Gaussian process kernel. Can be tuned to adjust
#' the uncertainty about the expected standard deviation of the logged Rt.
#'
#' @param kernel Character string, the type of kernel required. Currently
#' supporting the Matern kernel ("matern"), squared exponential kernel ("se"),
Expand Down Expand Up @@ -508,7 +508,7 @@ gp_opts <- function(basis_prop = 0.2,
ls_min = 0,
ls_max = 60,
alpha_mean = 0,
alpha_sd = 0.01,
alpha_sd = 0.1,
kernel = c("matern", "se", "ou", "periodic"),
matern_order = 3 / 2,
matern_type,
Expand Down
12 changes: 6 additions & 6 deletions man/gp_opts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-create_gp_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test_that("create_gp_data returns correct default values when GP is disabled", {
expect_equal(gp_data$ls_sdlog, convert_to_logsd(21, 7))
expect_equal(gp_data$ls_min, 0)
expect_equal(gp_data$ls_max, 3.54, tolerance = 0.01)
expect_equal(gp_data$alpha_sd, 0.01)
expect_equal(gp_data$alpha_sd, 0.1)
expect_equal(gp_data$gp_type, 2) # Default to Matern
expect_equal(gp_data$nu, 3 / 2)
expect_equal(gp_data$w0, 1.0)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-gp_opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("gp_opts returns correct default values", {
expect_equal(gp$ls_sd, 7)
expect_equal(gp$ls_min, 0)
expect_equal(gp$ls_max, 60)
expect_equal(gp$alpha_sd, 0.01)
expect_equal(gp$alpha_sd, 0.1)
expect_equal(gp$kernel, "matern")
expect_equal(gp$matern_order, 3 / 2)
expect_equal(gp$w0, 1.0)
Expand Down
12 changes: 7 additions & 5 deletions vignettes/gaussian_process_implementation_details.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,22 @@ with the following choices available for the kernel $k$
## Matérn 3/2 covariance kernel (the default)

\begin{equation}
k(\Delta t) = \alpha \left( 1 + \frac{\sqrt{3} \Delta t}{l} \right) \exp \left( - \frac{\sqrt{3} \Delta t}{l}\right)
k(\Delta t) = \alpha^2 \left( 1 + \frac{\sqrt{3} \Delta t}{l} \right) \exp \left( - \frac{\sqrt{3} \Delta t}{l}\right)
\end{equation}

with $l>0$ and $\alpha > 0$ the length scale and magnitude, respectively, of the kernel.
Note that here and later we use a slightly different definition of $\alpha$ compared to Riutort-Mayol et al. [@approxGP], where this is defined as our $\alpha^2$.

## Squared exponential kernel

\begin{equation}
k(\Delta t) = \alpha \exp \left( - \frac{1}{2} \frac{(\Delta t^2)}{l^2} \right)
k(\Delta t) = \alpha^2 \exp \left( - \frac{1}{2} \frac{(\Delta t^2)}{l^2} \right)
\end{equation}

## Ornstein-Uhlenbeck (Matérn 1/2) kernel

\begin{equation}
k(\Delta t) = \alpha \exp{\left( - \frac{\Delta t}{2 l^2} \right)}
k(\Delta t) = \alpha^2 \exp{\left( - \frac{\Delta t}{2 l^2} \right)}
\end{equation}

## Matérn 5/2 covariance kernel
Expand Down Expand Up @@ -120,7 +121,7 @@ t^* = \frac{t - \frac{1}{2}t_\mathrm{GP}}{\frac{1}{2}t_\mathrm{GP}}
Relevant priors are

\begin{align}
\alpha &\sim \mathcal{Normal}(0, \sigma_{\alpha}) \\
\alpha &\sim \mathcal{Normal}(\mu_\alpha, \sigma_{\alpha}) \\
\rho &\sim \mathcal{LogNormal} (\mu_\rho, \sigma_\rho)\\
\end{align}

Expand All @@ -133,7 +134,8 @@ m_\rho &= 21 \\
s_\rho &= 7 \\
\rho_\mathrm{min} &= 0\\
\rho_\mathrm{max} &= 60\\
\sigma_\alpha &= 0.05\\
\mu_\alpha &= 0\\
\sigma_\alpha &= 0.1
\end{align}

# References
Loading