Skip to contents

[Stable] Defines a list specifying the structure of the approximate Gaussian process. Custom settings can be supplied which override the defaults.

Usage

gp_opts(
  basis_prop = 0.2,
  boundary_scale = 1.5,
  ls_mean = 21,
  ls_sd = 7,
  ls_min = 0,
  ls_max = 60,
  ls = LogNormal(mean = 21, sd = 7, max = 60),
  alpha = Normal(mean = 0, sd = 0.01),
  kernel = c("matern", "se", "ou", "periodic"),
  matern_order = 3/2,
  matern_type,
  w0 = 1,
  alpha_mean,
  alpha_sd
)

Arguments

basis_prop

Numeric, the proportion of time points to use as basis functions. Defaults to 0.2. Decreasing this value results in a decrease in accuracy but a faster compute time (with increasing it having the first effect). In general smaller posterior length scales require a higher proportion of basis functions. See (Riutort-Mayol et al. 2020 https://arxiv.org/abs/2004.11408) for advice on updating this default.

boundary_scale

Numeric, defaults to 1.5. Boundary scale of the approximate Gaussian process. See (Riutort-Mayol et al. 2020 https://arxiv.org/abs/2004.11408) for advice on updating this default.

ls_mean

Deprecated; use ls instead.

ls_sd

Deprecated; use ls instead.

ls_min

Deprecated; use ls instead.

ls_max

Deprecated; use ls instead.

ls

A <dist_spec> giving the prior distribution of the lengthscale parameter of the Gaussian process kernel on the scale of days. Defaults to a Lognormal distribution with mean 21 days, sd 7 days and maximum 60 days: LogNormal(mean = 21, sd = 7, max = 60) (a lower limit of 0 will be enforced automatically to ensure positivity)

alpha

A <dist_spec> giving the prior distribution of the magnitude parameter of the Gaussian process kernel. Should be approximately the expected standard deviation of the Gaussian process (logged Rt in case of the renewal model, logged infections in case of the nonmechanistic model). Defaults to a half-normal distribution with mean 0 and sd 0.01: Normal(mean = 0, sd = 0.01) (a lower limit of 0 will be enforced automatically to ensure positivity)

kernel

Character string, the type of kernel required. Currently supporting the Matern kernel ("matern"), squared exponential kernel ("se"), periodic kernel, Ornstein-Uhlenbeck #' kernel ("ou"), and the periodic kernel ("periodic").

matern_order

Numeric, defaults to 3/2. Order of Matérn Kernel to use. Common choices are 1/2, 3/2, and 5/2. If kernel is set to "ou", matern_order will be automatically set to 1/2. Only used if the kernel is set to "matern".

matern_type

Deprecated; Numeric, defaults to 3/2. Order of Matérn Kernel to use. Currently, the orders 1/2, 3/2, 5/2 and Inf are supported.

w0

Numeric, defaults to 1.0. Fundamental frequency for periodic kernel. They are only used if kernel is set to "periodic".

alpha_mean

Deprecated; use alpha instead.

alpha_sd

Deprecated; use alpha instead.

Value

A <gp_opts> object of settings defining the Gaussian process

Examples

# default settings
gp_opts()
#> $basis_prop
#> [1] 0.2
#> 
#> $boundary_scale
#> [1] 1.5
#> 
#> $ls
#> - lognormal distribution (max: 60):
#>   meanlog:
#>     3
#>   sdlog:
#>     0.32
#> 
#> $alpha
#> - normal distribution:
#>   mean:
#>     0
#>   sd:
#>     0.01
#> 
#> $kernel
#> [1] "matern"
#> 
#> $matern_order
#> [1] 1.5
#> 
#> $w0
#> [1] 1
#> 
#> attr(,"class")
#> [1] "gp_opts" "list"   

# add a custom length scale
gp_opts(ls_mean = 4)
#> Warning: ! Specifying lengthscale priors via the `ls_mean`, `ls_sd`, `ls_min`, and
#>   `ls_max` arguments is deprecated.
#>  Use the `ls` argument instead.
#> $basis_prop
#> [1] 0.2
#> 
#> $boundary_scale
#> [1] 1.5
#> 
#> $ls
#> - lognormal distribution (max: 60):
#>   meanlog:
#>     0.69
#>   sdlog:
#>     1.2
#> 
#> $alpha
#> - normal distribution:
#>   mean:
#>     0
#>   sd:
#>     0.01
#> 
#> $kernel
#> [1] "matern"
#> 
#> $matern_order
#> [1] 1.5
#> 
#> $w0
#> [1] 1
#> 
#> attr(,"class")
#> [1] "gp_opts" "list"   

# use linear kernel
gp_opts(kernel = "periodic")
#> $basis_prop
#> [1] 0.2
#> 
#> $boundary_scale
#> [1] 1.5
#> 
#> $ls
#> - lognormal distribution (max: 60):
#>   meanlog:
#>     3
#>   sdlog:
#>     0.32
#> 
#> $alpha
#> - normal distribution:
#>   mean:
#>     0
#>   sd:
#>     0.01
#> 
#> $kernel
#> [1] "periodic"
#> 
#> $matern_order
#> [1] 1.5
#> 
#> $w0
#> [1] 1
#> 
#> attr(,"class")
#> [1] "gp_opts" "list"