samplePartners: Sample partners

View source: R/fakeunion_functions.r

samplePartnersR Documentation

Sample partners

Description

This function will draw a set of counterfactual partners for a given set of real unions. It is primarily intended for internal use by the generateCouples functiom.

Usage

samplePartners(actual, eligibles, n, partner, weight = NULL, id = "id")

Arguments

actual

a data.frame of actual unions identical in structure to that for generateCouples.

eligibles

a data.frame of eligible partners to be sampled. This should have the same structure as that for generateCouples.

n

The number of alternate partners to sample for each real spouse.

partner

a character sting of either "h" or "w" indicating which type of partner should be sampled.

weight

optional name of weights variable in eligibles that allows for different probabilities of sampling eligible partners. If left out then sampling will be done with equal probability

id

a character string indicating the first part of the variable name for the id to identify indidividuals in actual and eligibles. Identical to the argument in generateCouples.

Details

This function uses the wrswoR package for fast weighted sampling without replacement. In addition, for speed, the initial matching is done without concern for potentially sampling the correct partner from the set of alternate partners. This is then checked and removed in a secondary stage for the rare cases where such duplication occurs.

Value

a data.frame object similar to actual but containing only counterfactual unions.


AaronGullickson/fakeunion documentation built on Aug. 6, 2023, 7:19 p.m.