inf_hist_swap_phi: Swap infection history years with phi term

View source: R/proposal_infection_history.R

inf_hist_swap_phiR Documentation

Swap infection history years with phi term

Description

Swaps the entire contents of two columns of the infection history matrix, adhering to age and strain limitations. Also swaps the values of phi that correspond to these years

Usage

inf_hist_swap_phi(
  infection_history,
  phis,
  age_mask,
  sample_mask,
  proposal_inf_hist_indiv_swap_ratio,
  proposal_inf_hist_distance,
  n_alive
)

Arguments

infection_history

matrix of 1s and 0s to swap around representing the infection history

phis

vector of force of infection parameters for each column

proposal_inf_hist_indiv_swap_ratio

what proportion of infections should be swapped?

proposal_inf_hist_distance

How many time points away should be chosen as candidate swaps?

n_alive

number of individuals alive in each entry of phis

Value

a list: the same infection_history matrix, but with two columns swapped; also the swapped phis

See Also

inf_hist_swap

Other proposals: inf_hist_swap(), infection_history_symmetric(), mvr_proposal(), univ_proposal()

Examples

data(example_inf_hist)
data(example_antibody_data)
data(example_antigenic_map)
times <- example_antigenic_map$inf_times
ages <- unique(example_antibody_data[,c("birth","individual")])
age_mask <- create_age_mask(ages$birth, times)
sample_mask <- create_sample_mask(example_antibody_data, times)
phis <- runif(length(times))
n_alive <- get_n_alive(example_antibody_data,times)
new_inf_hist <- inf_hist_swap_phi(example_inf_hist, phis, age_mask,sample_mask, 1,3, n_alive)

seroanalytics/serosolver documentation built on Dec. 14, 2024, 5:33 a.m.