lp_apriori | R Documentation |
Adjusts an initial J0xK0 vote transfer matrix (ecological contingency table) to guarantee (i) congruency with aggregate results and (ii) completeness.
lp_apriori( votes_election1, votes_election2, apriori, weights = "constant", new_and_exit_voters = "raw", uniform = TRUE, solver = "lp_solve", integers = TRUE, integers.solver = "symphony", ... )
votes_election1 |
data.frame (or matrix) of order IxJ1 (or vector of length J1) with the votes gained by (or the numbers corresponding to) the J1 political options competing on election 1 (or origin) in the I territorial units considered. |
votes_election2 |
data.frame (or matrix) of order IxK2 (or vector of length K2) with the votes gained by (or the numbers corresponding to) the K2 political options competing on election 2 (or destination) in the I territorial units considered. |
apriori |
data.frame (or matrix) of order J0xK0 with an initial estimate of the (row-standarized) voter transition proportions/factions, pjk0, between the first J0 election options of election 1 and the first K0 election options of election 2. It could be also a data.frame (matrix) of counts. This matrix can contain some missing values. |
weights |
Either a numeric matrix (or data.frame) of order J0xK0 of weights, wjk, or
a character string indicating the structure of weights to be used. As character
string this argument admits seven different values: |
new_and_exit_voters |
A character string indicating the level of information available
regarding new entries and exits of the election censuses between the
two elections. This argument captures the different options discussed
in Pavia (2022). This argument admits eight values:
|
uniform |
A TRUE/FALSE value that indicates if census exits affect all the electoral options in
a (relatively) similar fashion; depending on the scenario any equation(s) among equations (6) to (11) of
Pavia (2022) could be used in the underlying model. Default, |
solver |
A character string indicating the linear programming solver to be used, only
|
integers |
A TRUE/FALSE value that indicates whether the LP solution of counts (votes) must be approximate to the closest integer solution using ILP to generate the final solution. Default, TRUE. |
integers.solver |
A character string indicating the linear programming solver to be used to
to the closest integer solution, only |
... |
Other arguments to be passed to the function. Not currently used. |
Description of the new_and_exit_voters
argument in more detail.
raw
: The default value. This argument accounts for the most plausible scenario when
adjusting vote transfer matrices. A scenario with two elections elapsed at least
some months where only the raw election data recorded in I territorial units
(where I can be equal to one), in which the area under study is divided, are
available. In this scenario, net exits and net entries are estimated according to
equation (7) of Romero et al. (2020). When both net entries and exits are no
null, constraint (15) of Pavia (2022) applies. If uniform = TRUE
constraints
(7) of Pavia (2022) are also imposed. In this scenario, J could be equal to J1 or
J1 + 1 and K equal to K2 or K2 + 1.
simultaneous
: This is the value to be used in simultaneous elections and when the user
is interested in adjusting other type of transfer matrices such as the one that typically arise in
classical ecological inference problems, In this scenario, the sum by rows of
votes_election1
and votes_election2
must coincide. In this case, the function
just implements the basic model defined by equations (1) to (5) of Pavia (2022).
regular
: This value accounts for a scenario with
two elections elapsed at least some months where (i) the column J1
of votes_election1
corresponds to new young electors who have the right
to vote for the first time, (ii) net exits and maybe other additional
net entries are computed according to equation (7) of Romero et al. (2020), and
(iii) we can (or not) assume that net exits affect equally all the first J1 - 1
options of election 1. When both net entries and exits are no null, constraints
(12) and (15) of Pavia (2022) apply and if uniform = TRUE
constraints
(11) of Pavia (2022) are also imposed. In this scenario, J could be equal
to J1 or J1 + 1 and K equal to K2 or K2 + 1.
ordinary
: This value accounts for a scenario
with two elections elapsed at least some months where (i) the column K1
of votes_election2
corresponds to electors who died in the interperiod
election, (ii) net entries and maybe other additional net exits are
computed according to equation (7) of Romero et al. (2020), and (iii) we can
assume that exits affect equally all the J1 options of election 1.
When both net entries and exits are no null, constraints (13) and
(15) of Pavia (2022) apply and if uniform = TRUE
constraints
(8) and (9) of Pavia (2022) are also imposed. In this scenario, J could be equal
to J1 or J1 + 1 and K equal to K2 or K2 + 1.
enriched
: This value accounts for a scenario that somewhat combine regular
and
ordinary
ecenarios. We consider two elections elapsed at least some months where
(i) the column J1 of votes_election1
corresponds to new young electors
who have the right to vote for the first time, (ii) the column K1 of
votes_election2
corresponds to electors who died in the interperiod
election, (iii) other (net) entries and (net) exits are computed according
to equation (7) of Romero et al. (2020), and (iv) we can assume
(or not) that exits affect equally all the J1 - 1 options of election 1.
When both net entries and exits are no null, constraints (12) to
(15) of Pavia (2022) apply and if uniform = TRUE
constraints
(10) and (11) of Pavia (2022) are also imposed. In this scenario, J could be equal
to J1 or J1 + 1 and K equal to K2 or K2 + 1.
semifull
: This value accounts for a scenario with two elections elapsed at least some
months, where: (i) the column J of votes_election1
totals new
electors (young and immigrants) that have the right to vote for the first time and
(ii) the column K of votes_election2
corresponds to total exits of the census
lists (due to death or emigration). In this scenario, the sum by rows of
votes_election1
and votes_election2
must agree and constraint (15)
of Pavia (2022) apply. Additionally, if uniform = TRUE
constraints
(8) of Pavia (2022) are also imposed.
full
: This value accounts for a scenario with two elections elapsed at least some
months, where (i) the column J - 1 of votes_election1
totals new young
electors that have the right to vote for the first time, (ii) the column J
of votes_election1
measures new immigrants that have the right to vote and
(iii) the column K of votes_election2
corresponds to total exits of the census
lists (due to death or emigration). In this scenario, the sum by rows of
votes_election1
and votes_election2
must agree and constraints (13)
and (15) of Pavia (2022) apply. Additionally, if uniform = TRUE
constraints
(11) of Pavia (2022) are also imposed.
gold
: This value accounts for a scenario similar to full, where total exits are
separated out between exits due to emigration (column K - 1 of votes_election2
)
and death (column K of votes_election2
). In this scenario, the sum by rows
of votes_election1
and votes_election2
must agree. Constraints (12) to
(15) of Pavia (2022) apply and if uniform = TRUE
constraints (10) and (11)
of Pavia (2022) are also imposed.
A list with the following components
VTM |
A matrix of order JxK with the estimated percentages of row-standardized vote transitions from election 1 to election 2.
In |
VTM.votes |
A matrix of order JxK with the estimated vote transitions from election 1 to election 2.
In |
weights |
A matrix of order JxK with the weights used to adjust the a priori vote transitions from election 1 to election 2. |
OTM |
A matrix of order KxJ with the estimated percentages of the origin of the votes obtained for the different options of election 2. |
VTM.complete |
A matrix of order JxK with the estimated proportions of row-standardized vote transitions from election 1 to election 2.
In |
VTM.complete.votes |
A matrix of order JxK with the estimated vote transitions from election 1 to election 2.
In |
inputs |
A list containing all the objects with the values used as arguments by the function. |
origin |
A vector with the final data used as votes of the origin election after taking into account the level of information available regarding to new entries and exits of the election censuses between the two elections. |
destination |
A vector with the final data used as votes of the origin election after taking into account the level of information available regarding to new entries and exits of the election censuses between the two elections. |
Jose M. Pavia, pavia@uv.es
Pavia, JM (2022). Adjusting initial estimates of voter transition probabilities to guarantee consistency and completeness. The function lp_apriori of the R-package lphom.
lphom
tslphom
nslphom
lclphom
Other linear programing ecological inference functions:
lclphom()
,
lphom_dual()
,
lphom_joint()
,
lphom()
,
nslphom_dual()
,
nslphom_joint()
,
nslphom()
,
tslphom_dual()
,
tslphom_joint()
,
tslphom()
P0 <- matrix(c(.75, .02, .15, .08, .01, .01, .97, .01, .01, .01, .01, .97, .01, .10, .80, .09, .20, .30, .30, .20, .10, .10, .50, .30, .10, .30, NA, NA, .25, .20, NA, NA), byrow = TRUE, 8, 4) mt <- lp_apriori(France2017P[, 1:8], France2017P[, 9:12], P0, integers = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.