ecolRxC {ecolRxC}R Documentation

Ecological Inference of RxC Tables by Latent Structure Approaches

Description

Estimates JxK (RxC) vote transfer matrices (ecological contingency tables) based on Thomsen (1987) and Park (2008) approaches.

Usage

ecolRxC(
  votes.election1,
  votes.election2,
  scale = "probit",
  method = "Thomsen",
  local = TRUE,
  census.changes = c("adjust", "raw", "regular", "ordinary", "enriched",
    "simultaneous", "semifull", "full", "gold"),
  reference = NULL,
  confidence = NULL,
  B = 500,
  Yule.aprox = FALSE,
  tol = 1e-06,
  ...
)

Arguments

votes.election1

data.frame (or matrix) of order IxJ1 with the votes gained by (or the counts corresponding to) the J1 (social classes) political options competing (available) on election 1 (or origin) in the I units considered.

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.

scale

A character string indicating the type of transformation to be applied to the vote fractions for applying ecological inference. Only logit and probit are allowed. Default, probit.

method

A character string indicating the algorithm to be used for adjusting (making congruent with the observed margins) the initial crude fractions attained in a 2x2 fashion. Only Thomsen (see sec. 4.3 in Thomsen, 1987) and IPF (iterative proportional fitting, also known as raking) are allowed. This argument has no effect in the 2x2 case. Default, Thomsen.

local

A TRUE/FALSE argument indicating whether local solutions (solutions for each polling unit) must be computed. In that case, the global solution is attained as composition/aggregation of local solutions. When method = "Thomsen" local solutions are always computed. Default TRUE.

census.changes

A character string informing about the level of information available in votes.election1 and votes.election2 regarding new entries and exits of the election censuses between the two elections or indicating how their sum discrepancies should be handled. This argument allows the eight options discussed in Pavia (2022) as well as an adjusting option. This argument admits nine values: adjust, raw, regular, ordinary, simultaneous, enriched, semifull, full and gold. See Details. Default, adjust.

reference

A vector of two components indicating (parties) options in election 1 and 2, respectively, to be used as reference with method = "Thomsen". This has not effect with method = "IPF". The references can be indicated by name or by position. If reference = NULL, the final solution is constructed as a weighted average of all the congruent solutions attained after considering as references all combinations of options. Default NULL.

confidence

A number between 0 and 1 to be used as level of confidence for the confidence intervals of the transition rates. By default NULL. If confidence = NULL, confidence intervals are not computed.

B

An integer indicating the number of samples to be drawn from each crude estimated confidence interval for estimating final confidence intervals when either R (J) or C (K) is higher than two. This is not relevant for the 2x2 case. It can take a while to compute confidence intervals, mainly when method = Thomsen. In general computation burden grows with B. Default, 500.

Yule.aprox

TRUE/FALSE argument indicating if either Thomsen (1987)'s formula (3.44), based on a binormal, or Thomsen (1987)'s formula (3.46), based on Yule's approximation of tetrachoric correlation, should be use to estimate cross-proportions. Default FALSE, formula (3.44).

tol

A number indicating the level of precision to be used to stop the adjustment of initial/crude count estimates reached using a 2x2 approach in a general RxC case. This is not relevant for the 2x2 case. Default, 0.000001.

...

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

Details

Description of the census.changes argument in more detail.

Value

A list with the following components

VTM

A matrix of order JxK (RxC) with the estimated proportions of the 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). When local = TRUE (default), this matrix is obtained as composition of the local solutions.

VTM.votes

A matrix of order JxK (RxC) with the estimated vote transfers 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). When local = TRUE (default), this matrix is obtained as aggregation of the local solutions.

VTM.global

A matrix of order JxK (RxC) with the estimated proportions of the row-standardized vote transitions from election 1 to election 2, attained directly from the global (whole electoral space) proportions. When local = FALSE. VTM and VTM.global coincide. 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).

VTM.votes.global

A matrix of order JxK (RxC) with the estimated vote transfers from election 1 to election 2, attained directly from the global proportions. When local = FALSE, VTM.votes and VTM.votes.global coincide. 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).

VTM.lower

A matrix of order JxK (RxC) with the estimated lower limits of the confidence intervals for the proportions of the 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). When confidence = NULL this is a NULL object.

VTM.upper

A matrix of order JxK (RxC) with the estimated upper limits of the confidence intervals for the proportions of the 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). When confidence = NULL this is a NULL object.

VTM.crude.global

A matrix of order JxK (RxC) with the (inconsistent) crude estimated proportions for the row-standardized vote transitions from election 1 to election 2 in the whole space attained in a 2x2 fashion before making them consistent using the iterative proportional fitting algorithm or the Thomsen iteratuve algortihm. 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).

VTM.units

An array of order JxKxI (RxCxI) with the estimated proportions of the row-standardized vote transitions from election 1 to election 2 attained for each unit. When local = FALSE, this is a NULL object. In raw, regular, ordinary and enriched scenarios, each unit matrix includes the row and the column corresponding to net entries and net exits (when they are present).

VTM.votes.units

An array of order JxKxI (RxCxI) with the estimated transfer of votes from election 1 to election 2 attained for each unit. When local = FALSE, this is a NULL object. In raw, regular, ordinary and enriched scenarios, each unit matrix includes the row and the column corresponding to net entries and net exits (when they are present).

VTM.lower.units

An array of order JxKxI (RxCxI) with the estimated lower limits of the confidence intervals for the proportions of the row-standardized vote transitions from election 1 to election 2 corresponding to each unit. When either local = FALSE or confidence = NULL, this is a NULL object. In raw, regular, ordinary and enriched scenarios, each unit matrix includes the row and the column corresponding to net entries and net exits (when they are present).

VTM.upper.units

An array of order JxKxI (RxCxI) with the estimated upper limits of the confidence intervals for the proportions of the row-standardized vote transitions from election 1 to election 2 corresponding to each unit. When either local = FALSE or confidence = NULL, this is a NULL object. In raw, regular, ordinary and enriched scenarios, each unit matrix includes the row and the column corresponding to net entries and net exits (when they are present).

VTM.crude.units

An array of order JxKxI (RxCxI) with the (inconsistent) crude estimated proportions of the row-standardized vote transitions from election 1 to election 2 attained for each unit in a 2x2 fashion before making them consistent using the iterative proportional fitting algorithm or the Thomsen iterative algorithm. When local = FALSE, this is a NULL object. In raw, regular, ordinary and enriched scenarios, each unit matrix includes the row and the column corresponding to net entries and net exits (when they are present).

correlations

A matrix of order JxK (Rxc) with the across units correlations between options for the proportions in the transformed scale.

reference.outputs

A list with three components: vjk.averages, vjk.by.reference and vjk.units.by.reference. The first component vjk.averages is a JxKx8 array with eight different global solutions of transfer matrix of votes attained after combining with different weights each of the solutions obtained using the different combinations of a row and a column option as reference. The second component vjk.by.reference is a JxKx(J1·K1) array with the J1K1 different global solutions of transfer matrix of votes attained after choosing as reference all the possible combination of a row and a column option. The third component vjk.units.by.reference is a JxKxIx(J1·K1) array with the local solutions linked to vjk.by.reference. When either method = "IPF" or reference is not NULL, this is a NULL object.

iter

A vector of either length 1 (when reference is different of NULL) or J1·K1 with the number of iterations needed by the Thomsen algorithm to reach convergence for each reference pair. When method = "Thomsen" this is a NULL object.

inputs

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

Note

This function somewhere builds on the .ado (STATA) functions written by Won-ho Park, in 2002.

Author(s)

Jose M. Pavia, pavia@uv.es

References

Achen, C.H. (2000). The Thomsen Estimator for Ecological Inference (Unpublished manuscript). University of Michigan.

Park, W.-H. (2008). Ecological Inference and Aggregate Analysis of Elections. PhD Dissertation. University of Michigan.

Pavia, J.M. (2022). Adjustment of initial estimates of voter transition probabilities to guarantee consistency and completeness.

Thomsen, S.R. (1987). Danish Elections 1920-79: a Logit Approach to Ecological Analysis and Inference. Politica, Aarhus, Denmark.

Examples

votes1 <- structure(list(P1 = c(16L, 4L, 13L, 6L, 1L, 16L, 6L, 17L, 48L, 14L),
                         P2 = c(8L, 3L, 0L, 5L, 1L, 4L, 7L, 6L, 28L, 8L),
                         P3 = c(38L, 11L, 11L, 3L, 13L, 39L, 14L, 34L, 280L, 84L),
                         P4 = c(66L, 5L, 18L, 39L, 30L, 57L, 35L, 65L, 180L, 78L),
                         P5 = c(14L, 0L, 5L, 2L, 4L, 21L, 6L, 11L, 54L, 9L),
                         P6 = c(8L, 2L, 5L, 3L, 0L, 7L, 7L, 11L, 45L, 17L),
                         P7 = c(7L, 3L, 5L, 2L, 3L, 17L, 7L, 13L, 40L, 8L)),
                         row.names = c(NA, 10L), class = "data.frame")
votes2 <- structure(list(C1 = c(2L, 1L, 2L, 2L, 0L, 4L, 0L, 4L, 19L, 14L),
                         C2 = c(7L, 3L, 1L, 7L, 2L, 5L, 3L, 10L, 21L, 6L),
                         C3 = c(78L, 7L, 28L, 42L, 28L, 84L, 49L, 85L, 260L, 100L),
                         C4 = c(56L, 14L, 20L, 7L, 19L, 54L, 22L, 50L, 330L, 91L),
                         C5 = c(14L, 3L, 6L, 2L, 3L, 14L, 8L, 8L, 45L, 7L)),
                         row.names = c(NA, 10L), class = "data.frame")
example <- ecolRxC(votes1, votes2, method = "IPF")$VTM


[Package ecolRxC version 0.1.1-10 Index]