Title: | The Data Defect Index for Samples that May not be IID |
---|---|
Description: | Implements Meng's data defect index (ddi), which represents the degree of sample bias relative to an iid sample. The data defect correlation (ddc) represents the correlation between the outcome of interest and the selection into the sample; when the sample selection is independent across the population, the ddc is zero. Details are in Meng (2018) <doi:10.1214/18-AOAS1161SF>, "Statistical Paradises and Paradoxes in Big Data (I): Law of Large Populations, Big Data Paradox, and the 2016 US Presidential Election." Survey estimates from the Cooperative Congressional Election Study (CCES) is included to replicate the article's results. |
Authors: | Shiro Kuriwaki [aut, cre] |
Maintainer: | Shiro Kuriwaki <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.0 |
Built: | 2025-03-07 03:03:08 UTC |
Source: | https://github.com/kuriwaki/ddi |
The Data Defect Correlation (ddc) is the correlation between response and group membership. It quantifies the correlation between the outcome of interest and the selection into the sample; when the sample selection is independent across members of the population, the ddc is zero. Currently both variables are binary. The data defect index (ddi) is the square of ddc. Squaring the d.d.c. is more useful for characterizing the asymptotics of ' MSE.
ddc(mu, muhat, N, n, cv = NULL)
ddc(mu, muhat, N, n, cv = NULL)
mu |
Vector of population quantity of interest |
muhat |
Vector for sample estimate |
N |
Vector of population size |
n |
Vector of sample size |
cv |
Coefficient of variation of the weights, if survey weights exist and
|
A vector of d.d.c. of the same length of the input, or a scalar if all input variables are scalars.
Meng, Xiao-Li (2018) <doi:10.1214/18-AOAS1161SF>, "Statistical Paradises and Paradoxes in Big Data (I): Law of Large Populations, Big Data Paradox, and the 2016 US Presidential Election." Annals of Applied Statistics 12:2, 685–726.
library(tibble) library(dplyr) data(g2016) # 1. scalar input select(g2016, cces_pct_djt_vv, cces_n_vv, tot_votes, votes_djt) %>% summarize_all(sum) ## plug those numbers in ddc(mu = 62984824/136639786, muhat = 12284/35829, N = 136639786, n = 35829) # 2. vector input using "with" with(g2016, ddc(mu = pct_djt_voters, muhat = cces_pct_djt_vv, N = tot_votes, n = cces_n_vv)) # 3. vector input in tidy tibble transmute(g2016, st, ddc = ddc(mu = pct_djt_voters, muhat = cces_pct_djt_vv, N = tot_votes, n = cces_n_vv))
library(tibble) library(dplyr) data(g2016) # 1. scalar input select(g2016, cces_pct_djt_vv, cces_n_vv, tot_votes, votes_djt) %>% summarize_all(sum) ## plug those numbers in ddc(mu = 62984824/136639786, muhat = 12284/35829, N = 136639786, n = 35829) # 2. vector input using "with" with(g2016, ddc(mu = pct_djt_voters, muhat = cces_pct_djt_vv, N = tot_votes, n = cces_n_vv)) # 3. vector input in tidy tibble transmute(g2016, st, ddc = ddc(mu = pct_djt_voters, muhat = cces_pct_djt_vv, N = tot_votes, n = cces_n_vv))
Donald Trump's voteshare in each U.S. state, with survey estimates from the Cooperative Congressional Election Study (pre-election wave). See Meng (2018) referenced below for more details. We focus on unweighted estimates to capture the response patterns, before correcting for any imbalances through weights.
g2016
g2016
A data frame with 51 rows (all U.S. states and D.C.)
state (full name)
state (abbreviation).
Donald J. Trump's voteshare, the estimand.
CCES unweighted proportion of Trump support, one estimate.
CCES unweighted proportion counting Republican undecideds as Trump voters.
Total number of votes by Trump.
Turnout in Presidential as total number of votes cast.
Validated voters intending to vote for Trump. Used as the numerator for the above CCES estimates.
Validated voters in survey sample. Used as the denominator for the above CCES estimates.
Voting Age Population in the state.
Voting Eligible Population in the state (estimate from the US Election Project).
Cooperative Congressional Election Study (CCES) https://cces.gov.harvard.edu/ and the United States Election Project http://www.electproject.org/2016g. Created under https://github.com/kuriwaki/poll_error.
For an explanation in the context of d.d.i., see Meng (2018) <doi:10.1214/18-AOAS1161SF>
library(dplyr) data(g2016) transmute(g2016, st, ddc = ddc(mu = pct_djt_voters, muhat = cces_pct_djt_vv, N = tot_votes, n = cces_n_vv))
library(dplyr) data(g2016) transmute(g2016, st, ddc = ddc(mu = pct_djt_voters, muhat = cces_pct_djt_vv, N = tot_votes, n = cces_n_vv))