lp_apriori {lphom}R Documentation

Implements lp_apriori models

Description

Adjusts an initial J0xK0 vote transfer matrix (ecological contingency table) to guarantee (i) congruency with aggregate results and (ii) completeness.

Usage

lp_apriori(
  votes_election1,
  votes_election2,
  apriori,
  weights = "constant",
  new_and_exit_voters = "raw",
  uniform = TRUE,
  solver = "lp_solve",
  integers = TRUE,
  integers.solver = "symphony",
  ...
)

Arguments

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/fractions, 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: constant, x, xy, expected, counts, sqrt, or sd. Default, constant (i.e., wjk = 1). The wjk coefficients measure the (relative) degree of confidence we have in the a priori values pjk0. Everything else constant, the greater a weight wjk the closer the estimated pjk and the pjk0 proportions will be. As numeric matrix, this matrix can contain some missing values, usually located in the same cells than the missing values of apriori.

new_and_exit_voters

A character string indicating the level of information available in votes_election1 and votes_election2 regarding new entries and exits of the election censuses between the two elections. This argument allows, in addition to the options discussed in Pavia (2023), three more options. This argument admits eleven different values: raw, regular, ordinary, enriched, adjust1, adjust2, simultaneous, semifull, full, fullreverse and gold. Default, raw.

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 (2023) could be used in the underlying model. Default, TRUE.

solver

A character string indicating the linear programming solver to be used, only lp_solve and symphony are allowed. By default, lp_solve. The package Rsymphony needs to be installed for the option symphony to be used.

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 for approximating to the closest integer solution. Only symphony and lp_solve are allowed. By default, symphony. The package Rsymphony needs to be installed for the option symphony to be used. Only used when integers = TRUE.

...

Other arguments to be passed to the function. Not currently used.

Details

Description of the new_and_exit_voters argument in more detail.

Value

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 raw, regular, ordinary and enriched scenarios when the percentage of net entries is small, less than 1% of the census, net entries are omitted (i.e., J = J1) even when estimates for net entries different from zero are obtained. Likewise, in the same scenarios when the percentage of net exits is small, less than 1% of the census, net exits are omitted (i.e., K = K2) even when estimates for net exits different from zero are obtained.

VTM.votes

A matrix of order JxK with the estimated vote transitions from election 1 to election 2. In raw, regular, ordinary and enriched scenarios when the percentage of net entries is small, less than 1% of the census, net entries are omitted (i.e., J = J1) even when estimates for net entries different from zero are obtained. Likewise, in the same scenarios when the percentage of net exits is small, less than 1% of the census, net exits are omitted (i.e., K = K2) even when estimates for net exits different from zero are obtained.

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 raw, regular, ordinary and enriched scenarios, this matrix includes the row and the column corresponding to net entries and net exits (when they are present) even when they are really small.

VTM.complete.votes

A matrix of order JxK with the estimated vote transitions from election 1 to election 2. In raw, regular, ordinary and enriched scenarios, this matrix includes the row and the column corresponding to net entries and net exits (when they are present) even when they are really small.

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.

Author(s)

Jose M. Pavia, pavia@uv.es

References

Pavia, JM (2023). Adjustment of initial estimates of voter transition probabilities to guarantee consistency and completeness, SN Social Sciences, 3, 75. doi:10.1007/s43545-023-00658-y.

See Also

lphom tslphom nslphom lclphom

Other linear programing ecological inference functions: lclphom(), lphom_dual(), lphom_joint(), lphom(), nslphom_dual(), nslphom_joint(), nslphom(), rslphom(), tslphom_dual(), tslphom_joint(), tslphom()

Examples

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)

[Package lphom version 0.3.5-5 Index]