| Title: | Scientific Analysis of Trial Errors (SATE) |
|---|---|
| Description: | Bundles functions used to analyze the harmfulness of trial errors in criminal trials. Functions in the Scientific Analysis of Trial Errors ('sate') package help users estimate the probability that a jury will find a defendant guilty given jurors' preferences for a guilty verdict and the uncertainty of that estimate. Users can also compare actual and hypothetical trial conditions to conduct harmful error analysis. The conceptual framework is discussed by Barry Edwards, A Scientific Framework for Analyzing the Harmfulness of Trial Errors, UCLA Criminal Justice Law Review (2024) <doi:10.5070/CJ88164341> and Barry Edwards, If The Jury Only Knew: The Effect Of Omitted Mitigation Evidence On The Probability Of A Death Sentence, Virginia Journal of Social Policy & the Law (2025) <https://vasocialpolicy.org/wp-content/uploads/2025/05/Edwards-If-The-Jury-Only-Knew.pdf>. The relationship between individual jurors' verdict preferences and the probability that a jury returns a guilty verdict has been studied by Davis (1973) <doi:10.1037/h0033951>; MacCoun & Kerr (1988) <doi:10.1037/0022-3514.54.1.21>, and Devine et el. (2001) <doi:10.1037/1076-8971.7.3.622>, among others. |
| Authors: | Barry Edwards [aut, cre] |
| Maintainer: | Barry Edwards <[email protected]> |
| License: | CC0 |
| Version: | 3.1.1 |
| Built: | 2026-06-03 08:34:02 UTC |
| Source: | https://github.com/cran/sate |
Calculates the probability that a jury of size jury_n finds defendant guilty given preferences of the jury pool (input as sample_pg). Does not estimate uncertainty (use as.jury.stats function for inferential statistics).
as.jury.point( sample_pg, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, simulate = FALSE )as.jury.point( sample_pg, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, simulate = FALSE )
sample_pg |
Proportion of jurors who favor a guilty verdict. Can be a single number between 0 and 1, or a vector of such numbers. |
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 12. |
pstrikes |
Number of peremptory strikes by prosecution; default value is 0. |
dstrikes |
Number of peremptory strikes by defendant; default value is 0. |
accuracy |
Accuracy of parties' peremptory strikes; a number between 0 and 1; default value is .15. |
simulate |
Simulation control. Use 'FALSE' (default) for deterministic Markov model values, 'TRUE' for simulation with defaults ('nDraws=10000', 'seed=NULL'), or a named list like 'list(nDraws=5000, seed=12345)'. |
Returns the probability jury finds defendant guilty (if sample_pg is a single number) or vector of such probabilities (if sample_pg is a vector).
library(sate) as.jury.point(sample_pg = .50) as.jury.point(sample_pg = 10/12) as.jury.point(sample_pg = .50, simulate = TRUE)library(sate) as.jury.point(sample_pg = .50) as.jury.point(sample_pg = 10/12) as.jury.point(sample_pg = .50, simulate = TRUE)
Calculates probability jury finds defendant guilty based on verdicts preferences of jury pool. Also reports standard error and confidence interval of estimate (use as.jury.point function for estimate only).
as.jury.stats( sample_pg, sample_n, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, digits = 3, simulate = FALSE )as.jury.stats( sample_pg, sample_n, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, digits = 3, simulate = FALSE )
sample_pg |
Proportion of jurors who favor a guilty verdict; a number between 0 and 1. |
sample_n |
Size of sample used to estimate sample_pg. |
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 12. |
pstrikes |
Number of peremptory strikes by prosecution; default value is 0. |
dstrikes |
Number of peremptory strikes by defendant; default value is 0. |
accuracy |
Accuracy of parties' peremptory strikes; a number between 0 and 1; default value is .15. |
digits |
Number of digits to report after decimal places; default value is 3. |
simulate |
Simulation control for uncertainty estimation. Use 'FALSE' (default) for analytic method, 'TRUE' for simulation with defaults ('nDraws=10000', 'seed=NULL'), or a named list like 'list(nDraws=5000, seed=12345)'. |
Returns a one-row data.frame with columns: P(G), SE, MOE, Lower 5
library(sate) as.jury.stats(sample_pg=.50, sample_n=830) as.jury.stats(sample_pg=10/12, sample_n=295) as.jury.stats(sample_pg=.50, sample_n=830, simulate=TRUE) as.jury.stats(sample_pg=.50, sample_n=830, simulate=list(nDraws=5000, seed=12345))library(sate) as.jury.stats(sample_pg=.50, sample_n=830) as.jury.stats(sample_pg=10/12, sample_n=295) as.jury.stats(sample_pg=.50, sample_n=830, simulate=TRUE) as.jury.stats(sample_pg=.50, sample_n=830, simulate=list(nDraws=5000, seed=12345))
Creates the shell of a plot showing relationship between jury pool preferences and jury verdict probabilities, optional argument to modify main, xlab, and ylab labels, includes grid lines.
basic.plot.grid(main, xlab, ylab)basic.plot.grid(main, xlab, ylab)
main |
Main title for plot (optional), default is no main title. |
xlab |
X-axis label for plot (optional), default is "Jurors' Verdict Preferences, P(g)". |
ylab |
Y-axis label for plot (optional), default is "Jury Verdict Probabilities, P(G)". |
No return value; function creates a plot.
library(sate) basic.plot.grid() basic.plot.grid(main="Death Sentencing Analysis", xlab="Jurors' Sentencing Preferences, P(d)", ylab="Jury Verdict Probabilities, P(D)")library(sate) basic.plot.grid() basic.plot.grid(main="Death Sentencing Analysis", xlab="Jurors' Sentencing Preferences, P(d)", ylab="Jury Verdict Probabilities, P(D)")
Creates the shell of a plot used for compact display estimate of harm estimate relative to harm thresholds.
compact_harm_plot()compact_harm_plot()
No return
library(sate) compact_harm_plot()library(sate) compact_harm_plot()
Calculates juror-level statistics and differences based on sample statistics (from a survey) supplied by user.
compare.juror.stats(pg_actual, n_actual, pg_hypo, n_hypo, digits = 3)compare.juror.stats(pg_actual, n_actual, pg_hypo, n_hypo, digits = 3)
pg_actual |
The proportion of jurors who favor a guilty verdict in the actual trial condition (the trial with error). |
n_actual |
The size of the sample used to estimate pg_actual. |
pg_hypo |
The proportion of jurors who favor a guilty verdict in the hypothetical trial condition (the fair trial without error). |
n_hypo |
The size of the sample used to estimate pg_hypo. |
digits |
Number of digits to report after decimal places; default value is 3. |
Returns a list of juror-level statistics to assess the effect of a trial error or omission on juror preferences. Returned list includes statistics for the actual trial, the hypothetical trial, and the difference between them.
library(sate) compare.juror.stats(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450) compare.juror.stats(pg_actual=.75, n_actual=450, pg_hypo=.65, n_hypo=350)library(sate) compare.juror.stats(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450) compare.juror.stats(pg_actual=.75, n_actual=450, pg_hypo=.65, n_hypo=350)
Calculates jury-level statistics and differences based on juror-level statistics supplied by user.
compare.jury.stats( pg_actual, n_actual, pg_hypo, n_hypo, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, digits = 3, simulate = FALSE )compare.jury.stats( pg_actual, n_actual, pg_hypo, n_hypo, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, digits = 3, simulate = FALSE )
pg_actual |
The proportion of jurors who favor a guilty verdict in the actual trial condition (the trial with error). |
n_actual |
The size of the sample used to estimate pg_actual. |
pg_hypo |
The proportion of jurors who favor a guilty verdict in the hypothetical trial condition (the fair trial without error). |
n_hypo |
The size of the sample used to estimate pg_hypo. |
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 12. |
pstrikes |
Number of peremptory strikes by prosecution; default value is 0. |
dstrikes |
Number of peremptory strikes by defendant; default value is 0. |
accuracy |
Accuracy of parties' peremptory strikes; a number between 0 and 1; default value is .15. |
digits |
Number of digits to report after decimal places; default value is 3. |
simulate |
Simulation control for uncertainty estimation. Use 'FALSE' (default) for analytic method, 'TRUE' for simulation with defaults ('nDraws=10000', 'seed=NULL'), or a named list like 'list(nDraws=5000, seed=12345)'. |
Returns a list of jury-level statistics to assess effect of a trial error. Returned list includes statistics for actual jury, hypothetical jury, and the difference between them.
library(sate) compare.jury.stats(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450) compare.jury.stats(pg_actual=.75, n_actual=450, pg_hypo=.65, n_hypo=350, jury_n=6, pstrikes=3, dstrikes=3) compare.jury.stats(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450, simulate=TRUE)library(sate) compare.jury.stats(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450) compare.jury.stats(pg_actual=.75, n_actual=450, pg_hypo=.65, n_hypo=350, jury_n=6, pstrikes=3, dstrikes=3) compare.jury.stats(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450, simulate=TRUE)
The deliberate function returns a jury verdict based on a simulation of deliberation as a modified tug-of-war between two verdict factions. Can be called directly, but is meant to be called many times to generate verdict probabilities based on g_votes and jury_n values. Requires '0 <= g_votes <= jury_n'.
deliberate(g_votes, jury_n)deliberate(g_votes, jury_n)
g_votes |
Initial number of votes for guilty verdict (same as K value). |
jury_n |
Size of the jury (i.e. 4, 6, 8, 12, or 16). |
Returns "G" (guilty verdict), "NG" (not guilty verdict), or 'NA' if either input is 'NA'.
library(sate) deliberate(g_votes=10, jury_n=12) deliberate(g_votes=4, jury_n=6)library(sate) deliberate(g_votes=10, jury_n=12) deliberate(g_votes=4, jury_n=6)
The deliberate function returns a jury verdict based on a simulation of deliberation as a tug-of-war between two verdict factions. The civil version of deliberate does not have presumption in favor of either party. Can be called directly, but is meant to be called many times to generate verdict probabilities based on p_votes and jury_n values. Requires '0 <= p_votes <= jury_n'.
deliberate.civil(p_votes, jury_n)deliberate.civil(p_votes, jury_n)
p_votes |
Initial number of votes for plaintiff. |
jury_n |
Size of the jury (i.e. 4, 6, 8, 12, or 16). |
Returns "P" (plaintiff verdict), "D" (defendant verdict), or 'NA' if either input is 'NA'.
library(sate) deliberate.civil(p_votes=8, jury_n=12) deliberate.civil(p_votes=5, jury_n=6)library(sate) deliberate.civil(p_votes=8, jury_n=12) deliberate.civil(p_votes=5, jury_n=6)
Encodes Cloud research respondent information with names and values suitable for calculating sampling weights. All variables encoded and added to dataset are booleans. The variable respondent_na is TRUE if the respondent's information is "Prefer not to say" or missing on any variable.
encode.cloud.respondent.variables(dataset)encode.cloud.respondent.variables(dataset)
dataset |
Data frame containing Cloud Research respondent demographic information. Required columns are: Race, Education, Household.Income, Age, Gender, and Ethnicity. Age must be numeric. |
Returns dataset with encoded variables added: black, ba_or_more, hhincome_over50k, age35plus, woman, hispanic, and respondent_na.
library(sate) example <- data.frame(Race = sample(x=c("Black or African American", "Other"), size=10, replace=TRUE), Education = sample(x=c("Bachelor's degree (for example: BA, AB, BS)", "Other"), size=10, replace=TRUE), Household.Income = sample(x=c("$70,000-$79,999", "Other"), size=10, replace=TRUE), Age = sample(x=18:80, size=10, replace=TRUE), Gender = sample(x=c("Woman", "Man", "Prefer not to say"), size=10, replace=TRUE), Ethnicity = sample(x=c("No, not of Hispanic, Latino, or Spanish origin", "Other"), size=10, replace=TRUE)) dataset.encoded <- encode.cloud.respondent.variables(dataset=example)library(sate) example <- data.frame(Race = sample(x=c("Black or African American", "Other"), size=10, replace=TRUE), Education = sample(x=c("Bachelor's degree (for example: BA, AB, BS)", "Other"), size=10, replace=TRUE), Household.Income = sample(x=c("$70,000-$79,999", "Other"), size=10, replace=TRUE), Age = sample(x=18:80, size=10, replace=TRUE), Gender = sample(x=c("Woman", "Man", "Prefer not to say"), size=10, replace=TRUE), Ethnicity = sample(x=c("No, not of Hispanic, Latino, or Spanish origin", "Other"), size=10, replace=TRUE)) dataset.encoded <- encode.cloud.respondent.variables(dataset=example)
Calculates a vector of probabilities that a jury with jury_n will return a guilty verdict. The vector represents P(G|k) for 0, 1, 2, ... , jury_n where k is the number of jurors initially in favor of guilty verdict.
get_pG_by_k(jury_n = 6)get_pG_by_k(jury_n = 6)
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 6. |
Returns a vector of probabilities for guilty verdict of size jury_n + 1.
library(sate) get_pG_by_k(10) get_pG_by_k(jury_n=12)library(sate) get_pG_by_k(10) get_pG_by_k(jury_n=12)
Plots jury-level differences based on juror-level statistics supplied by user. Point estimates supplemented by confidence intervals. Effect-on-defendant also plotted.
graph.effect.defendant( pg_actual, n_actual, pg_hypo, n_hypo, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, simulate = FALSE )graph.effect.defendant( pg_actual, n_actual, pg_hypo, n_hypo, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, simulate = FALSE )
pg_actual |
The proportion of jurors who favor a guilty verdict in the actual trial condition (the trial with error). |
n_actual |
The size of the sample used to estimate pg_actual. |
pg_hypo |
The proportion of jurors who favor a guilty verdict in the hypothetical trial condition (the fair trial without error). |
n_hypo |
The size of the sample used to estimate pg_hypo. |
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 12. |
pstrikes |
Number of peremptory strikes by prosecution; default value is 0. |
dstrikes |
Number of peremptory strikes by defendant; default value is 0. |
accuracy |
Accuracy of parties' peremptory strikes; a number between 0 and 1; default value is .15. |
simulate |
Simulation control passed to 'compare.jury.stats' and 'as.jury.stats'. Use 'FALSE' (default), 'TRUE', or a named list like 'list(nDraws=5000, seed=12345)'. For graphing speed, 'TRUE' uses 'nDraws=2000' by default. |
No return (creates plots)
library(sate) graph.effect.defendant(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450) graph.effect.defendant(pg_actual=.75, n_actual=450, pg_hypo=.65, n_hypo=350, jury_n=6, pstrikes=3, dstrikes=3) graph.effect.defendant(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450, simulate=TRUE)library(sate) graph.effect.defendant(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450) graph.effect.defendant(pg_actual=.75, n_actual=450, pg_hypo=.65, n_hypo=350, jury_n=6, pstrikes=3, dstrikes=3) graph.effect.defendant(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450, simulate=TRUE)
Plots probability of guilty verdict with confidence interval based on juror-level statistics supplied by user. Similar to graph.effect.defendant, but plots one condition.
graph.estimate( sample_pg, sample_n, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, simulate = FALSE )graph.estimate( sample_pg, sample_n, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, simulate = FALSE )
sample_pg |
The proportion of jurors who favor a guilty verdict in the sample condition |
sample_n |
The size of the sample used to estimate sample_pg_actual |
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 12. |
pstrikes |
Number of peremptory strikes by prosecution; default value is 0. |
dstrikes |
Number of peremptory strikes by defendant; default value is 0. |
accuracy |
Accuracy of parties' peremptory strikes; a number between 0 and 1; default value is .15. |
simulate |
Simulation control passed to 'as.jury.stats'. Use 'FALSE' (default), 'TRUE', or a named list like 'list(nDraws=5000, seed=12345)'. For graphing speed, 'TRUE' uses 'nDraws=2000' by default. |
No return (creates plot)
library(sate) graph.estimate(sample_pg=.70, sample_n=400) graph.estimate(sample_pg=.75, sample_n=450, jury_n=6, pstrikes=3, dstrikes=3) graph.estimate(sample_pg=.70, sample_n=400, simulate=TRUE)library(sate) graph.estimate(sample_pg=.70, sample_n=400) graph.estimate(sample_pg=.75, sample_n=450, jury_n=6, pstrikes=3, dstrikes=3) graph.estimate(sample_pg=.70, sample_n=400, simulate=TRUE)
A compilation of observed jury deliberations from multiple studies used to analyze relationship between initial state of jury and probability of verdict.
observed.deliberationsobserved.deliberations
A data frame with 2382 rows and 7 variables.
Internal identification number.
Proportion of jurors initially in favor of guilty/death verdict.
Size of jury.
Did jury render guilty/death verdict? 1 = yes, 0 = no.
Deliberation by six-person jury? 1 = yes, 0 = no.
Was jury deliberating death penalty? 1 = yes, 0 = no.
Source of data. Devine_2001 = Devine et al. (2001) table 6 without Sandys & Dillehey (1995); Devine_2004 = Devine et al. (2004) table 2; Devine_2007 = Devine et al. (2007) with correction for undecideds suggested by Kerr and McCoun (2012); Sandys_1995 = Sandys & Dillehey (1995) with correction for undecideds suggested by Kerr and McCoun (2012); CJP_2015 = Capital Jury Project from Devine & Kelly (2015), some imputed prop_jurors_g values; NCSC_LA = Hannaford-Agor et al. (2001), NCSC Study, Los Angeles site trials, with identifying number; NCSC_AZ = Hannaford-Agor et al. (2001), NCSC Study, Maricopa site trials, with identifying number; NCSC_NY = Hannaford-Agor et al. (2001), NCSC Study, Bronx site trials, with identifying number; NCSC_DC = Hannaford-Agor et al. (2001), NCSC Study, Washington, DC site trials, with identifying number;
Compilation of multiple sources, see source variable.
verdict probabilities based on jury pool sentiment for ordered verdict options.
prob_ord_from_pool(jury_n, verdict_options, verdict_props, digits = NULL)prob_ord_from_pool(jury_n, verdict_options, verdict_props, digits = NULL)
jury_n |
Integer. Number of jurors. |
verdict_options |
Character vector of ordered verdict labels (e.g., 'c("NG","M2","M1")'). Order matters: left = most lenient. Labels must be non-missing, non-empty, and unique. |
verdict_props |
Numeric vector specifying proportion of jurors who support the respective verdict_options in the population from which jurors are drawn. (e.g., 'c(.25,.50,.25)'). Must correspond to verdict_options, contain non-missing finite values, be non-negative, and sum to a positive value. |
digits |
Integer. Optional, number of digits to round in the returned matrix. |
A vector of length K that are probabilities of the ordered verdicts.
[transition.matrix.ordered]
library(sate) # Three-verdict ordered model with a 12-person jury: prob_ord_from_pool(12, c("NG", "M2", "M1"), c(.25,.50,.25), digits=3)library(sate) # Three-verdict ordered model with a 12-person jury: prob_ord_from_pool(12, c("NG", "M2", "M1"), c(.25,.50,.25), digits=3)
Compute the probability that an ordered-category Markov chain on jury vote counts will eventually absorb at each unanimous verdict, starting from any transient (non-unanimous) composition. Internally, this constructs the transition matrix with 'transition.matrix.ordered()' **using its defaults**, i.e., equal cut lines (no lambda weighting).
prob.ordered.verdicts(jury_n, verdict_options, digits = NULL, collab = TRUE)prob.ordered.verdicts(jury_n, verdict_options, digits = NULL, collab = TRUE)
jury_n |
Integer. Number of jurors. |
verdict_options |
Character vector of ordered verdict labels (e.g., 'c("NG","Lesser","G")'). Order matters: left = most lenient. |
digits |
Integer. Number of digits to round in the returned matrix. Default '3'. |
collab |
Logical. If 'TRUE' (default), attach human-friendly row/column labels: rows are verdict names; columns are starting states (transients first, then unanimities). |
Let be the transition matrix returned by
'transition.matrix.ordered(jury_n, verdict_options)', with meta attributes
providing:
- 'T': number of transient states,
- 'K': number of absorbing states (equal to 'length(verdict_options)'),
- 'states': list of length 'T + K' of count vectors (per state),
- 'n': the jury size,
- 'verdict_options': the verdict labels.
A numeric K by T+K matrix of absorption probabilities. Rows index absorbing verdicts in 'verdict_options'. Columns index starting states: first all transient compositions, then each unanimity composition (one per verdict). If 'collab = TRUE', row/column names are added.
[transition.matrix.ordered]
library(sate) # Three-verdict ordered model with a 12-person jury: prob.ordered.verdicts(12, c("NG", "M2", "M1")) # Probability of ultimately unanimous "Lesser" starting from A=6, B=4, C=2: prob.ordered.verdicts(12, c("A","B","C"), digits = 3)library(sate) # Three-verdict ordered model with a 12-person jury: prob.ordered.verdicts(12, c("NG", "M2", "M1")) # Probability of ultimately unanimous "Lesser" starting from A=6, B=4, C=2: prob.ordered.verdicts(12, c("A","B","C"), digits = 3)
Calculates and returns probability distribution of initial votes for guilty verdict from 0:jury_n with options for peremptory strikes and strike accuracy. To select jury without strikes, keep pstrikes=0 and dstrikes=0.
select.with.strikes( p_g, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15 )select.with.strikes( p_g, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15 )
p_g |
The proportion of jurors in the jury pool who favor a guilty verdict |
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 12. |
pstrikes |
Number of peremptory strikes by prosecution; default value is 0. |
dstrikes |
Number of peremptory strikes by defendant; default value is 0. |
accuracy |
Accuracy of parties' peremptory strikes; a number between 0 and 1; default value is .15. |
A vector of probabilities for 0:jury_n initial guilty votes
library(sate) select.with.strikes(p_g=.70, jury_n=6) select.with.strikes(p_g=.75, jury_n=12, pstrikes=6, dstrikes=10)library(sate) select.with.strikes(p_g=.70, jury_n=6) select.with.strikes(p_g=.75, jury_n=12, pstrikes=6, dstrikes=10)
Returns estimate of the probability of guilty verdict based on juror-level statistics supplied by user. Also reports inferential statistics. Results are based on an empirical model with greater uncertainty than as.jury.stats function.
sim.as.jury.stats( sample_pg, sample_n, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, digits = 3, nDraws = 10000, seed = NULL )sim.as.jury.stats( sample_pg, sample_n, jury_n = 12, pstrikes = 0, dstrikes = 0, accuracy = 0.15, digits = 3, nDraws = 10000, seed = NULL )
sample_pg |
The proportion of jurors who favor a guilty verdict in the jury pool |
sample_n |
The size of the sample used to estimate sample_pg |
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 12. |
pstrikes |
Number of peremptory strikes by prosecution; default value is 0. |
dstrikes |
Number of peremptory strikes by defendant; default value is 0. |
accuracy |
Accuracy of parties' peremptory strikes; a number between 0 and 1; default value is .15. |
digits |
Number of digits to report after decimal places; default value is 3. |
nDraws |
The number of simulations used to generate results. Should be very large number (default = 10000). |
seed |
Optional non-negative integer seed for replication. Default is NULL (no seeding). |
Returns a one-row data.frame with columns: P(G), SE, MOE, Lower 5
library(sate) sim.as.jury.stats(sample_pg=.50, sample_n=830, nDraws=500) sim.as.jury.stats(sample_pg=10/12, sample_n=295, pstrikes=6, dstrikes=10, nDraws=1000)library(sate) sim.as.jury.stats(sample_pg=.50, sample_n=830, nDraws=500) sim.as.jury.stats(sample_pg=10/12, sample_n=295, pstrikes=6, dstrikes=10, nDraws=1000)
Calculates jury-level differences based on juror-level statistics supplied by user. Results based on empirical data, inferential statistics produced via simulations.
sim.compare.jury.stats( pg_actual, n_actual, pg_hypo, n_hypo, jury_n = 12, digits = 3, pstrikes = 0, dstrikes = 0, accuracy = 0.15, seed = NULL, nDraws = 10000 )sim.compare.jury.stats( pg_actual, n_actual, pg_hypo, n_hypo, jury_n = 12, digits = 3, pstrikes = 0, dstrikes = 0, accuracy = 0.15, seed = NULL, nDraws = 10000 )
pg_actual |
The proportion of jurors who favor a guilty verdict in the actual trial condition (the trial with error). |
n_actual |
The size of the sample used to estimate pg_actual. |
pg_hypo |
The proportion of jurors who favor a guilty verdict in the hypothetical trial condition (the fair trial without error). |
n_hypo |
The size of the sample used to estimate pg_hypo. |
jury_n |
Size of the jury (i.e. 6, 8, or 12); default value is 12. |
digits |
Number of digits to report after decimal places; default value is 3. |
pstrikes |
Number of peremptory strikes by prosecution; default value is 0. |
dstrikes |
Number of peremptory strikes by defendant; default value is 0. |
accuracy |
Accuracy of parties' peremptory strikes; a number between 0 and 1; default value is .15. |
seed |
Optional non-negative integer seed for replication. Default is NULL (no seeding). |
nDraws |
The number of simulations used to generate results. Should be very large number (default = 10000). |
Returns a list of jury-level statistics to assess effect of a trial error.
library(sate) sim.compare.jury.stats(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450, nDraws=500) sim.compare.jury.stats(pg_actual=.75, n_actual=450, pg_hypo=.65, n_hypo=350, seed=12345, nDraws=1000)library(sate) sim.compare.jury.stats(pg_actual=.70, n_actual=400, pg_hypo=.60, n_hypo=450, nDraws=500) sim.compare.jury.stats(pg_actual=.75, n_actual=450, pg_hypo=.65, n_hypo=350, seed=12345, nDraws=1000)
A dataset with demographic statistics at state level plus national-level that may be used for calculating sample weights. Includes information related to race, educational attainment, household income, age, gender, and ethnicity.
state.demographic.infostate.demographic.info
A data frame with 52 rows and 8 variables.
Name of state
Two-letter abbreviation for state. USA for nation.
Proportion of state population who identify as black (African American), per US Census Bureau.
Proportion of adult (18+) population who have attained a BA degree or more, per US Census Bureau.
Proportion of state population with household income of $50,000 or more, per US Census Bureau.
Proportion of adult (18+) population age 35 or older, per US Census Bureau.
Proportion of state population who identify as women, per US Census Bureau.
Proportion of state population who identify as Hispanic, per US Census Bureau.
U.S. Census Bureau, American Community Survey, 5-Year Estimates.
Looks up and returns six key demographic statistics for a target state to be used for calculating sample weights. State-level population statistics from U.S. Census Bureau, American Community Survey 5-year estimates. Data from state.demographic.info, a saved datafile in sate package.
target.population.demographics(state)target.population.demographics(state)
state |
The target state, input as two-letter abbreviation (i.e., "GA" "TX" or "FL"). If no state specified, will use "USA". |
A one row data.frame with the following statistics: black, ba_or_more, hhincome_over50k, age35plus, woman, hispanic
library(sate) target.population.demographics(state="FL") target.population.demographics() # will return stats for USAlibrary(sate) target.population.demographics(state="FL") target.population.demographics() # will return stats for USA
Returns a (jury_n + 1) by (jury_n + 1) matrix of probabilities. Columns represent current state and rows represent next state. Column values sum to 1. Depending on use, you may want to transpose rows and columns.
transition.matrix(jury_n)transition.matrix(jury_n)
jury_n |
The number of jurors. |
A matrix of transition probabilities.
library(sate) transition.matrix(6) transition.matrix(jury_n=12)library(sate) transition.matrix(6) transition.matrix(jury_n=12)
Constructs the full **column-stochastic** Markov transition matrix \(P\) for a jury deliberation model with an **ordered** set of verdict options (least to most punitive). Transient states are all compositions of 'jury_n' jurors across the 'verdict_options'; absorbing states are the 'K' unanimity vertices (one per verdict), appended at the end in the same order as 'verdict_options'.
The transition from a transient state is built by applying your **2-option step rule** independently at each adjacent *cut* between options and combining those suggestions with **equal weight across cuts**. For cut 'r' (between options 'r' and 'r+1'), let 'g = sum(counts[(r+1):K])' be the number on the **more punitive** side; compute
Map "up" to moving one juror across the cut toward the more punitive option, "down" toward the less punitive option; pool all "stay" mass (and any illegal move mass at boundaries) into the **self-loop** so each column still sums to 1.
transition.matrix.ordered(jury_n, verdict_options, digits = NULL)transition.matrix.ordered(jury_n, verdict_options, digits = NULL)
jury_n |
Integer. Size of the jury (number of jurors), 'jury_n >= 1'. |
verdict_options |
Character vector of **ordered** verdict labels from least to most punitive, e.g. 'c("NG","M2","M1")' or 'c("NG","M3","M2","M1")'. Labels must be non-missing, non-empty, and unique. The order defines which options are adjacent. |
digits |
Optional integer. If supplied, round the returned matrix to this many decimals and then re-normalize each column to remain column-stochastic. Defaults to 'NULL' (no rounding). |
* Absorbing columns (the last 'K') are identity columns (unanimity stays put). * Self-loops collect "stay" mass from all cuts and any mass from moves that are illegal at boundaries (e.g., trying to move from an empty option). * Providing 'digits' is meant for tidy printing; for numerical work you may prefer to leave 'digits = NULL' to keep full precision.
A column-stochastic matrix 'P' of size , where
is the number of compositions of 'jury_n' into 'K'
parts (all states), ordered with **transients first** and then the 'K' unanimity
absorbing states in the order of 'verdict_options'. The matrix carries metadata on
'attr(P, "meta")' as a list with elements:
'states' - list of length-'K' integer count vectors for each state, in column order;
'idx' - environment mapping comma-joined count vectors to column/row indices;
'T', 'S', 'K', 'n' - counts (transients, total states, #options, #jurors);
'verdict_options' - the label vector you supplied.
prob.ordered.verdicts for solved absorption probabilities
(including appended unanimity starts) built on top of this transition matrix.
# 3 jurors, 3 options (NG < M2 < M1), equal cut weights P <- transition.matrix.ordered(3, c("NG","M2","M1")) dim(P); colSums(P) # columns sum to 1 attr(P, "meta")$verdict_options # labels carried in metadata # Tidy print: transition.matrix.ordered(3, c("NG","M2","M1"), digits = 3) # 4 options (NG < M3 < M2 < M1) P4 <- transition.matrix.ordered(3, c("NG","M3","M2","M1"))# 3 jurors, 3 options (NG < M2 < M1), equal cut weights P <- transition.matrix.ordered(3, c("NG","M2","M1")) dim(P); colSums(P) # columns sum to 1 attr(P, "meta")$verdict_options # labels carried in metadata # Tidy print: transition.matrix.ordered(3, c("NG","M2","M1"), digits = 3) # 4 options (NG < M3 < M2 < M1) P4 <- transition.matrix.ordered(3, c("NG","M3","M2","M1"))
Calculates survey weights given respondent information and target population demographics. Respondent demographic info must be properly encoded in respondentdata to work with targetdata. If respondent demographic info is missing, the respondent's weight will be coded 1. Weight values trimmed so that no weights are greater than 6 or less than .1.
weights_for_population(respondentdata, targetdata)weights_for_population(respondentdata, targetdata)
respondentdata |
Data frame with encoded respondent demographic information (use encode.cloud.respondent.variables to prepare). Must include: ParticipantId, black, ba_or_more, hhincome_over50k, age35plus, woman, hispanic, respondent_na. |
targetdata |
A one-row data.frame (or named vector) with the following statistics in [0, 1]: black, ba_or_more, hhincome_over50k, age35plus, woman, hispanic (use target.population.demographics to obtain). |
Returns respondentdata with raked sampling weights encoded.
library(sate) example_n <- 100 example <- data.frame(Race = sample(x=c("Black or African American", "Other"), size=example_n, replace=TRUE), Education = sample(x=c("Bachelor's degree (for example: BA, AB, BS)", "Other"), size=example_n, replace=TRUE), Household.Income = sample(x=c("$70,000-$79,999", "Other"), size=example_n, replace=TRUE), Age = sample(x=18:80, size=example_n, replace=TRUE), Gender = sample(x=c("Woman", "Man", "Prefer not to say"), size=example_n, replace=TRUE), Ethnicity = sample(x=c("No, not of Hispanic, Latino, or Spanish origin", "Other"), size=example_n, replace=TRUE), ParticipantId = 1:example_n) respondents.encoded <- encode.cloud.respondent.variables(dataset=example) pop.targets <- target.population.demographics(state="FL") respondents.weighted <- weights_for_population(respondentdata = respondents.encoded, targetdata = pop.targets)library(sate) example_n <- 100 example <- data.frame(Race = sample(x=c("Black or African American", "Other"), size=example_n, replace=TRUE), Education = sample(x=c("Bachelor's degree (for example: BA, AB, BS)", "Other"), size=example_n, replace=TRUE), Household.Income = sample(x=c("$70,000-$79,999", "Other"), size=example_n, replace=TRUE), Age = sample(x=18:80, size=example_n, replace=TRUE), Gender = sample(x=c("Woman", "Man", "Prefer not to say"), size=example_n, replace=TRUE), Ethnicity = sample(x=c("No, not of Hispanic, Latino, or Spanish origin", "Other"), size=example_n, replace=TRUE), ParticipantId = 1:example_n) respondents.encoded <- encode.cloud.respondent.variables(dataset=example) pop.targets <- target.population.demographics(state="FL") respondents.weighted <- weights_for_population(respondentdata = respondents.encoded, targetdata = pop.targets)