philmikejones / rakeR

Tools for easy spatial microsimulation (raking) in R
http://philmikejones.github.io/rakeR/
11 stars 1 forks source link

Check all `cons` populations match #78

Open philmikejones opened 5 years ago

philmikejones commented 5 years ago

In rk_weight():

# The sum of weights will form the simulated population so this must match
  # the population from cons
  if (!isTRUE(all.equal(sum(weights), (sum(cons) / length(vars))))) {
    stop("Weight populations don't match constraint populations.
          Usually this means the populations for each of your constraints
          are slightly different\n",
         "Sum of simulated population:  ", sum(weights), "\n",
         "Sum of constraint population: ", (sum(cons) / length(vars)))
  }