nslphom_dual: Implements the nslphom_dual algorithm

View source: R/nslphom_dual.R

nslphom_dualR Documentation

Implements the nslphom_dual algorithm

Description

Estimates RxC vote transfer matrices (ecological contingency tables) with nslphom_dual

Usage

nslphom_dual(
  votes_election1,
  votes_election2,
  iter.max = 10,
  min.first = FALSE,
  integers = FALSE,
  solver = "lp_solve",
  integers.solver = "symphony",
  tol = 10^-5,
  ...
)

Arguments

votes_election1

data.frame (or matrix) of order IxJ with the counts to be initially mapped to rows. When estimating vote transfer matrices, the votes gained by the J political options competing on election 1 (or origin) in the I territorial units considered. The sum by rows of votes_election1 and votes_election2 must coincide.

votes_election2

data.frame (or matrix) of order IxK with the counts to be initially mapped to columns. When estimating vote transfer matrices, the votes gained by the K political options competing on election 2 (or destination) in the I territorial units considered. In general, The sum by rows of votes_election1 and votes_election2 must coincide.

iter.max

Maximum number of iterations to be performed in each dual linear program. The process ends independently in each system 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 FALSE, the matrix associated with the minimum HETe after performing iter.max iterations is taken as solution. If 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), iter.max is is forced to be at least 100. Default, FALSE.

integers

A TRUE/FALSE value that indicates whether the problem is solved in integer values in each iteration: zero (lphom) and intermediate and final (including unit) solutions. If TRUE, the initial LP matrices are approximated in each iteration to the closest integer solution solving the corresponding Integer Linear Program. Default, FALSE.

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.

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.

Value

A list with the following components

VTM.votes.w

The matrix of order JxK with the estimated cross-distribution of votes of elections 1 and 2, attained weighting the two dual solutions using as weights the corresponding HTEe estimates.

VTM.votes.units.w

The array of order JxKxI with the local estimated cross-distributions of votes of elections 1 and 2 by unit, attained weighting the two dual solutions using as weights the corresponding HTEe estimates.

VTM.votes.a

The matrix of order JxK with the estimated cross-distribution of votes of elections 1 and 2, attained simple averaging the two dual solutions.

VTM.votes.units.a

The matrix of order JxKxI with the estimated cross-distributions of votes of elections 1 and 2 by unit, attained weighting the two dual solutions using as weights the corresponding HTEe estimates.

HETe.w

Estimated heterogeneity index associated to the VTM.votes.w solution.

HETe.a

Estimated heterogeneity index associated to the VTM.votes.a solution.

VTM12.w

The matrix of order JxK with the estimated row-standardized proportions of vote transitions from election 1 to election 2 associated to the VTM.votes.w solution.

VTM21.w

The matrix of order KxJ with the estimated row-standardized proportions of vote transitions from election 2 to election 1 associated to the VTM.votes.w solution.

VTM12.a

The matrix of order JxK with the estimated row-standardized proportions of vote transitions from election 1 to election 2 associated to the VTM.votes.a solution.

VTM21.a

The matrix of order KxJ with the estimated row-standardized proportions of vote transitions from election 2 to election 1 associated to the VTM.votes.a solution.

nslphom.object.12

The output of the nslphom function attained solving the problem X –> Y, that is, mapping votes_election1 to rows and votes_election2 to columns.

nslphom.object.21

The output of the nslphom function attained solving the problem Y –> X, that is, mapping votes_election2 to rows and votes_election1 to columns.

inputs

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

Author(s)

Jose M. Pavia, pavia@uv.es

Rafael Romero rromero@eio.upv.es

References

Pavia, JM and Romero, R (2021). Symmetry estimating R×C vote transfer matrices from aggregate data, mimeo.

See Also

nslphom lphom_dual tslphom_dual lphom_joint tslphom_joint nslphom_joint

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

Examples

x <- France2017P[, 1:8]
y <- France2017P[, 9:12]
y[,1] <- y[,1]  - (rowSums(y) - rowSums(x))
mt <- nslphom_dual(x, y)
mt$VTM.votes.w
mt$HETe.w


lphom documentation built on March 21, 2022, 9:09 a.m.

Related to nslphom_dual in lphom...