Title: Characterizing Observed and Expected Representation
Version: 1.1.1
Description: A system for analyzing descriptive representation, especially for comparing the composition of a political body to the population it represents. Users can compute the expected degree of representation for a body under a random sampling model, the expected degree of representation variability, as well as representation scores from observed political bodies. The package is based on Gerring, Jerzak, and Oncel (2024) <doi:10.1017/S0003055423000680>.
URL: https://github.com/cjerzak/DescriptiveRepresentationCalculator-software/
BugReports: https://github.com/cjerzak/DescriptiveRepresentationCalculator-software/issues
Depends: R (≥ 3.3.3)
License: GPL-3
Encoding: UTF-8
Imports: stats
Suggests: knitr, testthat (≥ 3.0.0)
VignetteBuilder: knitr
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2025-12-14 21:51:32 UTC; cjerzak
Author: Connor Jerzak ORCID iD [aut, cre], John Gerring ORCID iD [aut], Erzen Oncel ORCID iD [aut]
Maintainer: Connor Jerzak <connor.jerzak@gmail.com>
Repository: CRAN
Date/Publication: 2025-12-14 22:20:02 UTC

Compute the expected degree of representation for any group in a political body

Description

Finds the degree of expected representation for any group in a political body under a random sampling model as described in Gerring, Jerzak and Oncel (2024).

Usage

ExpectedRepresentation(PopShares, BodyN, a = -0.5, b = 1)

Arguments

PopShares

A numeric vector containing the group-level population proportions.

BodyN

A positive integer denoting the size of the political body in question.

a, b

The a and b parameters control the affine transformation for how the representation measure is summarized. That is, a and b control how the expected L1 deviation of the population shares from the body shares is re-weighted. The expected L1 deviation is the average value of the absolute deviation of the population from body shares under a random sampling model. This expected L1 deviation is multiplied by a; b is as an additive re-scaling term: a*E[L1]+b. By default, a=-0.5 and b=1 so that the expected Rose Index of Proportionality is returned.

Value

The expected degree of representation (a scalar).

References

See Also

Examples


ExpectedRep <- ExpectedRepresentation(PopShares = c(1/4, 2/4, 1/4),
                                      BodyN = 50)

print( ExpectedRep )


Compute the observed degree of representation for any group in a political body

Description

Finds the degree of observed representation for any group in a political body.

Usage

ObservedRepresentation(BodyMemberCharacteristics, PopShares, BodyShares, a = -0.5, b = 1)

Arguments

BodyMemberCharacteristics

A vector specifying the characteristics for members of a political body.

PopShares

A numeric vector specifying population shares of identities specified in the body-member characteristics input. The names of the entries in PopShares should correspond to identities in that body-member characteristics input (see Example).

BodyShares

(optional) A numeric vector with same structure as PopShares specifying group population shares of a given body. If supplied with names, they are matched to PopShares; otherwise, the order is assumed to correspond to that of PopShares.

a, b

Parameters controlling the affine transformation for how the representation measure is summarized. That is, a and b control how the L1 deviation of the population shares from the body shares is re-weighted. This expected L1 deviation is multiplied by a; b is as an additive re-scaling term: a*L1+b. By default, a=-0.5 and b=1 so that the Rose Index of Proportionality is returned.

Value

The observed degree of representation (a scalar). By default, this quantity is the Rose Index of Proportionality.

See Also

Examples


ObsRep <- ObservedRepresentation(
                        BodyMemberCharacteristics = c("A","A","C","A","C","A"),
                        PopShares = c("A"=1/4,"B"=2/4, "C"=1/4))

print( ObsRep )


Compute relative representation compared to random sampling

Description

Calculates the difference between observed and expected representation. Optionally standardizes this difference using the standard deviation of representation under the random sampling model.

Usage

RelativeRepresentation(BodyMemberCharacteristics,
                       PopShares,
                       a = -0.5, b = 1,
                       standardize = FALSE,
                       nMonte = 10000)

Arguments

BodyMemberCharacteristics

A vector specifying characteristics for each member of a political body.

PopShares

A numeric vector of population group proportions. Names must correspond to identities in BodyMemberCharacteristics.

a, b

Parameters controlling the affine transformation of the representation index, passed to ObservedRepresentation and ExpectedRepresentation.

standardize

Logical. If TRUE, the difference between observed and expected representation is divided by the standard deviation of representation under random sampling.

nMonte

A positive integer denoting number of Monte Carlo iterations used for estimating the standard deviation when standardize = TRUE.

Value

A scalar giving the difference between observed and expected representation. If standardize = TRUE, the difference is divided by the standard deviation under the random sampling model.

See Also

ObservedRepresentation, ExpectedRepresentation, SDRepresentation


Compute the amount of representation left unexplained by a random sampling model.

Description

Finds the residual standard deviation when using the expected representation for any group in a political body to predict observed representation as described in Gerring, Jerzak and Oncel (2024).

Usage

SDRepresentation(PopShares, BodyN, a = -0.5, b = 1, nMonte = 10000)

Arguments

PopShares

A numeric vector containing the group-level population proportions.

BodyN

A positive integer denoting the size of the political body in question.

a, b

Parameters controlling the affine transformation for how the representation measure is summarized. That is, a and b control how the expected L1 deviation of the population shares from the body shares is re-weighted. The expected L1 deviation is the average value of the absolute deviation of the population from body shares under a random sampling model. This expected L1 deviation is multiplied by a; b is as an additive re-scaling term: a*E[L1]+b. By default, a=-0.5 and b=1 so that the expected Rose Index of Proportionality is used in the calculation.

nMonte

A positive integer denoting number of Monte Carlo iterations used to approximate the variance of representation under a random sampling model.

Value

A scalar summary of the amount of representation not explained by a random sampling model. More precisely, this function returns the the residual standard deviation when using the expected degree of representation to predict observed representation under a random sampling model.

References

See Also

Examples


SDRep <- SDRepresentation(PopShares = c(1/4, 2/4, 1/4),
                                BodyN = 50)

print( SDRep )


Check for body members not in population shares

Description

Warns if body member characteristics include groups not present in PopShares.

Usage

checkUnmatchedBodyMembers(BodyMemberCharacteristics, PopShares)

Arguments

BodyMemberCharacteristics

A vector of body member characteristics.

PopShares

A named numeric vector of population shares.

Value

Character vector of unmatched groups (invisibly).


Validate population shares

Description

Checks that population shares are valid: non-negative and sum to 1.

Usage

validatePopShares(PopShares, tol = 1e-06)

Arguments

PopShares

A numeric vector of population shares.

tol

Tolerance for checking if shares sum to 1.

Value

TRUE if valid, otherwise throws an error.