
Set condition_change_action for a whole residual covariance block
Source: R/define_condition_change_action.R
define_condition_change_action.Rdcondition_change_action decides what add_phenotype() does when a
correlated phenotype's stored residual was drawn under a different residual
condition_level than the current record resolves to — an animal that moved
farms between two records, say. It is a property of the residual
covariance block, not of one phenotype: D6 requires every member of a
block to carry the same value, so this function is the only way to change it
once a block of two or more exists.
Usage
define_condition_change_action(
pop,
phenotype_name,
condition_change_action = c("error", "independent")
)Details
define_phenotype() sets the value at registration time, when the phenotype
is still a block of one. Afterwards the two are locked together — flipping
either one alone through define_phenotype(overwrite = TRUE) would leave
the block disagreeing, which D6 refuses, and restating the phenotype would
reset every other column of its phenotype_meta row along the way. This
function changes exactly one column, on every member, in one transaction.
Unlike the covariance matrix itself, the action is not locked by
realized draws (D3). It governs how future records condition on stored
residuals and says nothing about the ones already drawn, so changing it
mid-simulation is legitimate and leaves ind_phenotype and
phenotype_random_effects untouched.
Examples
if (FALSE) { # \dontrun{
# A and B share a farm-conditioned residual block, both at the default
# "error". An animal that changes farms between records should now be
# drawn independently of its stale residual rather than stopping the run.
pop <- define_condition_change_action(pop, "A", "independent")
# -> also set on B (same residual covariance block)
} # }