
Find a Replacement Candidate of the Opposite Gender
Source:R/fn_get.R
findOppositeGenderReplacementForCandidate.RdIdentifies an available candidate of the opposite gender that most closely resembles a supplied candidate.
Arguments
- object
A
ReplicaStructureobject.- wrong_candidate
Candidate requiring replacement.
- mask
Logical eligibility mask.
- position
Household-position category to search.
Value
A single-row data frame or data.table containing the selected replacement candidate.
Returns NULL if no suitable replacement exists.
Details
This function supports fallback partner-matching behaviour within replica when the preferred gender composition cannot be achieved directly from the primary candidate pool.
Candidate selection is restricted to agents who:
Occupy the specified household-position category.
Have the opposite gender.
Have not already been assigned.
Candidates are ranked according to a simple similarity score based on matching demographic and household characteristics.