Creates a "shadow population" for comparative data analysis.
"What's a shadow population?" I hear you ask?
It's a bit like a control group in an experiment, drawn from an existing defined population dataset.
Imagine you are asked to report on activity relating to a particular population where there has been some kind of intervention or treatment applied. As part of the evaluation of the intervention, you would like to compare these activity outcomes against the activity of a similar, but separate, population. This secondary population is what I am calling a shadow population.
You want the shadow population to have a similar distribution of certain key (independent) variables to your primary population. For example, you may want to generate a population that lives in areas that have a similar overall socio-economic profile as your primary population. Or you may want the age or gender profile to be as similar as possible. Or any other variable that you think matters.
I'm assuming that the primary population and the shadow population can both be drawn from a single overall dataset, for example patients registered at a hospital or students at a college. It may not be possible to exactly mirror the distribution of these variables in the shadow population, but {shadowpop} helps you get as close as possible.
At the R console:
remotes::install_git("https://codeberg.org/francisbarton/shadowpop")
There is currently just a single user-facing function, shadowpop().
Use
?shadowpop
to access the help file.
You will need to provide a sample_data data frame, a source_data data frame, and a list of columns match_cols (shared between sample and source) to use as the basis for matching the shadow population to the sample data.
You can optionally also supply the name of an id_col column (which uniquely identifies each row in the sample and source data), and a custom size shadow_size for your shadow population.
shadowpop(sample_data, source_data, match_cols, id_col, shadow_size)
See the "outline" vignette for more detail.