CorrelationParameters | R Documentation |
Class: Correlation parameters
Class: Correlation parameters
This class implements functionality that allows interventions to be correlated, positively or negatively. By default, interventions are applied independently and an individual's probability of receiving two interventions (either two separate interventions or two rounds of the same one) is the product of the probability of receiving each one.
By setting a positive correlation between two interventions, we can make it so that the individuals that receive intervention A are more likely to receive intervention B. Conversely, a negative correlation will make it such that individuals that receive intervention A are less likely to also receive intervention B.
Broadly speaking, the implementation works by assigning at startup a weight to each individual and intervention pair, reflecting how likely an individual is to receive that intervention. Those weights are derived stochastically from the configured correlation parameters.
For a detailed breakdown of the calculations, see Protocol S2 of Griffin et al. (2010). Derive the mvnorm from the configured correlations.
If a restored_mvnorm
is specified, its columns (corresponding to
restored interventions) will be re-used as is. Missing columns (for new
interventions) are derived in accordance with the restored data.
new()
initialise correlation parameters
CorrelationParameters$new(population, interventions)
population
popularion size
interventions
character vector with the name of enabled interventions
inter_round_rho()
Add rho between rounds
CorrelationParameters$inter_round_rho(int, rho)
int
string representing the intervention to update
rho
value between 0 and 1 representing the correlation between rounds of the intervention
inter_intervention_rho()
Add rho between interventions
CorrelationParameters$inter_intervention_rho(int_1, int_2, rho)
int_1
string representing the first intervention
int_2
string representing the second intervention (intechangable with int_1)
rho
value between -1 and 1 representing the correlation between rounds of the intervention
sigma()
Standard deviation of each intervention between rounds
CorrelationParameters$sigma()
mvnorm()
multivariate norm draws for these parameters
CorrelationParameters$mvnorm()
save_state()
Save the correlation state.
CorrelationParameters$save_state()
restore_state()
Restore the correlation state.
Only the randomly drawn weights are restored. The object needs to be initialized with the same rhos.
CorrelationParameters$restore_state(timestep, state)
timestep
the timestep at which simulation is resumed. This parameter's value is ignored, it only exists to conform to a uniform interface.
state
a previously saved correlation state, as returned by the save_state method.
clone()
The objects of this class are cloneable with this method.
CorrelationParameters$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.