simula_BPF_with_deviations: Simulate RxC Square Tables with Ecological Fallacy Effects...

View source: R/simula_BPF_with_deviations.R

simula_BPF_with_deviationsR Documentation

Simulate RxC Square Tables with Ecological Fallacy Effects Based on Overdispersed-Multinomial Models

Description

Generates a set of RxC square (RxR) tables with the joint distribution of voters in two elections according to the model proposed by Forcina et al. (2012), an extension of Brown and Payne (1986), under the assumption that transition probabilities are non-homogeneous across units. The simulation procedure, detailed in Pavia and Forcina (2026), models voter behaviour in each unit using a unit-specific transition table. Each transition table is constructed as a mixture of probabilities representing four latent voter types: (i) voters who follow the global transition probabilities of the BPF model; (ii) largely loyal voters; (iii) strategic voters; and (iv) voters whose probability of remaining loyal depends on their party’s strength in the unit at the first election.

Usage

simula_BPF_with_deviations(
  n.units,
  TM,
  prop1,
  polling.sizes,
  theta1 = 0.1,
  theta2 = 0.1,
  cs = 50,
  prop.dev = c(0.4, 0.6),
  prop.loyal = matrix(0.34, nrow = ifelse(is.null(dim(n.units)), n.units, nrow(n.units)),
    ncol = nrow(TM)),
  prop.strategic = matrix(0.33, nrow = ifelse(is.null(dim(n.units)), n.units,
    nrow(n.units)), ncol = nrow(TM)),
  prop.context = matrix(0.33, nrow = ifelse(is.null(dim(n.units)), n.units,
    nrow(n.units)), ncol = nrow(TM)),
  par.loyal = 0.95,
  par.strategic = 0.5,
  par.context = 0.5,
  simplify = FALSE,
  ...
)

Arguments

n.units

Either a positive integer, K, indicating the number of polling units to be simulated, or a KxR data.frame (or matrix) giving the number of votes obtained in election 1 for each of the R options in each of the K units. If n.units is a matrix or data.frame of counts (votes), the values of arguments prop1 and theta1 are ignored.

TM

A row-standardized RxC matrix with the underlying global transition probabilities for the Overdispersed-Multinomial Model. If the matrix is not row-standardized, it is internally row-standardized by the function.

prop1

A vector of length R with the initial assumed probabilities of voting (to be simulated) for each of the R competing options in the first election. If the provided vector is not a set of probabilities (i.e., a vector of positive numbers adding to 1), it is internally standardized by the function.

polling.sizes

Either a vector of two components with two positive integer numbers indicating the minimum and maximum number of voters for each unit or a vector of length n.units of positive integer numbers informing about the number of voters in each unit. When polling.sizes is a vector of length two, a number of voters is randomly assigned for each unit using a uniform distribution with parameters the minimum and maximum values included in polling.sizes.

theta1

A number between 0 and 1 used as the overdispersion parameter. This parameter is employed by the underlying Dirichlet distribution, in conjunction with prop1, to randomly generate vectors of probabilities for each unit. These vectors are then used to simulate the results of the first election. The smaller the value of this parameter, the closer the unit-level marginal distributions for the first election are to prop1. Default, 0.1.

theta2

Either a single number between 0 and 1 or a vector of length nrow(TM) containing numbers between 0 and 1. The values in theta2 serve as overdispersion parameters and are used alongside the row-probability vectors in TM within the underlying Dirichlet distributions. These distributions are employed to generate probability vectors for each combination of unit, cluster, and row, which are then used to simulate vote transfers from the first to the second election. If theta2 is a vector, each row is assigned a distinct overdispersion parameter based on its corresponding value. Default, 0.1.

cs

A positive number indicating the average number of cluster size. Default, 50.

prop.dev

Either a two-component vector with positive values between 0 and 1, indicating the minimum and maximum proportion of voters (to be simulated) that deviate from the base Overdispersed-Multinomial Model in each unit or a vector of length n.units specifying the proportion of voters deviating from the basic model in each unit. If prop.dev is a two-component vector, the proportion of deviating voters in each unit is randomly assigned using a uniform distribution with the specified minimum and maximum values. Default, c(0.4, 0.6).

prop.loyal

A KxR matrix where each cell ⁠(k, r)⁠ represents the proportion of voters from party r in unit k who are strongly loyal. These voters are highly likely to vote for the same party with near certainty (see the parameter par.loyal). In contrast, the remaining prop.dev percent of the voters from the party follow the transition probabilities specified in TM. The sum of the matrices prop.loyal, prop.strategic, and prop.contextual must equal one for each cell. If this condition is not met, the function internally standardizes the provided matrices. Default, matrix(0.34, nrow = ifelse(is.null(dim(n.units)), n.units, nrow(n.units)), ncol = nrow(TM)).

prop.strategic

A KxR matrix where each cell ⁠(k, r)⁠ represents the proportion of voters from party r in unit k who are strategic voters. These voters are a par.strategic percent more likely to support parties that improve their results in the second election compared to their performance in their first election (see the parameter par.strategic). In contrast, the remaining prop.dev percent of the voters from the party follow the transition probabilities specified in TM. The sum of the matrices prop.loyal, prop.strategic, and prop.contextual must equal one for each cell. If this condition is not met, the function internally standardizes the provided matrices. Default, matrix(0.33, nrow = ifelse(is.null(dim(n.units)), n.units, nrow(n.units)), ncol = nrow(TM)).

prop.context

A KxR matrix where each cell ⁠(k, r)⁠ represents the proportion of voters from party r in unit k who are influenced by the relative strength in their neighborhood of the party they voted for in the first election. These voters are a par.context multiplied by the party's strength in the unit percent more likely to support the same party in the second election (see the parameter par.context). In contrast, the remaining prop.dev percent of the voters from the party follow the transition probabilities specified in TM. The sum of the matrices prop.loyal, prop.strategic, and prop.contextual must equal one for each cell. If this condition is not met, the function internally standardizes the provided matrices. Default, matrix(0.33, nrow = ifelse(is.null(dim(n.units)), n.units, nrow(n.units)), ncol = nrow(TM)).

par.loyal

A number between 0.9 and 1 indicating the minimum probability with which loyal voters will support the same party in the second election as they did in the first. For each unit, the probability is randomly chosen between par.loyal and 1. Default, 0.95.

par.strategic

A positive number indicating the proportion of increase that the initial transfer probabilities in TM should be increased for those parties improving their support in the second election compared to their performance in their first election. Default, 0.5.

par.context

A positive number indicating the factor by which the proportion of support for a party in each unit should be multiplied to increase the initial transfer probabilities in TM corresponding to that party. Default, 0.5.

simplify

A TRUE/FALSE argument indicating whether the simulated RxCxK array of counts by polling unit should be rearranged as a matrix of order Kx(RC). Default, FALSE.

...

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

Value

A list with the following components

votes1

A KxR matrix with the (simulated) results in each polling unit for the first election.

votes2

A KxC matrix with the simulated results in each polling unit for the second election.

TM.global

An RxC matrix with the simulated global transfer matrix of counts.

TM.units

An RxCxK array with the simulated transfer matrices of votes by polling unit. If simplify = TRUE, the simulated transfer matrices of votes are returned in a Kx(RC) matrix.

inputs

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

Note

Compared with simula_mixture, this function (i) is restricted to square matrices; (ii) considers only four voter types; and (iii) because it mixes only the expected behaviours across voter types, draws from a distribution with smaller variance, even when the latent types and their parameters are the same.

Author(s)

Jose M. Pavia, pavia@uv.es

Antonio Forcina, forcinarosara@gmail.com

References

Brown, P. and Payne, C. (1986). Aggregate data, ecological regression and voting transitions. Journal of the American Statistical Association, 81, 453–460. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.1986.10478290")}

Forcina, A., Gnaldi, M. and Bracalente, B. (2012). A revised Brown and Payne model of voting behaviour applied to the 2009 elections in Italy. Statistical Methods & Applications, 21, 109–119. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s10260-011-0184-x")}

Pavia, J.M, and Forcina, A. (2026). Simulating electoral behavior. In Modeling Decisions for Artificial Intelligence, MDAI 2025. Lecture Notes in Computer Science, vol 15957, Torra, V., Narukawa, Y., Domingo-Ferrer, J. (eds), Springer, Cham, pp. 54-65. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-3-032-00891-6_5")}

See Also

simula_BPF simula_mixture

Examples

TMg <- matrix(c(0.6, 0.1, 0.3, 0.1, 0.7, 0.2, 0.1, 0.1, 0.8),
             byrow = TRUE, nrow = 3)
example <- simula_BPF_with_deviations(n.units = 100, TM = TMg, prop1 = c(0.3, 0.3, 0.4),
                                      polling.sizes = c(750, 850))

eiCircles documentation built on March 18, 2026, 1:06 a.m.