create_param: Initializes outputs for outbreaker

View source: R/create_param.R

create_paramR Documentation

Initializes outputs for outbreaker

Description

This function creates initial outputs and parameter states for outbreaker.

Usage

create_param(data = outbreaker_data(), config = create_config())

Arguments

data

A list of data items as returned by outbreaker_data, or arguments passed to this function.

config

A list of settings as returned by create_config, or arguments passed to this function.

Value

A named list containing two components $store and $current. store is a list with the class outbreaker_store, used for storing 'saved' states of the MCMC. current is a list with the class outbreaker_param, used for storing 'current' states of the MCMC.

outbreaker_store class content:

  • size:The length of the list, corresponding to the number of samples saved from the MCMC.

  • step: A vector of integers of length size, storing the steps of the MCMC corresponding to the saved samples.

  • post: A numeric vector of length size, storing log-posterior values.

  • like: A numeric vector of length size, storing log-likelihood values.

  • prior: A numeric vector of length size, storing log-prior values.

  • alpha: A list of length size. Each item of the list is an integer vector of length data$N, storing indices (from 1 to N) of infectors for each case.

  • t_inf: A list of length size. Each item of the list is an integer vector of length data$N, storing dates of infections for each case.

  • kappa: A list of length size. Each item of the list is an integer vector of length data$N, storing the number of generations before the last sampled ancestor for each case.

  • pi: A numeric vector of length size, storing values of the reporting probability.

  • a: A numeric vector of length size, storing values of the first spatial parameter (population).

  • b: A numeric vector of length size, storing values of the second spatial parameter (distance).

  • counter: A counter used to keep track of the current iteration of the MCMC (used internally).

outbreaker_param class content:

  • alpha: An integer vector of length data$N, storing indices (from 1 to N) of infectors for each case.

  • t_inf: An integer vector of length data$N, storing dates of infections for each case.

  • kappa: An integer vector of length data$N, storing the number of generations before the last sampled ancestor for each case.

  • pi: The value of the reporting probability.

  • a: The value of the first spatial parameter (population).

  • b: The value of the second spatial parameter (distance).

  • log_s_dens:The spatial likelihood matrix, calculated at each step from a and b if move_a == TRUE or move_b == TRUE.

Author(s)

Initial version by Thibaut Jombart, rewritten by Alexis Robert (alexis.robert@lshtm.ac.uk)

Examples


## load data
data("toy_outbreak_short")
dt_cases <- toy_outbreak_short$cases
dt_cases <- dt_cases[order(dt_cases$Date), ]
dt_regions <- toy_outbreak_short$dt_regions
all_dist <- geosphere::distGeo(matrix(c(rep(dt_regions$long, nrow(dt_regions)), 
                                        rep(dt_regions$lat, nrow(dt_regions))), 
                                      ncol = 2), 
                               matrix(c(rep(dt_regions$long, each = nrow(dt_regions)), 
                                        rep(dt_regions$lat, each = nrow(dt_regions))),
                                      ncol = 2))

dist_mat <- matrix(all_dist/1000, nrow = nrow(dt_regions))
pop_vect <- dt_regions$population
names(pop_vect) <- rownames(dist_mat) <- colnames(dist_mat) <- dt_regions$region

data <- outbreaker_data(dates = dt_cases$Date, age_group = dt_cases$age_group,
                        region = dt_cases$Cens_tract, population = pop_vect, 
                        distance = dist_mat)

## modify config settings
config <- create_config(move_alpha = FALSE, n_iter = 2e5, sample_every = 1000)

## create param object
param <- create_param(data = data, config = config)


o2geosocial documentation built on June 22, 2024, 10:18 a.m.