new_location: Create the location of a new case

Description Usage Arguments Details Author(s) Examples

View source: R/new_location.R

Description

This function creates the location of a new case, with or without a known infector. If it is missing (NULL, default), the case is imported according to parameters in config.

Usage

1
new_location(location = NULL, ..., config = new_config(...))

Arguments

location

An optional location of the infector; if provided, it must be a list with the following slots: 'location', 'dna'

...

further arguments passed to new_config

config

optionally, a config returned by new_config

Details

This function uses a Normal spatial kernel for all spatial dimensions, with a single parameter 'sd_spatial'.

Author(s)

Thibaut Jombart thibautjombart@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## without initial location
x_loc <- new_location()

## dispersal from this location, different sd
new_locs_sd1 <- t(replicate(100, new_location(x_loc)))
new_locs_sd5 <- t(replicate(100, new_location(x_loc, 5)))

plot(matrix(x_loc, ncol = 2), xlim = c(-20, 20), ylim = c(-20, 20), pch = "x")
points(new_locs_sd1, col = "blue")
points(new_locs_sd5, col = "red")

## using a custom spatial kernel
custom_kernel <- function(x) {
  out <- x + runif(length(x), min = -2, max = 20)
  out
}

new_location(c(0,0)) # default kernel
new_location(c(0,0), spatial_kernel = custom_kernel) # custom kernel

thibautjombart/quicksim documentation built on May 5, 2019, 2:42 a.m.