inf_hist_prop_prior_v2_and_v4: Infection history gibbs proposal

View source: R/RcppExports.R

inf_hist_prop_prior_v2_and_v4R Documentation

Infection history gibbs proposal

Description

Generates a new infection history matrix and corresponding individual likelihoods, using a gibbs sampler from the infection history prior. See inf_hist_prop_prior_v3, as inputs are very similar.

Usage

inf_hist_prop_prior_v2_and_v4(
  theta,
  unique_theta_indices,
  unique_biomarker_groups,
  infection_history_mat,
  infection_history_mat_indices,
  likelihoods_pre_proposal,
  sampled_indivs,
  n_times_samp_vec,
  age_mask,
  sample_mask,
  n_alive,
  n_infections,
  n_infected_group,
  prior_lookup,
  proposal_inf_hist_indiv_swap_ratio,
  swap_distance,
  propose_from_prior,
  shape1,
  shape2,
  possible_exposure_times,
  possible_exposure_times_indices,
  sample_times,
  type_data_start,
  biomarker_groups,
  sample_data_start,
  antibody_data_start,
  nrows_per_sample,
  cum_nrows_per_individual_in_data,
  cum_nrows_per_individual_in_repeat_data,
  group_id_vec,
  biomarker_id_indices,
  start_level_indices,
  starting_antibody_levels,
  births,
  antigenic_map_long,
  antigenic_map_short,
  antigenic_distances,
  antibody_data,
  antibody_data_repeats,
  n_measurements_total,
  repeat_indices,
  repeat_data_exist,
  measurement_shifts,
  proposal_iter,
  accepted_iter,
  proposal_swap,
  accepted_swap,
  overall_swap_proposals,
  overall_add_proposals,
  time_sample_probs,
  total_alive,
  data_types,
  obs_weights,
  temp = 1,
  solve_likelihood = TRUE
)

Arguments

theta

NumericVector, the named model parameters used to solve the model

infection_history_mat

IntegerMatrix the matrix of 1s and 0s corresponding to individual infection histories

likelihoods_pre_proposal

NumericVector, the current likelihoods for each individual before proposing new infection histories

sampled_indivs

IntegerVector, indices of sampled individuals

n_times_samp_vec

int, for each individual, how many time periods to resample infections for?

age_mask

IntegerVector, length of the number of individuals, with indices specifying first time period that an individual can be infected (indexed from 1, such that a value of 1 allows an individual to be infected in any time period)

sample_mask

IntegerVector, length of the number of individuals, with indices specifying last time period that an individual can be infected (ie. last time a sample was taken)

n_alive

IntegerMatrix, number of columns is the number of time periods that an individual could be infected, giving the number of individual alive in each time period. Number of rows is the number of distinct groups.

n_infections

IntegerMatrix, the number of infections in each year (columns) for each group (rows)

n_infected_group

IntegerVector, the total number of infections across all times in each group

prior_lookup

arma::cube, the pre-computed lookup table for the beta prior on infection histories, dimensions are number of infections, time, and group

proposal_inf_hist_indiv_swap_ratio

double, gives the proportion of proposals that will be swap steps (ie. swap contents of two cells in infection_history rather than adding/removing infections)

swap_distance

int, in a swap step, how many time steps either side of the chosen time period to swap with

shape1

double, shape1 (alpha) parameter for beta prior on infection probability

shape2

double, shape2 (beta) parameter for beta prior on infection probability

possible_exposure_times

NumericVector, the times that individuals could be infected

possible_exposure_times_indices

IntegerVector, indexing vector from 0:(number of exposure times-1)

sample_times

NumericVector, the vector of real times that samples were taken

cum_nrows_per_individual_in_data

IntegerVector, How many rows in the antibody data correspond to each individual?

cum_nrows_per_individual_in_repeat_data

IntegerVector, For the repeat data (ie. already calculated these antibody levels), how many rows in the antibody data correspond to each individual?

group_id_vec

IntegerVector, vector with 1 entry per individual, giving the group ID of that individual

biomarker_id_indices

IntegerVector, For each antibody measurement, corresponding entry in antigenic map

antigenic_map_long

arma::mat, the collapsed cross reactivity map for long term boosting, after multiplying by sigma1, see create_cross_reactivity_vector

antigenic_map_short

arma::mat, the collapsed cross reactivity map for short term boosting, after multiplying by sigma2, see create_cross_reactivity_vector

antigenic_distances

NumericVector matching the dimensions of antigenic_map_long and antigenic_map_short, but with the raw antigenic distances between strains

antibody_data

NumericVector, data for all individuals for the first instance of each calculated antibody level

antibody_data_repeats

NumericVector, the repeat antibody data for all individuals (ie. do not solve the same antibody level twice)

repeat_indices

IntegerVector, which index in the main data vector does each entry in repeat_data correspond to ie. which calculated antibody level in predicted_antibody_levels should be used for each observation?

measurement_shifts

NumericVector, if length matches the length of data, adds these as measurement shifts to the antibody levels. If lengths do not match, is not used.

proposal_iter

IntegerVector, vector with entry for each individual, storing the number of infection history add/remove proposals for each individual.

accepted_iter

IntegerVector, vector with entry for each individual, storing the number of accepted infection history add/remove proposals for each individual.

proposal_swap

IntegerVector, vector with entry for each individual, storing the number of proposed infection history swaps

accepted_swap

IntegerVector, vector with entry for each individual, storing the number of accepted infection history swaps

total_alive

IntegerVector, giving the total number of potential infection events for each group. This only applies to prior version 4. If set to a vector of values -1, then this is ignored.

temp

double, temperature for parallel tempering MCMC

solve_likelihood

bool, if FALSE does not solve likelihood when calculating acceptance probability

rows_per_indiv_in_samples

IntegerVector, How many rows in antibody data correspond to each individual, sample and repeat?

nrows_per_blood_sample

IntegerVector, Split the sample times and runs for each individual

data_type

int, defaults to 1 for discretized, bounded data. Set to 2 for continuous, bounded data

Value

an R list with 6 entries: 1) the vector replacing likelihoods_pre_proposal, corresponding to the new likelihoods per individual; 2) the matrix of 1s and 0s corresponding to the new infection histories for all individuals; 3-6) the updated entries for proposal_iter, accepted_iter, proposal_swap and accepted_swap.

See Also

Other infection_history_proposal: inf_hist_prop_prior_v3()


seroanalytics/serosolver documentation built on April 26, 2024, 1:19 a.m.