nslphom {lphom}R Documentation

Implements nslphom algorithm

Description

Estimates RxC (JxK) vote transfer matrices (ecological contingency tables) with nslphom

Usage

nslphom(
  votes_election1,
  votes_election2,
  new_and_exit_voters = c("raw", "regular", "ordinary", "enriched", "adjust1", "adjust2",
    "simultaneous", "semifull", "full", "fullreverse", "gold"),
  apriori = NULL,
  lambda = 0.5,
  uniform = TRUE,
  iter.max = 10,
  min.first = FALSE,
  structural_zeros = NULL,
  integers = FALSE,
  distance.local = c("abs", "max", "none"),
  verbose = TRUE,
  solver = "lp_solve",
  integers.solver = "symphony",
  burnin = 0,
  tol = 10^-5,
  ...
)

Arguments

votes_election1

data.frame (or matrix) of order IxJ1 with the votes gained by (or the counts corresponding to) the J1 political options competing (available) on election 1 (or origin) in the I units considered. In general, the row marginals of the I tables corresponding to the units.

votes_election2

data.frame (or matrix) of order IxK2 with the votes gained by (or the counts corresponding to) the K2 political options competing (available) on election 2 (or destination) in the I (territorial) units considered. In general, the column marginals of the I tables corresponding to the units.

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.

apriori

data.frame (or matrix) of order J0xK0 with an initial estimate of the (row-standarized) global voter transition proportions/fractions, pjk0, between the first J0 (election) options of election 1 and the first K0 (election) options of election 2. This matrix can contain some missing values. When no a priori information is available apriori is a null object. Default, NULL.

lambda

A number between 0 and 1, informing the relative weight the user assigns to the apriori information. Setting lambda = 0 is equivalent to not having a priori information (i.e., apriori = NULL). Default, 0.5.

uniform

A TRUE/FALSE value that informs whether census exits impact all the electoral options in a (relatively) similar fashion in all iterations, including iteration 0 and when deriving units tables. If uniform = TRUE typically at least one of the equations among equations (6) to (11) of Pavia (2023) is included in the underlying model. This parameter has no effect in simultaneous scenarios. It also has not impact in raw and regular scenarios when no net exits are estimated by the function from the provided information. Default, TRUE.

iter.max

Maximum number of iterations to be performed. The process ends when either the number of iterations reaches iter.max or when the maximum variation between two consecutive estimates of the probability transfer matrix is less than tol. By default, 10.

min.first

A TRUE/FALSE value. If min.first = FALSE, the matrix associated with the minimum HETe after performing iter.max iterations is taken as solution. If min.first = TRUE, the associated matrix to the instant in which the first decrease of HETe occurs is taken as solution. The process stops at that moment. In this last scenario (when min.first = TRUE), burnin = 0 is forced and iter.max is at least 100. Default, FALSE.

structural_zeros

Default NULL. A list of vectors of length two, indicating the election options for which no transfer of votes are allowed between election 1 and election 2. For instance, when new_and_exit_voters is set to "semifull", lphom implicitly states structural_zeros = list(c(J1, K2)).

integers

A TRUE/FALSE value that indicates whether the problem is solved in integer values in both iterations, including iteration zero (lphom) and the rest of iterations, when deriving unit tables solutions. If integers = TRUE, the LP matrices are approximated to the closest integer solution solving the corresponding Integer Linear Program. Default, FALSE.

distance.local

A string argument that indicates whether the second step of the lphom_local algorithm should be performed to solve potential indeterminacies of local solutions. Default, "abs". If distance.local = "abs" lphom_local selects in its second step the matrix closer to the temporary global solution under L_1 norm, among the first step compatible matrices. If distance.local = "max" lphom_local selects in its second step the matrix closer to the temporary global solution under L_Inf norm, among the first step compatible matrices. If distance.local = "none", the second step of lphom_local is not performed.

verbose

A TRUE/FALSE value that indicates if a summary of the results of the computations performed to estimate net entries and exits should be printed on the screen. 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.solver

A character string indicating the linear programming solver to be used to approximate 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.

burnin

Number of initial solutions to be discarded before determining the final solution. By default, 0.

tol

Maximum deviation allowed between two consecutive iterations. The process ends when the maximum variation between two proportions for the estimation of the transfer matrix between two consecutive iterations is less than tol or the maximum number of iterations, iter.max, has been reached. By default, 0.00001.

...

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 J'xK' (where J'=J-1 or J and K'=K-1 or K) 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 in all units, net entries are omitted (i.e., the number of rows of VTM is equal to 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 in all units, net exits are omitted (i.e., the number of rows of VTM is equal to K2) even when estimates for net exits different from zero are obtained.

VTM.votes

A matrix of order J'xK' (where J'=J-1 or J and K'=K-1 or K) 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.

OTM

A matrix of order KxJ with the estimated percentages of the origin of the votes obtained for the different options of election 2.

HETe

The estimated heterogeneity index as defined in equation (15) of Pavia and Romero (2022).

VTM.complete

A matrix of order JxK with the estimated proportions of row-standardized vote transitions from election 1 to election 2, including in regular and raw scenarios the row and the column corresponding to net_entries and net_exits even when they are really small, less than 1% in all units.

VTM.complete.votes

A matrix of order JxK with the estimated vote transitions from election 1 to election 2, including in regular and raw scenarios the row and the column corresponding to net_entries and net_exits even when they are really small, less than 1% in all units.

VTM.sequence

Array of order JxKx(iter+1) (where iter is the efective number of iterations performed) of the estimated matrices corresponding to each iteration.

HETe.sequence

Numeric vector of length iter+1 with the HETe coefficients corresponding to the matrices in VTM.sequence.

VTM.prop.units

An array of order JxKxI with the estimated proportions of vote transitions from election 1 to election 2 attained for each unit in the selected iteration.

VTM.votes.units

An array of order JxKxI with the estimated matrix of vote transitions from election 1 to election 2 attained for for each unit in the selected iteration.

zeros

A list of vectors of length two, indicating the election options for which no transfer of votes are allowed between election 1 and election 2.

iter

The real final number of iterations performed before ending the process.

iter.min

Number of the iteration associated to the selected VTM solution.

deterministic.bounds

A list of two matrices of order JxK and two arrays of order JxKxI containing for each vote transition the lower and upper allowed proportions given the observed aggregates.

inputs

A list containing all the objects with the values used as arguments by the function.

origin

A matrix 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 matrix 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.

EHet

A matrix of order IxK measuring in each spatial unit a distance to the homogeneity hypothesis, that is, the differences under the homogeneity hypothesis between the actual recorded results and the expected results with the solution in each territorial unit for each option of election 2.

solution_init

A list with the main outputs produced by lphom().

Author(s)

Jose M. Pavia, pavia@uv.es

Rafael Romero rromero@eio.upv.es

References

Pavia, JM, and Romero, R (2022). Improving estimates accuracy of voter transitions. Two new algorithms for ecological inference based on linear programming, Sociological Methods & Research. doi:10.1177/00491241221092725.

See Also

lphom tslphom lclphom rslphom

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

Examples

mt.ns <- nslphom(France2017P[, 1:8] , France2017P[, 9:12], new_and_exit_voters= "raw")
mt.ns$VTM
mt.ns$HETe
mt.ns$solution_init$HETe_init


[Package lphom version 0.3.5-5 Index]