Title: | Data and Functions for R Companion to Political Analysis 3rd Ed |
---|---|
Description: | Bundles the datasets and functions featured in Philip H. Pollock and Barry C. Edwards<https://edge.sagepub.com/pollock>, "An R Companion to Political Analysis, 3rd Edition," Thousand Oaks, CA: Sage Publications. |
Authors: | Barry Edwards [aut, cre] |
Maintainer: | Barry Edwards <[email protected]> |
License: | CC0 |
Version: | 1.3.1 |
Built: | 2024-12-05 13:55:10 UTC |
Source: | CRAN |
Generates box plots for visual comparison of interval-level dependent variable's distribution across categories of independent variable. Includes option for weighting observations, modifying colors, variable widths. Box plot can be used to compare values of interval-level dependent variable by categories of an independent variable (a factor).
boxplotC(dv, iv, w, data, main, xlab, ylab, box.col, varwidth = TRUE, ivlabs, printC = FALSE, ...)
boxplotC(dv, iv, w, data, main, xlab, ylab, box.col, varwidth = TRUE, ivlabs, printC = FALSE, ...)
dv |
Dependent variable, should be in dataset$var form unless dataset specified in optional data argument. |
iv |
Independent variable, should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables (optional). |
main |
(Optional) Supply custom main label for plot; default uses names of dv and iv. |
xlab |
(Optional) Supply custom x-axis label for plot; default uses name of iv. |
ylab |
(Optional) Supply y-axis label for plot; default uses name of dv. |
box.col |
(Optional) The name of color to use for box colors. Default is "gray80". |
varwidth |
(Optional) Do you want the widths of boxes to be proportional to number of observations in each group? Default is TRUE; set |
ivlabs |
(Optional) A vector of labels for the iv values that are box lablels. |
printC |
(Optional) Do you want to print box plot to .html file in working directory? (Default: FALSE) |
... |
Additional arguments passed to plotting functions, |
No return, creates a plot.
Making Box Plots with RCPA3's boxplotC Function 15:12, shows you how to use the RCPA3 Package's boxplotC function to create box plots that show the relationship between an interval-level dependent variables and a categorical independent variable.
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 5.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 53-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Graphing Relationships and Describing Patterns, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site, find datasets for your own research and resources to help with political analysis.
library(RCPA3) # basic usage with variables as vectors boxplotC(dv=nes$ft.rep, iv=nes$partyid3) # with w and data arguments boxplotC(dv=ft.rep, iv=partyid3, w=wt, data=nes)
library(RCPA3) # basic usage with variables as vectors boxplotC(dv=nes$ft.rep, iv=nes$partyid3) # with w and data arguments boxplotC(dv=ft.rep, iv=partyid3, w=wt, data=nes)
Reports the confidence interval of a sample mean in table and plot. Default is 95% CI but use can raise or lower confidence level.
CImean(x, w, data, digits = 3, level = 95, pop.sd, printC = FALSE, plot = TRUE, main, xlab, xlim, ...)
CImean(x, w, data, digits = 3, level = 95, pop.sd, printC = FALSE, plot = TRUE, main, xlab, xlim, ...)
x |
A numeric variable, should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable (optional), must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable (optional). |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
level |
(Optional) A single number equal to the desired confidence level (i.e. 95, 99, 90, etc.). Default value is 95 percent confidence level. |
pop.sd |
(Optional) A single number equal to the known population standard deviation of x. This value is rarely know, but if it is, critical values for confidence interval are based on standard normal distribution. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot |
(Optional) Do you want a plot of the confidence interval? Default is TRUE. |
main |
(Optional) Change the main title of plot. Default title generated from level, x, and w. |
xlab |
(Optional) Label for x-axis of confidence interval plot. |
xlim |
(Optional) Modify x-axis limits of confidence interval plot. |
... |
(Optional) additional arguments passed to |
Returns the confidence interval as a vector of numeric values (the lower and upper bounds).
Confidence Intervals for Sample Means with RCPA3's CImean Function 16:16
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 8.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 184-186. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Foundations of Inference, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) CImean(nes$age) ## Not run: # using optional w, level, and data arguments CImean(x=nes$age, w=nes$wt, level=90) CImean(x=age, data=nes, level=95) ## End(Not run)
library(RCPA3) CImean(nes$age) ## Not run: # using optional w, level, and data arguments CImean(x=nes$age, w=nes$wt, level=90) CImean(x=age, data=nes, level=95) ## End(Not run)
Reports the confidence interval of sample proportions in table and plot. Default is 95% CI but use can raise or lower confidence level.
CIprop(x, w, data, digits = 3, level = 95, printC = FALSE, plot = TRUE, main, xlab, xlim, ...)
CIprop(x, w, data, digits = 3, level = 95, printC = FALSE, plot = TRUE, main, xlab, xlim, ...)
x |
A nominal or ordinal variable (factor), should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable. |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
level |
(Optional) A single number equal to the desired confidence level (i.e. 95, 99, 90, etc.). Default value is 95 percent confidence level. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot |
(Optional) Do you want a plot of the confidence interval? Default is TRUE. |
main |
(Optional) Change the main title of plot. Default title generated from level, x, and w. |
xlab |
(Optional) Label for x-axis of confidence interval plot. |
xlim |
(Optional) Modify x-axis limits of confidence interval plot. |
... |
(Optional) Additional arguments passed to |
Returns a data frame that gives the lower bound, point estimate, and upper bounds of each value of x variable.
Confidence Intervals for Sample Proportions with RCPA3's CIprop Function 18:29
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 8.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 184-186. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Foundations of Inference, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) CIprop(nes$lifex.knowimmig) ## Not run: # using optional w and data arguments CIprop(x=nes$lifex.knowimmig, w=nes$wt) CIprop(x=lifex.knowimmig, w=wt, data=nes) ## End(Not run)
library(RCPA3) CIprop(nes$lifex.knowimmig) ## Not run: # using optional w and data arguments CIprop(x=nes$lifex.knowimmig, w=nes$wt) CIprop(x=lifex.knowimmig, w=wt, data=nes) ## End(Not run)
Mean comparison analysis, options for weighted observations and control variable. Also supports several plotting options for basic mean comparisons and controlled mean comparisons. Can conduct single and two-factor analysis of variance (ANOVA) to test differences among multiple means.
compmeansC(dv, iv, w, z, data, digits = 2, compact = FALSE, ivlabs, zlabs, anova = FALSE, printC = FALSE, plot = TRUE, main, xlab, ylab, ylim, plot.ci = FALSE, z.palette, legend.title)
compmeansC(dv, iv, w, z, data, digits = 2, compact = FALSE, ivlabs, zlabs, anova = FALSE, printC = FALSE, plot = TRUE, main, xlab, ylab, ylim, plot.ci = FALSE, z.palette, legend.title)
dv |
Dependent variable, should be in dataset$var form unless dataset specified in optional data argument. |
iv |
Independent variable, should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable (optional), must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
z |
(Optional) Control variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables (optional). |
digits |
(Optional) The number of decimal places reported in result (defaults to 2). |
compact |
(Optional) Do you want compact version of controlled mean comparison table with N and Std. Dev. values omitted? Default is FALSE. Compact display only available for controlled comparisons. |
ivlabs |
(Optional) A vector of names for the independent variable's values (to abbreviate the mean comparison table's row labels and iv labels on plots) |
zlabs |
(Optional) A vector of names for the control variable's values (to abbreviate a controlled mean comparison table's column labels and z variable's labels on plots) |
anova |
(Optional) Do you want to conduct analysis of variance (ANOVA)? Default is FALSE. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot |
(Optional) Do you want a plot of the means? Default is TRUE (makes a bar plot). Additional options:
|
main |
(Optional) Main label for plot, if missing, default main title generated. |
xlab |
(Optional) x-axis label for plot, if missing, default label generated using iv name. |
ylab |
(Optional) y-axis label for plot, if missing, default label generated using dv name. |
ylim |
(Optional) Range of y-axis values on plot. |
plot.ci |
(Optional) Do you want vertical 95 percent confidence intervals added to line plot of means? Default is FALSE. Only works when |
z.palette |
(Optional) For bar and line charts with control variables (z), the name of HCL color palette to use. Default is "LightGrays". See |
legend.title |
(Optional) Customize title of legend on plot used for controlling comparisons. |
Returns a mean comparison table as a matrix of values.
Make Mean Comparisons with RCPA3's compmeansC Function 13:20, shows you how to use the RCPA3 Package's compmeansC function to compare values of an interval-level dependent variable across categories of an independent variable.
Making Controlled Mean Comparisons with RCPA3's compmeansC Function 25:46
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapters 4, 5, 7, 10.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp.85-97, 150-156. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Making Comparisons, Graphing Relationships and Describing Patterns, Making Controlled Comparisons, and Chi-Square Test and Analysis of Variance, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) compmeansC(dv=nes$ft.rep, iv=nes$partyid7, plot=FALSE) ## Not run: # basic usage with a plot compmeansC(dv=nes$ft.rep, iv=nes$partyid7, w=nes$wt, plot=TRUE) # basic usage: data argument used compmeansC(dv=infant.mortality, iv=region, data=world, plot=FALSE) # with weights and z variable compmeansC(dv=nes$ft.rep, iv=nes$partyid7, w=nes$wt, z=nes$gender, plot="line") compmeansC(dv=nes$ft.gay, iv=nes$gender, z=nes$partyid3, compact=TRUE, plot=TRUE) ## End(Not run)
library(RCPA3) compmeansC(dv=nes$ft.rep, iv=nes$partyid7, plot=FALSE) ## Not run: # basic usage with a plot compmeansC(dv=nes$ft.rep, iv=nes$partyid7, w=nes$wt, plot=TRUE) # basic usage: data argument used compmeansC(dv=infant.mortality, iv=region, data=world, plot=FALSE) # with weights and z variable compmeansC(dv=nes$ft.rep, iv=nes$partyid7, w=nes$wt, z=nes$gender, plot="line") compmeansC(dv=nes$ft.gay, iv=nes$gender, z=nes$partyid3, compact=TRUE, plot=TRUE) ## End(Not run)
Given two or more numeric variables, correlateC
reports correlation coefficients, along with inferential statistics (if requested), works with sampling weights. If more than two x variables are supplied, the function calculates correlation coefficients using pairwise complete observations (as opposed to limiting analysis to observations complete on all variables).
The wtd.cor
function is imported from the weights package. See wtd.cor
documentation for details.
correlateC(x, w, data, digits = 3, stats = FALSE, printC = FALSE, plot = FALSE, jitter = FALSE, ...)
correlateC(x, w, data, digits = 3, stats = FALSE, printC = FALSE, plot = FALSE, jitter = FALSE, ...)
x |
A list of variables for correlation analysis, variables must be numeric. Should be entered as list(dataset$var1, dataset$var2, dataset$var3 ... ) form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable (optional). |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
stats |
(Optional) Do you want the inferential statistics (standard errors, t-statistics, and p-values)? Default is FALSE. Set to TRUE for inferential statistics. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
plot |
(Optional) Do you want scatterplot(s)? Default is FALSE. |
jitter |
(Optional) Do you want scatterplot pointed jittered? By default, points jittered when there are more than 500 observations, but you can set this arguments to TRUE/FALSE to override the default. |
... |
(Optional) Additional arguments passed to |
Makes use of the wtd.cor function, part of the weights package.
Returns the coefficients of correlation among x variables; if stats=TRUE
, inferential statistics returned in tables as well.
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 11.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 240-244. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Correlation and Bivariate Regression, compiled by Barry C. Edwards.
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) correlateC(x=list(abortlaws, women.stateleg), data=states, plot=FALSE) ## Not run: # with weighted observations and inferential statistics correlateC(x=list(nes$ft.rep, nes$ft.trump.pre, nes$ft.dem, nes$ft.biden.pre), w=nes$wt, stats=TRUE) ## End(Not run)
library(RCPA3) correlateC(x=list(abortlaws, women.stateleg), data=states, plot=FALSE) ## Not run: # with weighted observations and inferential statistics correlateC(x=list(nes$ft.rep, nes$ft.trump.pre, nes$ft.dem, nes$ft.biden.pre), w=nes$wt, stats=TRUE) ## End(Not run)
This is a workhorse function for analyzing the relationship between two variables measured at the nominal or ordinal-level (factors). Basic output is a cross-tabulation with column percentages and counts. Options include weighting observations, adding control variable for controlled cross-tabulation, several plotting options, conducting Chi-Square test of independence, and measuring strength of association.
crosstabC(dv, iv, w, z, data, digits = 2, compact = FALSE, dvlabs, ivlabs, zlabs, chisq = FALSE, lambda = FALSE, somers = FALSE, cramers = FALSE, printC = FALSE, plot = TRUE, plot.response, main, xlab, ylab, z.palette, legend.title)
crosstabC(dv, iv, w, z, data, digits = 2, compact = FALSE, dvlabs, ivlabs, zlabs, chisq = FALSE, lambda = FALSE, somers = FALSE, cramers = FALSE, printC = FALSE, plot = TRUE, plot.response, main, xlab, ylab, z.palette, legend.title)
dv |
Dependent variable, should be in dataset$var form unless dataset specified in optional data argument. Should be a nominal or ordinal-level variable. |
iv |
Independent variable, should be in dataset$var form unless dataset specified in optional data argument. Should be a nominal or ordinal-level variable. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
z |
(Optional) Control variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables. |
digits |
(Optional) Number of decimal places reported in result (defaults to 2). |
compact |
(Optional) Do you want compact display of cross-tabulation with row subtotals omitted? Default is FALSE. |
dvlabs |
(Optional) A vector of names for the dependent variable's values (to abbreviate the cross-tabulation's row labels and dv labels on plots) |
ivlabs |
(Optional) A vector of names for the independent variable's values (to abbreviate the cross-tabulation's column labels and iv labels on plots) |
zlabs |
(Optional) A vector of names for the control variable's values (to abbreviate the controlled cross-tabulation's column labels and z variable labels on plots) |
chisq |
(Optional) Do you want to conduct Chi-Square Test? If z argument specific, Chi-Square Test conducted on dv-iv relationship for each value of z. |
lambda |
(Optional) Do you want Lambda reported? If z argument specified, Lambda reported for dv-iv relationship for each value of z. |
somers |
(Optional) Do you want Somers' d reported? If z argument specific, Somers' D reported for dv-iv relationship for each value of z. |
cramers |
(Optional) Do you want Cramer's V reported? If z argument specific, Cramer's V reported for dv-iv relationship for each value of z. |
printC |
(Optional) Do you want to print cross-tabulation and plot (if plot is used) to .html file in working directory? (default: FALSE) |
plot |
(Optional) Do you want a plot of the cross-tabulation? Default is TRUE (and makes a bar plot). Other plot options:
|
plot.response |
(Optional) The dv value to be summarized on plot. To combine and plot multiple dv values, use transformC and create dummy variable to be plotted. Set |
main |
(Optional) Main label for plot |
xlab |
(Optional) x-axislabel for plot |
ylab |
(Optional) y-axis label for plot |
z.palette |
(Optional) For bar and line plots with control variables (z), the name of HCL color palette to use. Default is "LightGrays". See |
legend.title |
(Optional) Title for legend shown if plot used with z argument. |
Returns a cross-tabulation
Create Cross-Tabulations to Make Comparisons with RCPA3's crosstabC Function 13:31
Plots for Cross-Tabulations with RCPA3's crosstabC Function 29:51
Making Controlled Comparisons with RCPA3's crosstabC Function 28:34
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapters 4, 5, 7, 10.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp.85-97, 150-156, 215-231. ISBN-13: 978-1506379616; ISBN-10: 150637961.
Tutorials & Resources for Making Comparisons, Graphing Relationships and Describing Patterns, Making Controlled Comparisons, and Chi-Square Test and Analysis of Variance, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) ## Not run: crosstabC(dv=nes$death.penalty, iv=nes$partyid3) # with optional w, data, chisq, somers arguments crosstabC(dv=death.penalty, iv=partyid3, w=wt, data=nes, chisq=TRUE, somers=TRUE) # example with optional w, data, z, and plot="line" arguments crosstabC(dv=death.penalty, iv=partyid3, w=wt, data=nes, z=gender, plot="line") ## End(Not run)
library(RCPA3) ## Not run: crosstabC(dv=nes$death.penalty, iv=nes$partyid3) # with optional w, data, chisq, somers arguments crosstabC(dv=death.penalty, iv=partyid3, w=wt, data=nes, chisq=TRUE, somers=TRUE) # example with optional w, data, z, and plot="line" arguments crosstabC(dv=death.penalty, iv=partyid3, w=wt, data=nes, z=gender, plot="line") ## End(Not run)
A dataset with variables about students who participated in an experiment. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
debate
debate
A data frame with 171 rows and 14 variables.
Unique identification number for each subject
Name of condition subject was assigned to
Did subject watch debate on TV? 1 = yes, 0 = no
Number correct answers on five question quiz about the debate.
Is subject Catholic? 1 = yes, 0 = no
Which candidate do you agree with on policy issues?
Which candidate has more integrity?
Which candidate is more effective leader?
Which candidate has more empathy?
Is respondent a sophomore? 1 = yes, 0 = no.
Which candidate won the debate? 1 = Kennedy ... 4 = Tie ... 7 = Nixon
Self-reported partisan identification on standard 1-7 scale
Self-reported political ideology on standard 1-7 scale
Subject's gender, 0 = male, 1 = female.
Jamie Druckman. See Appendix of printed textbook for further information.
Prints a table of descriptive statistics for variable(s) specified with x argument. Works with variables measures at any level but output varies with level of measurement (e.g. you won't get standard deviation for a nominal variable). Option for weighting observations.
describeC(x, w, data, digits = 3, printC = FALSE)
describeC(x, w, data, digits = 3, printC = FALSE)
x |
A variable or list of variables, should be in dataset$var form unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x (and w) variable. |
digits |
(Optional) Number of decimal places reported in result (defaults to 3). |
printC |
(Optional) Do you want to print table of descriptive statistics to .html file in working directory? (default: FALSE) |
Table of descriptive statistics
Generate Descriptive Statistics with RCPA3 Package's describeC Function 17:40
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 2.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 39-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.
Tutorials & Resources for Descriptive Statistics, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) # descriptive statistics for qualitative variables describeC(x=world$region) ## Not run: # descriptive statistics for numeric variable describeC(x=world$infant.mortality) # describe multiple variables in list, with optional w argument describeC(x=list(angry.about.things, approve.cong), w=wt, data=nes) ## End(Not run)
library(RCPA3) # descriptive statistics for qualitative variables describeC(x=world$region) ## Not run: # descriptive statistics for numeric variable describeC(x=world$infant.mortality) # describe multiple variables in list, with optional w argument describeC(x=list(angry.about.things, approve.cong), w=wt, data=nes) ## End(Not run)
Generates frequency distribution table and bar chart to describe distribution of variable values. Based on freq
function in descr package.
freqC(x, w, data, digits = 2, rowlabs, printC = FALSE, plot = TRUE, main, xlab, ylab, bar.col, ...)
freqC(x, w, data, digits = 2, rowlabs, printC = FALSE, plot = TRUE, main, xlab, ylab, bar.col, ...)
x |
The variable to be analyzed. If dataset not specified with data argument, should be a vector in form dataset$var. |
w |
(Optional) Sample weights (must be numeric if used), If dataset not specified with data argument, should be in form dataset$weighvar |
data |
(Optional) Name of dataset that contains x (and w) variable. |
digits |
(Optional) Number of digits to display after decimal point (default=2). |
rowlabs |
(Optional) Vector specifying custom text for labeling table rows and chart bars. The rowlabs vector must correspond to x variable's levels (if the variable has five levels, rowlabs must be length 5). Useful when default value labels are too long. |
printC |
(Optional) Do you want to print frequency distribution table and bar chart (if plot is used) to .html file in working directory? (default: FALSE) |
plot |
(Optional) Do you want a bar chart? (default set to TRUE) |
main |
(Optional) Main title of bar chart. |
xlab |
(Optional) The x-axis label of bar chart. |
ylab |
(Optional) The y-axis label of bar chart. |
bar.col |
(Optional) The name of color to use for bars. Default is "gray80". |
... |
(Optional) Additional arguments passed to |
A frequency distribution table.
Make Frequency Distribution Tables and Bar Charts with RCPA3 Package's freqC Function 15:33
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 2.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 39-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Descriptive Statistics, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) # unordered factors freqC(x=region, data=world) # ordered factors freqC(x=threat.from.china, data=nes)
library(RCPA3) # unordered factors freqC(x=region, data=world) # ordered factors freqC(x=threat.from.china, data=nes)
If you don't complete file argument, you will be prompted to select file. Supports dataset file format like Stata, SPSS, Rdata, and csv files. It previews imported data and asks you to confirm before returning a data frame. You must assign the returned data frame to an object to work with it. If getC
doesn't support a file type, it may suggest other functions and packages for importing that type of file.
getC(file, confirm = TRUE, ...)
getC(file, confirm = TRUE, ...)
file |
(Optional) Path to file you want to get and load in your R session; if you do not specify file you will be prompted to select one. |
confirm |
(Optional) Do you want to confirm getting file before function results returned? (default: TRUE) |
... |
(Optional) Additional arguments passed to loading function |
Dataset specified in file argument as a data frame. You must assign this returned data frame to an object to work with it.
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 15.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 321-327. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Doing Your Own Political Analysis, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) # basic call will prompt user to choose file ## Not run: getC() ## End(Not run)
library(RCPA3) # basic call will prompt user to choose file ## Not run: getC() ## End(Not run)
Generates frequency distribution table of binned values and a histogram to describe distribution of variable values.
histC(x, w, data, breaks, digits = 2, printC = FALSE, plot = TRUE, main, xlab, ylab, bar.col, ...)
histC(x, w, data, breaks, digits = 2, printC = FALSE, plot = TRUE, main, xlab, ylab, bar.col, ...)
x |
The variable to be analyzed. If dataset not specified with data argument, should be a vector in form dataset$var. |
w |
(Optional) Sample weights (must be numeric if used), If dataset not specified with data argument, should be in form dataset$weighvar |
data |
(Optional) Name of dataset that contains x (and w) variable. |
breaks |
(Optional) Specify how to break the x variable into bins. Options include the number of breaks, a vector specifying the breakpoints, or the name of an algorithm that generates breakpoints. Default value is "Sturges" (other algorithms are "Scott" and "FD", see details in |
digits |
(Optional) Number of digits to display after decimal points (default is 2). |
printC |
(Optional) Do you want the histogram and binned frequencies table printed to working directory? (default: FALSE) |
plot |
(Optional) Do you want the histogram graphic? (default: TRUE) |
main |
(Optional) Customize main title for histogram. |
xlab |
(Optional) Custom label for x-axis of histogram. |
ylab |
(Optional) Custom label for y-axis of histogram. |
bar.col |
(Optional) Color for histogram bars; default is "gray80". |
... |
(Optional) Additional arguments passed to |
A frequency distribution table of binned x variable values.
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 2.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 39-55. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Descriptive Statistics, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) histC(x=states$covid.cases.per1000)
library(RCPA3) histC(x=states$covid.cases.per1000)
Logistic regression analysis function with many useful features. Its standard output included a table of coefficients, table of deviance residuals, and summary of additional model information. Options include weighting observations, additional reports on odds ratios, ANOVA, multiple measures of model fit, proportional reduction in error, and diagnostic plots of residuals.
logregC(formula, w, data, digits = 3, orci = FALSE, fit.stats = FALSE, anova = FALSE, pre = FALSE, printC = FALSE, res.plots = FALSE, ...)
logregC(formula, w, data, digits = 3, orci = FALSE, fit.stats = FALSE, anova = FALSE, pre = FALSE, printC = FALSE, res.plots = FALSE, ...)
formula |
should be in dataset$dv ~ datatset$iv1 + dataset$iv2 unless dataset specified in optional data argument. |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables. |
digits |
(Optional) Number of decimal places reported in result (defaults to 2). |
orci |
(Optional) Do you want table reporting odds ratios for coefficients with confidence intervals? (default: FALSE) |
fit.stats |
(Optional) Do you want a table of assorted model fit statistics? (default: FALSE) |
anova |
(Optional) Do you want ANOVA table reported? (default: FALSE) |
pre |
(Optional) Do you want table reporting proportion reduction in error achieved by model? This is a Lambda-style measure of model fit. (default: FALSE) |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
res.plots |
(Optional) Do you want a set of diagnostic plots of model residuals? (default: FALSE) |
... |
(Optional) Additional arguments passed to |
Returns a glm (unweighted models) or svyglm (weighted models) object.
Logistic Regression Analysis with RCPA3 Package's logregC Function 13:36
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 14.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), Chapter 9. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Logistic Regression, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) ## Not run: # basic usage with variable vectors logregC(states$battleground2020 ~ states$vep16.turnout) # with post-estimation analysis logregC(states$battleground2020 ~ states$vep16.turnout, orci=TRUE, fit.stats=TRUE, anova=TRUE, pre=TRUE, res.plots=TRUE) ## End(Not run)
library(RCPA3) ## Not run: # basic usage with variable vectors logregC(states$battleground2020 ~ states$vep16.turnout) # with post-estimation analysis logregC(states$battleground2020 ~ states$vep16.turnout, orci=TRUE, fit.stats=TRUE, anova=TRUE, pre=TRUE, res.plots=TRUE) ## End(Not run)
The American National Election Survey polls individuals about their political beliefs and behavior. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
nes
nes
A data frame with 8280 rows and 429 variables.
PRE: Importance of abortion issue to R
PRE: STD Abortion: self-placement
PRE: SUMMARY: Abortion rights Supreme Court
PRE: Armed forces active duty
PRE: Years R lived at address
PRE: SUMMARY: Respondent age
PRE: How important that people agree on basic facts
POST: SUMMARY: Favor/oppose allowing refugees to come to US
POST: How important is being American to R's identity
PRE: How angry R feels about how things are going in the country
POST: SUMMARY: Approve/disapprove Affordable Care Act
PRE: SUMMARY: Approval of Congress handling its job
PRE: SUMMARY: Approve or disapprove R's governor handling COVID-19
PRE: SUMMARY: Approve or disapprove local government handling COVID-19
PRE: SUMMARY: Approve or disapprove President handling COVID-19
PRE: SUMMARY: Approve or disapprove President handling economy
PRE: SUMMARY: Approve or disapprove President handling health care
PRE: SUMMARY: Approve or dissaprove President handling immigration
PRE: SUMMARY: Approve or disapprove President handling foreign relations
PRE: SUMMARY: Approve or disapprove President handling job
POST: SUMMARY: Favor/oppose banning 'assault-style' rifles
POST: Has R ever been arrested
PRE: Is Bible word of God or men
PRE: Democratic Presidential candidate trait: really cares
PRE: Democratic Presidential candidate trait: honest
PRE: Democratic Presidential candidate trait: knowledgeable
PRE: 7pt scale liberal-conservative: Democratic Presidential candidate
PRE: Democratic Presidential candidate trait: strong leadership
PRE: SUMMARY: Favor or oppose ending birthright citizenship
POST: Agree/disagree: blacks have gotten less than they deserve
POST: Agree/disagree: past slavery & discrimination make it difficult for blacks
POST: Agree/disagree: if blacks tried harder they'd be as well off as whites
POST: Agree/disagree: blacks should work their way up without special favors
PRE: SUMMARY: Favor or oppose building a wall on border with Mexico
PRE: Rs: born US, Puerto Rico, or some other country
POST: Favor/oppose government buy back of 'assault-style' rifles
PRE: Mention: TV PROG - Tucker Carlson Tonight (Fox)
PRE: Mention: TV PROG - The Late Show with Stephen Colbert
PRE: Mention: TV PROG - Hannity (Fox)
PRE: Mention: TV PROG - The Rachel Maddow Show (MSNBC)
PRE: Media sources R used to follow presidential campaign: none
PRE: Media sources R used to follow presidential campaign: newspapers
PRE: Media sources R used to follow presidential campaign: radio news
PRE: Media sources R used to follow presidential campaign: tv programs
PRE: Media sources R used to follow presidential campaign: internet sites
POST: Limits on campaign spending
PRE: How interested in following campaigns
POST: Because of rich and powerful it's difficult for the rest to get ahead
PRE: How much R cares who wins Presidential Election [revised]
2020 Case ID
PRE: How often self censor
PRE: R name ever changed
POST: Which child trait more important: considerate or well-behaved
POST: Which child trait more important: curiosity or good manners
POST: Which child trait more important: obedience or self-reliance
POST: Which child trait more important: independence or respect
POST: SUMMARY: Favor/oppose providing path to citizeship
POST: Has R in past 12 months: gotten into a political argument
POST: Has R in past 12 months: posted comment online about political issue
POST: Has R in past 12 months: worked w/others to deal w/issue facing community
POST: Has R in past 12 months: contacted member of US Senate or House of Rep
POST: Has R in past 12 months: contacted non-elected official in federal govt
POST: Has R in past 12 months: contacted federal elected official
POST: Has R in past 12 months: given money to other organization
POST: Has R in past 12 months: given money to religious organization
POST: Has R in past 12 months: joined a protest march, rally, or demonstration
POST: Has R in past 12 months: attend mtg about issue facing community/schools
POST: Has R in past 12 months: sign internet or paper petition
POST: Has R in past 12 months: contacted non-elected official in state/local gov
POST: Has R in past 12 months: contacted elected official on state/local level
POST: Has R in past 12 months: done any volunteer work
POST: How much is climate change affecting severe weather/temperatures in US
POST: How important is issue of climate change to R
PRE: How long lived in this community YRS
POST: How often bought or boycotted product/service for social/political reasons
POST: Anyone talk to R about registering or getting out to vote
PRE: Options for election if COVID-19 continues
PRE: SUMMARY: Federal government response to COVID-19
POST: Was the coronavirus (COVID-19) was developed intentionally in a lab or not
PRE: SUMMARY: Re-opening too quickly or too slowly
PRE: Limits placed on public activity due to COVID-19 too strict or not
POST: How important should science be for decisions about COVID-19
PRE: SUMMARY: R favor/oppose death penalty
PRE: 7pt scale defense spending: self-placement
POST: Importance of reducing deficit
PRE: 7pt scale liberal-conservative: Democratic party
PRE: SUMMARY: Should children brought illegally be sent back or allowed to stay
POST: SUMMARY: Favor/oppose returning unauthorize immigrants to native country
POST: Discrimination in the US against Asians
POST: Discrimination in the US against blacks
POST: Discrimination in the US against Christians
POST: Discrimination in the US against Gays and Lesbians
POST: Discrimination in the US against Hispanics
POST: Discrimination in the US against men
POST: Discrimination in the US against Muslims
POST: Discrimination in the US against transgender people
POST: Discrimination in the US against whites
POST: Discrimination in the US against women
POST: SUMMARY: Increasing diversity made US better/worse place to live
PRE: Party Control or split government
POST: Congress change votes because of donation to campaign
PRE: Current economy good or bad
PRE: SUMMARY: National economy better or worse in last year
POST: SUMMARY: Economic mobility
PRE: SUMMARY: Economy better or worse in next 12 months
PRE: How worried about national economy
PRE: SUMMARY: Respondent 5 Category level of education
PRE: Highest level of Education
POST: How important that more Asians get elected to political office
POST: How important that more blacks get elected to political office
POST: How important that more Hispanics get elected to political office
POST: How important that more LGBT people get elected to political office
POST: How important that more women get elected to political office
PRE: Elections make government pay attention
PRE: 7pt scale environment-business tradeoff: self-placement
POST: Society should make sure everyone has equal opportunity
POST: How often post political content on Facebook
POST: How often use Facebook
POST: How much discrimination has R faced because of gender
POST: How much discrimination has R faced personally because or race/ethnicity
POST: SUMMARY: Federal government treats blacks or whites better
PRE: SUMMARY: Federal Budget Spending: aid to the poor
PRE: SUMMARY: Federal Budget Spending: Tightening border security
PRE: SUMMARY: Federal Budget Spending: dealing with crime
PRE: SUMMARY: Federal Budget Spending: protecting the environment
PRE: SUMMARY: Federal Budget Spending: building and repairing highways
PRE: SUMMARY: Federal Budget Spending: public schools
PRE: SUMMARY: Federal Budget Spending: Social Security
PRE: SUMMARY: Federal Budget Spending: welfare programs
POST: Does R consider themself a feminist or anti-feminist
POST: How important is being a feminist
PRE: R how much better or worse off financially than 1 year ago
PRE: R how much better or worse off financially next year
PRE: How worried is R about current financial situation
POST: Feeling thermometer: Asian-Americans
POST: Feeling thermometer: Asians
POST: Feeling thermometer: Democratic Presidential candidate: Joe Biden
PRE: Feeling Thermometer: Joe Biden, Democratic Presidential candidate
POST: Feeling thermometer: big business
POST: Feeling thermometer: blacks
POST: Feeling thermometer: Black Lives Matter
POST: Feeling thermometer: capitalists
POST: Feeling thermometer: Center for Disease Control (CDC)
POST: Feeling thermometer: Christian fundamentalists
POST: Feeling thermometer: Christians
POST: Feeling thermometer: congress
POST: Feeling thermometer: conservatives
PRE: Feeling Thermometer: Democratic Party
POST: Feeling thermometer: Dr. Anthony Fauci
POST: Feeling thermometer: Federal Bureau of Investigation (FBI)
POST: Feeling thermometer: feminists
POST: Feeling thermometer: gay men and lesbians
POST: Feeling thermometer: Democratic Vice Presidential candidate: Kamala Harris
PRE: Feeling Thermometer: Kamala Harris, Democratic Vice-Presidential candidate
POST: Feeling thermometer: Hispanics
POST: Feeling thermometer: Immigration and Customs Enforcement (ICE) agency
POST: Feeling thermometer: illegal immigrants
POST: Feeling thermometer: Jews
POST: Feeling thermometer: journalists
POST: Feeling thermometer: liberals
POST: Feeling thermometer: #MeToo movement
POST: Feeling thermometer: Muslims
POST: Feeling thermometer: North Atlantic Treaty Organization (NATO)
POST: Feeling thermometer: National Rifle Association (NRA)
PRE: Feeling Thermometer: Barack Obama
POST: Feeling thermometer: Republican Vice Presidential candidate: Mike Pence
PRE: Feeling Thermometer: Mike Pence, Republican Vice-Presidential candidate
POST: Feeling thermometer: police
POST: Feeling thermometer: Planned Parenthood
PRE: Feeling Thermometer: Republican Party
POST: Feeling thermometer: rural Americans
POST: Feeling thermometer: scientists
POST: Feeling thermometer: U.S. Supreme Court
POST: Feeling thermometer: socialists
POST: Feeling thermometer: transgender people
POST: Feeling thermometer: Republican Presidential candidate: Donald Trump
PRE: Feeling Thermometer: Donald Trump, Republican Presidential candidate
POST: Feeling thermometer: United Nations (UN)
POST: Feeling thermometer: labor unions
POST: Feeling thermometer: whites
POST: Feeling thermometer: World Health Organization (WHO)
PRE: Should gay and lesbian couples be allowed to adopt
PRE: SUMMARY: Favor/oppose laws protect gays lesbians against job discrimination
PRE: R position on gay marriage
PRE: SUMMARY: Services to same sex couples
PRE: What is your (R) sex? [revised]
PRE: 7pt scale gov assistance to blacks scale: self-placement
POST: SUMMARY: Favor/oppose government trying to reduce income inequality
PRE: Government action about rising temperatures (STRENGTH)
PRE: Government action about rising temperatures
PRE: How many in government are corrupt
PRE: 7pt scale guaranteed job-income scale: self-placement
PRE: 7pt scale gov-private medical insurance scale: self-placement
POST: SUMMARY: Increase/decrease government spending to help pay for health care
PRE: Government run by a few big interests or for benefit of all
PRE: 7pt scale spending & services: self-placement
PRE: How concerned government might undermine media
PRE: Does government waste much tax money
POST: Would it be good for society to have more or less government regulation
PRE: How many grandparents born outside the US
PRE: Where R grew up
POST: SUMMARY: Favor/oppose background checks for gun puchases
POST: Should federal government make it more difficult or easier to buy a gun
POST: How important is issue of gun access to R
PRE: How many Guns owned
PRE: How happy R feels about how things are going in the country
POST: How difficult was it for R to vote
POST: Has R experienced harrassment at work
POST: How often has R experienced harrassment at work
POST: Does R have any sons or daughters - one or more daughters
POST: Does R have any sons or daughters - no sons and no daughters
POST: Does R have any sons or daughters - one or more sons
PRE: Does R have health insurance
PRE: How likely R able to pay all health care costs in next 12 months
PRE: Health of R
PRE: R concerned about losing health insurance
PRE: R concerned about paying for health care
POST: How much do people need help from experts to understand science
PRE: Anyone in household COVID-19 based on symptoms
PRE: Anyone in household tested pos for COVID-19
PRE: R living with how many family members
PRE-POST: SUMMARY: Total (family) income
PRE: SUMMARY: Total (family) income
PRE: Is there a working HH landline phone
PRE: How many children in HH age 0-17
PRE: Domestic partnership status
PRE: Anyone in HH belong to labor union
PRE: How likely R able to make all housing payments in next 12 months
POST: Evidence that hydroxychloroquine is effective treatment for COVID-19 or no
POST: SUMMARY: effect of illegal immiration on crime rate
POST: What should immigration levels be
PRE: US government policy toward unauthorized immigrants
POST: How likely immigration will take away jobs
PRE: How important branches of government keep one another from too much power
PRE: How important that news organizations free to criticize
PRE: How important elected officials face serious consequences for misconduct
POST: SUMMARY: Favor/oppose new limits on imports
PRE: SUMMARY: How much larger is income gap today
PRE: Income gap today more or less than 20 years ago
POST: We'd be better off if worried less about equality
PRE: Force to solve international problems
PRE: Money invested in Stock Market
POST: Congress pass laws that benefit contributor individuals
POST: Congress pass laws that benefit contributor organization
PRE: Prefer government official who compromises or sticks to principles
PRE: 3pt scale liberal-conservative self-placement
PRE: 7pt scale liberal-conservative self-placement
PRE: How satisfied is R with life
POST: Life experience: does R choose products because they are made in America
POST: Life experience: has R displayed American flag on house in past year
POST: Life experience: has R ever received food stamps or other public assistanc
POST: Life experience: has R gone hunting or fishing in past year
POST: Life experience: does R know someone moved to U.S. from another country
POST: Life experience: does R currently owe money on student loans
POST: Life experience: does R a have pension or retirement account
POST: Life experience: has R used public transportation in past year
POST: Life experience: has R ever been bitten by a shark
POST: R has family/neighbors/coworkers/friends who are gay, lesbian or bisexual
PRE: Marital status
PRE: Put off checkup and vaccines
POST: SUMMARY: Attention to sexual harrassment as gone too far/not far enough
POST: Is R lower middle class, middle class, upper middle class? [EGSS]
POST: Should the minimum wage be raised, kept the same, or lowered
POST: The world is changing & we should adjust view of moral behavior
POST: Not a big problem if some have more chance in life
POST:SUMMARY: Less or more government
POST: SUMMARY Should federal govt do more/less about opioid drug addiction
POST: How often does R have concerned feelings for other racial/ethnic groups
POST: How often R imagines how they would feel before criticizing other groups
POST: How often does R try to understand perpective of other racial/ethnic group
POST: How often R feels protective of someone due to race or ethnicity
PRE: SUMMARY: Require employers to offer paid leave to parents of new children
PRE: Native status of parents
PRE-POST: SUMMARY: Party of registration
PRE: Party ID, 3 categories
PRE: SUMMARY: Party ID
PRE: Party identity importance
POST: Much of what people hear in schools and media are lies by those in power
PRE: Need to be more sensitive talking or people too easily offended
POST: How much opportunity in America for average person to get ahead
POST: How much influence do Asians have in US politics
POST: How much influence do blacks have in US politics
POST: [STD] Public officials don't care what people think
POST: Our political system only works for insiders with money and power
POST: How much influence do Hispanics have in US politics
POST: How much have political differences hurt relationships w/family
POST: [STD] Have no say about what goverment does
POST: Business and politics controlled by few powerful people
POST: [REV] Politics/government too complicated to understand
POST: [REV] How well does R understand important political issues
POST: How much influence do whites have in US politics
POST: R contribute money to individual candidate running for public office
POST: R contribute to any other group that supported or opposed candidates
POST: R contribute money to political party during this election year
POST: R go to any political meetings, rallies, speeches, dinners
POST: R attend online political meetings, rallies, speeches, fundraisers
POST: R do any (other) work for party or candidate
POST: R wear campaign button or post sign or bumper sticker
POST: R ever discuss politics with family or friends
POST: R talk to anyone about voting for or against a party or candidate
POST: SUMMARY: Police treat blacks or whites better
POST: During past 12 months, R or any family members stopped by police
POST: How often do police officers use more force than necessary
PRE: SUMMARY: Political violence compared to 4 yrs ago
PRE: How often does R pay attention to politics and elections
PRE: On which program does Federal government spend the least
POST: Office recall: German Chancellor - Angela Merkel [coded/scheme 1]
PRE: Party with most members in House before election
POST: Office recall: Russian President - Vladimir Putin [coded/scheme 1]
POST: Office recall: SCOTUS Chief Justice - John Roberts [coded/scheme 1]
PRE: How many years in full term for US Senator
PRE: Party with most members in Senate before election
POST: Office recall: Speaker of the House - Nancy Pelosi [coded/scheme 1]
POST: Office recall: Vice-President - Mike Pence [coded]
POST: Post materialism most important 1A
POST: Post materialism next most important 1B
POST: Post materialism most important 2A
POST: Post materialism next most important 2B
POST: SUMMARY: Favor/oppose preferential hiring/promotion of blacks
PRE: Appropriate/inappropriate Pres ask foreign countries to investigate rivals
PRE: SUMMARY: Helpful/harmful if Pres didn't have to worry about congress/courts
PRE-POST: SUMMARY: 2020 Presidential vote
PRE: Did R vote in a Presidential primary or caucus
PRE: SUMMARY: Protestors actions been mostly violent or peaceful
PRE: SUMMARY: R self-identified race/ethnicity
POST: How often post political content on Reddit
POST: How often use Reddit
POST: SUMMARY: Favor/oppose increased regulation on greenhouse emissions
SAMPLE: Census region
PRE: Ever attend church or religious services
PRE: Attend religious services how often
PRE: What is present religion of R
PRE: SUMMARY: Major group religion summary
PRE: Is religion important part of R life [revised]
PRE: Religious identification
PRE: 7pt scale liberal-conservative: Republican party
PRE: SUMMARY: Favor or oppose restricting journalist access
POST: SUMMARY: People in rural areas get more/less from government
POST: SUMMARY: People in rural areas have too much/too little influence
POST: SUMMARY: People in rural areas get too much/too little respect
POST: Does R currently live in a rural or urban area
POST: How important is urban or rural to R's identity
PRE: Likelihood of Russian interference in upcoming election
POST: Did Russia try to interfere in 2016 presidential election or not
POST: SUMMARY: Favor/oppose separating children of detained immigrants
PRE: Sexual orientation of R [revised]
POST: R smoked 100 cigarettes in life
POST: R currently smoking
POST: How would R describe social class [EGSS]
PRE: How important to speak English in US
PRE: Split-ticket voting
SAMPLE: Sample location FIPS state
SAMPLE: Sample location state postal abbreviation
PRE: How often took survey seriously
POST: How many days in past week discussed politics with family or friends
POST: Favor or oppose tax on millionaires
POST: DHS: How worried about terrorist attack in near future
POST: How much is China a threat to the United States
POST: How much is Germany a threat to the United States
POST: How much is Iran a threat to the United States
POST: How much is Japan a threat to the United States
POST: How much is Mexico a threat to the United States
POST: How much is Russia a threat to the United States
POST: Fewer problems if there was more emphasis on traditional family values
POST: SUMMARY: Favor/oppose free trade agreements
POST: SUMMARY: Increasing trade good/bad for international relationships
POST: SUMMARY: International trade increaded/decreased jobs abroad
POST: SUMMARY: International trade increased/decreased jobs in US
POST: R has family/neighbors/coworkers/friends who are transgender
POST: SUMMARY: Favor/oppose transender people serve in military
PRE: SUMMARY: Transgender policy
POST: If people were treated more fairly we would have fewer problems
PRE: SUMMARY: Favor or oppose Senate acquittal decision
PRE: Republican Presidential Candidate trait: really cares
PRE: SUMMARY: Corruption increased or decreased since Trump
POST: Did Trump administration deport more immigrants or did Obama
PRE: Republican Presidential Candidate trait: honest
PRE: SUMMARY: Favor or oppose House impeachment decision
PRE: Republican Presidential Candidate trait: knowledgeable
PRE: 7pt scale liberal-conservative: Republican Presidential candidate
PRE: Republican Presidential Candidate trait: strong leadership
PRE: Did Trump ask Ukraine to investigate rivals
PRE: How often trust government in Washington to do what is right [revised]
PRE: Trust election officials
POST: SUMMARY: Trust ordinary people/experts for public policy
PRE: How much trust in news media
PRE: How often can people be trusted
PRE-POST: SUMMARY: Voter turnout in 2020
POST: How often post political content on Twitter
POST: How often use Twitter
PRE: SUMMARY: Unemployment better or worse in last year
PRE: More or less unemployment in next year
POST: What is the current unemployment rate
POST: SUMMARY: Favor/oppose federal program giving citizens $12K/year
PRE: Best way to deal with urban unrest
POST: SUMMARY: US better or wose than most other countries
PRE: Are things in the country on right track
PRE: SUMMARY: Country would be better off if we just stayed home
PRE: During last year, US position in world weaker or stronger
POST: SUMMARY: Favor/oppose requiring vaccines in schools
POST: Does most scientific evidence show vaccines cause autism or not
POST: SUMMARY: Health benefits of vaccinations outweigh risks
PRE: Justified to use violence
POST: Preference strong for Presidential candidate for whom R vote
POST: How long before election R made decision Presidential vote [coded]
PRE: Votes counted accurately
POST: How often are votes counted fairly
PRE: SUMMARY: Voting as duty or choice
PRE: SUMMARY: Favor/oppose allowing felons to vote
PRE: SUMMARY: Favor/oppose requiring ID when voting
PRE: SUMMARY: Favor/oppose vote by mail
PRE: How often people denied right to vote
POST: How long was wait time at polling place
POST: When R voted in 2020 election
POST: How likely whites unable to find jobs because employers hiring minorities
POST: Do women complaining about discrimination cause more problems
PRE: Women seek to gain power by getting control over men
POST: Do women demanding equality seek special favors
PRE: Women interpret innocent remarks as sexist
POST: SUMMARY: Better/worse if man works and woman takes care of home
PRE: Describe R's employment
PRE: How many hours R worked per week
PRE: R worked for pay last week
POST: SUMMARY: Easier/harder for working mother to bond with child
PRE: SUMMARY: R occupation status 1 digit
POST: Better if rest of world more like America
POST: Have world temperatuers have risen on average or last 100 years or not
Full sample pre-election weight
Full sample post-election weight
2020 American National Election Survey. See Appendix of printed textbook for further information
Prints table or summary of results to a .html file in local working directory. Converting Console format tables to .html tables helps users quickly create publication- and presentation-ready tables. The .html file's name is displayed as Console message.
Current date added to Table.Output.html file name to keep output organized. You can print output directly from Companion functions using printC=TRUE
argument (where available).
printC(objx, file)
printC(objx, file)
objx |
A table or data frame. The table must be html-ready, not all Console output is organized in tables. If objx is not a html-ready table, |
file |
(Optional) The path/file name for .html output. If not specified, function will output to .html file in your working directory. |
No return to R. The formatted objx is outputted to a .html file in working directory.
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 1.
library(RCPA3) example.table <- freqC(x=world$vdem.4cat, plot=FALSE) # running printC will generate a .html file in your working directory ## Not run: printC(example.table, file=tempfile(fileext = ".html")) ## End(Not run)
library(RCPA3) example.table <- freqC(x=world$vdem.4cat, plot=FALSE) # running printC will generate a .html file in your working directory ## Not run: printC(example.table, file=tempfile(fileext = ".html")) ## End(Not run)
Linear regression analysis function with many useful features. Standard output of results includes table of coefficients, table of residuals, and additional model information. Options for weighting observations, analysis of variance (ANOVA), performing post-estimation diagnostic tests, including testing normality of residuals and constant variance, and generating diagnostic plots of residuals.
regC(formula, w, data, digits = 3, anova = FALSE, norm.test = FALSE, ncv.test = FALSE, linear.test = FALSE, reset.test = FALSE, outlier.test = FALSE, vif = FALSE, printC = FALSE, res.plots = FALSE, ...)
regC(formula, w, data, digits = 3, anova = FALSE, norm.test = FALSE, ncv.test = FALSE, linear.test = FALSE, reset.test = FALSE, outlier.test = FALSE, vif = FALSE, printC = FALSE, res.plots = FALSE, ...)
formula |
should be in dataset$dv ~ datatset$iv1 + dataset$iv2 unless dataset specified in optional data argument. If weights are specified using w argument, the formula cannot contain functions or logical statements (all variables in the function must be named in the dataset). |
w |
(Optional) Sampling weights of variable, must be numeric; should be in dataset$weightvar form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains dv, iv (and w) variables. |
digits |
(Optional) Number of decimal places reported in result (defaults to 2). |
anova |
(Optional) Do you want ANOVA table reporting F-test for all predictors? (default: FALSE) |
norm.test |
(Optional) Test assumption that regression residuals follow normal distribution (default: FALSE) |
ncv.test |
(Optional) Test assumption that regression residuals have constant variance (default: FALSE) |
linear.test |
(Optional) Report results of linearity test? (default: FALSE) |
reset.test |
(Optional) Report results of model specification test? (default: FALSE) |
outlier.test |
(Optional) Test whether outlier observations have outsized leverage on results (default: FALSE) |
vif |
(Optional) Report variance inflation factors to assess multicollinearity? (default: FALSE) |
printC |
(Optional) Do you want to print tables of results (and residuals plots if res.plots=TRUE) to .html file in working directory? (default: FALSE) |
res.plots |
(Optional) |
... |
(Optional) Additional arguments passed to |
Returns a lm or svyglm object.
Bivariate Regression Analysis with RCPA3 Package's regC Function 10:31
Multiple Regression Analysis with RCPA3 Package's regC Function 14:55
Analyzing Regression Residuals with RCPA3 Package's regC Function 12:41
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapters 11, 12, 13.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 244-271. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Correlation and Bivariate Regression, Multiple Regression, and Analyzing Regression Residuals, compiled by Barry C. Edwards.
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) ## Not run: # basic usage regC(states$vep20.turnout ~ states$hs.or.more) # with w and data arguments regC(nes$ft.unions ~ nes$ft.dem, w=nes$wt) # multiple IV with some post-estimation tests regC(peace.index ~ vdem.edi.score + hdi, data=world, norm.test=TRUE, ncv.test=TRUE) ## End(Not run)
library(RCPA3) ## Not run: # basic usage regC(states$vep20.turnout ~ states$hs.or.more) # with w and data arguments regC(nes$ft.unions ~ nes$ft.dem, w=nes$wt) # multiple IV with some post-estimation tests regC(peace.index ~ vdem.edi.score + hdi, data=world, norm.test=TRUE, ncv.test=TRUE) ## End(Not run)
Visualize expected sampling distributions for sample statistics. You can plot the probability and cumulative density functions for statistics based on either the normal distribution or a t-distribution.
The sampdistC
function also generates the confidence interval (default 95%) for a sample statistic which is useful for obtaining the CI of a summary statistic (when you're not estimating it from the dataset yourself).
sampdistC(stat, se, t.df, plot.cdf = FALSE, ci = 95, digits = 3, printC = FALSE)
sampdistC(stat, se, t.df, plot.cdf = FALSE, ci = 95, digits = 3, printC = FALSE)
stat |
A numeric statistic, the point estimate of a parameter based on a sample of observations, like a sample mean or a sample proportion. |
se |
The standard error of the statistic, must be a positive number. |
t.df |
(Optional) If critical values for sampling distribution should be based on t-distribution (generally true when statistic is a mean), set t.df to the number of degrees of freedom (typically n-1). |
plot.cdf |
(Optional) Do you want to plot the cumulative density function? Default = FALSE (for probability density function). |
ci |
(Optional) Specify desired confidence level for confidence interval as a percentage. Set ci=FALSE to suppress CI table (default: 95) |
digits |
(Optional) Number of digits after decimal to display in CI table (default: 3) |
printC |
(Optional) Do you want to sampling distribution plot to .html file in working directory? (default: FALSE) |
None (makes a plot)
Viewing Sampling Distributions with RCPA3's sampdistC Function 21:51
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 8.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), Chapter 6. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Foundations of Inference, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) sampdistC(stat=10, se=1) ## Not run: # based on normal distributions sampdistC(stat=10, se=1, plot.cdf=TRUE) # based on t-distribution with 15 degrees of freedom sampdistC(stat=8, se=2, t.df=15) sampdistC(stat=8, se=2, t.df=15, plot.cdf=TRUE) ## End(Not run)
library(RCPA3) sampdistC(stat=10, se=1) ## Not run: # based on normal distributions sampdistC(stat=10, se=1, plot.cdf=TRUE) # based on t-distribution with 15 degrees of freedom sampdistC(stat=8, se=2, t.df=15) sampdistC(stat=8, se=2, t.df=15, plot.cdf=TRUE) ## End(Not run)
Returns case-level information in order specified by user. You can sort by additional criteria to break ties. Useful for learning about units of analysis and selecting cases for qualitative research designs.
sortC(id, by, data, thenby, descending = TRUE, limit, confirm = TRUE, printC = FALSE)
sortC(id, by, data, thenby, descending = TRUE, limit, confirm = TRUE, printC = FALSE)
id |
A variable in the dataset (data) that identfies individual cases, typically the name of states, countries, etc. |
by |
Variable the cases should be sorted by. |
data |
(Optional) Dataset to be sorted. |
thenby |
(Optional) Criteria for sorting cases after sorting with the "by" variable. Useful if many cases tied on first criteria. |
descending |
(Optional) Should the cases be sorted in descending order? By default, set to TRUE. When sorting ordered factors, check that the levels higher numerically correspond to the sort order you have in mind. |
limit |
(Optional) The number of rows to report. If there are many observations to be sorted, you may want to limit output to 5, 10, etc. rows. |
confirm |
(Optional) If function is going to return long table of results (more than 20 rows), you'll be asked for confirmation (use |
printC |
(Optional) Do you want to print table of sorted observations to to .html file in working directory? (default: FALSE) |
A data frame of sorted observations.
Sort and View Case-Level Information with the sortC Function 12:22
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapters 2, 6.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 122-123. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Descriptive Statistics, compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) # basic usage sortC(id=state, by=abortlaws, data=states) ## Not run: # options to limit results and sort in ascending order sortC(id=country, by=gini.index, descending=FALSE, limit=10, data=world) # sort by and thenby sortC(id=country, by=vdem.4cat, thenby=gini.index, descending=c(FALSE, FALSE), data=world, confirm=FALSE) sortC(id=country, by=vdem.4cat, thenby=gini.index, descending=c(FALSE, TRUE), data=world, confirm=FALSE) ## End(Not run)
library(RCPA3) # basic usage sortC(id=state, by=abortlaws, data=states) ## Not run: # options to limit results and sort in ascending order sortC(id=country, by=gini.index, descending=FALSE, limit=10, data=world) # sort by and thenby sortC(id=country, by=vdem.4cat, thenby=gini.index, descending=c(FALSE, FALSE), data=world, confirm=FALSE) sortC(id=country, by=vdem.4cat, thenby=gini.index, descending=c(FALSE, TRUE), data=world, confirm=FALSE) ## End(Not run)
A dataset with variables about the 50 states. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
states
states
A data frame with 50 rows and 149 variables.
Number of abortions per 1000 women 15-44, 2008
Number of restrictions on abortion
Restrictiveness of state abortion laws, 3 ordinal categories
Percentage of 25+ population with graduate or professional degree
Alcohol consumption (gal/capita) 2007
Percentage freq attend relig serv (Pew)
Percentage of 25+ population with bachelor's degree or more
Battleground in 2020 election?
Two-party vote share for Biden in 2020 election
Electoral College votes for Biden in 2020 election
State business tax climate ranking
State business tax climate rating
Percentage of population black or African American
Percent of state legislators who are African American
Brady Campaign ranking
Brady Campaign score
Percentage of households with broadband Internet subscription
Motor vehicle fatalities (per 100,000 pop)
Motor vehicle fatalities per 100,000 pop (2007)
Cigarette tax per pack
Cigarette tax per pack, 3 ordinal categories
Packs bimonthly per adult pop
Citizen ideology index
Vote share for Clinton in 2016 election
Percentage of state's 2020 congressional delegation that is Democratic
Higher scores more Dem
3 quantiles of cook_index
Population incarcerated per 100,000 state residents
Population under correctional supervision per 100,000 state residents
COVID cases (as of June 2021)
COVID cases per 1,000 persons (as of June 2021)
COVID deaths (as of June 2021)
COVID deaths per 1,000 persons (as of June 2021)
Maximum of COVID response stringency index
Mean of COVID response stringency index
Percentage of population fully vaccinated against COVID (as of June 2021)
Burglary rate, per 100,000 population
Murder and non-negligent manslaughter rate, per 100,000 population
Property crime rates, per 100,000 population
Violent crime rate, per 100,000 population
Executions since 1976
Death penalty exonerations since 1973
Does state retain death penalty?
Federal defense expenditures per capita
Percent of state legislators who are Democrats
Population per square mile
Census division
Drug overdose death rate per 100,000 adults
Earmarks per capita (in dollars)
Percentage of population born outside the United States
Billman's policy scale
RECODE of gay_policy (Billman's policy scale)
Does state have 'most conservative' gay policies?
Lax-Phillips opinion index
Gay rights: public support
Letter grade of state's gun control laws, from Giffords Law Center
Ranking of state's gun control laws, from Giffords Law Center
GINI index score
Income equality ranking
Precentage workforce government workers (2012)
Background checks per 100,000 pop (2012)
Gun dealers per 100,000 pop
Gun deaths per 100k
Gun murder rate (2010)
Number of state gun control laws
Number of state gun control laws, 3 ordinal categories
Ranking of best states for gun owners
Median household income (dollars)
Percentage of poulation Hispanic or Latino (of any race)
Percent of state legislators who are Hispanic/Latino
Mean NOMINATE score of state's House delegation
Percentage of 25+ population attained at least high school diploma or equivalent
Years of social studies required to graduate high school
Number of infant deaths per 1,000 live births
Method used to select appellate court judges
Does state elect appellate court judges?
Size of state in square miles
State legal climate rating 2015
State legal climate ranking 2015
Rating of conservatism of state legislature
State legislative professionalism rank for 2015
State legislative professionalism score for 2015
Ordinal ranking of state policies for LQBTQ equality
Number of laws passed that advance LQBTQ equality
Median age (years)
State action on Medicaid expansion pursuant to ACA
State minimum wage
Percentage of adults with a body mass index of 30.0 or higher
Retail opioid prescriptions dispensed per 100 persons
Percentage of population 65 years and over
Polarization in State Legislatures, Lower chambers
Polarization in State Legislatures, Upper chambers
Policy adoption rate score
State population, 2016 (in 100k)
Percentage of population 18 to 24 years old
State population in 2020
Percentage increase/decrease in population from 2010 to 2020
State marijuana laws in 2017
Percentage of people in poverty
Per capita income
Number of pregnancies per 1,000 women aged 15-19
Unintended pregnancy rate per 1,000 women 15-44
Percentage of adults who say abortion should be legal in all/most cases
Percentage adults self-identifying as conservative
Percentage adults self-identifying as liberal
Percentage adults self-identifying as moderate
Census region
Percentage Catholic (2012)
Percentage Protestant (2012)
Percentage high religiosity (2012)
Percent religion "A great deal of guidance"
Overall index of religiosity
Percentage low religiosity (2012)
Relig observance-belief scale (Pew)
Religiosity
Right to work state?
Average salary of public school teachers
Expenditure per student in average daily attendance
Students enrolled per teacher
Secularism scale (Pew)
3 quantiles of secularism
Data_Value
Southern state?
Percentage of population that only speaks English
State Name
Overall quality of state government administrative functions
Two-letter abbreviation of state name
Number of deaths due to intentional self-harm per 100,000 population
State's primary revenue source
Does state have term limits for legislators?
Vote share for Trump in 2016 election
Electoral College votes for Trump in 2016 election
Two-party vote share for Trump in 2020 election
Electoral college votes for Trump in 2020 election
Difference in voter turnout in 2020 compared to 2016
Percentage of population under age 18
State unemployment rate
No health insurance coverage
Percent of workers who are union members
Ordinal-level measurement of state's percentage union membership
Percent urban population
Percent turnout of voting eligible population in 2016
Percent turnout of voting eligible population in 2018
Percent turnout of voting eligible population in 2020
Volunteer hours per resident
Volunteer rate
Voter identification law in effect in 2017
Percentage of population white
Percent of state legislators who are women
Data sources vary. See Appendix of printed textbook for further information.
Conducts one and two-sample difference of means tests (t-tests). Options for weighting observations, known population standard deviation, equal or unequal variances, paired observations.
testmeansC(x1, x2, w, data, dv, iv, digits = 2, var.equal = FALSE, paired = FALSE, pop.sd = FALSE, var.test = FALSE, printC = FALSE, ci.table = TRUE, ci.level = 95, ci.plot = TRUE, main, xlab, xlim, ...)
testmeansC(x1, x2, w, data, dv, iv, digits = 2, var.equal = FALSE, paired = FALSE, pop.sd = FALSE, var.test = FALSE, printC = FALSE, ci.table = TRUE, ci.level = 95, ci.plot = TRUE, main, xlab, xlim, ...)
x1 |
The first variable to be compared (mean of x1 will be compared to mean of x2). Must be numeric variable. Should be in the form dataset$var, unless dataset specified with data argument. |
x2 |
The variable (or number) to which x1 is compared. Should be in the form dataset$var, unless dataset specified with data argument. You can set x2 equal to a number to conduct a one sample means test. For example, to test whether x1 could have population mean of 50, you'd set x2 = 50. |
w |
(Optional) Weights variable (optional). Should be in the form dataset$var, unless dataset specified with data argument. |
data |
(Optional) The dataset that contains x1, x1 and x2, or dv and iv. |
dv |
The dependent variable. Must be numeric variable. Should be in the form dataset$var, unless dataset specified with data argument. |
iv |
The independent variable. Should have two distinct values (like treatment and control). Should be in the form dataset$var, unless dataset specified with data argument. |
digits |
(Optional) Number of digits to report after decimal place, optional (default: 3). |
var.equal |
(Optional) With two-sample tests, do you want to assume equal variances? (default: FALSE) |
paired |
(Optional) With two-sample tests, are the observations paired? (default: FALSE) |
pop.sd |
(Optional) If the population standard deviation is known, you can specify it. |
var.test |
(Optional) If set to TRUE, will test the assumption that two sample variance are equal using an F test. Default is FALSE. The var.test option implemented for both weighted and unweighted analysis. If you are not using sample weights, you can supplement this F test with additional tests such as |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
ci.table |
(Optional) Confidence level for calculating the confidence interval of the difference of means, defaults to 95. Set to F or FALSE to omit confidence interval from results. |
ci.level |
(Optional) Desired confidence level, as percentage (default: 95) |
ci.plot |
(Optional) Do you want a plot of the confidence interval of the difference of means? (default: TRUE) |
main |
(Optional) Main title for plot of confidence interval of difference |
xlab |
(Optional) Label for x-axis of plot of confidence interval of difference |
xlim |
(Optional) A vector (of length 2) specifying the range of the x-axis, useful to zoom in on CI. |
... |
(Optional) Additional arguments passed to |
No return
Testing Means with RCPA3 Package's testmeansC Function 12:22
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 9.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp.201-215. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Hypothesis Tests with One and Two Samples, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site, find datasets for your own research and resources to help with the analysis.
library(RCPA3) ## Not run: # one sample test against hypothesized value testmeansC(x1=world$literacy, x2=80) # with x1 and x2 testmeansC(x1=ft.trump.post, x2=ft.pence.post, w=wt, data=nes) # with paired x1 and x2 testmeansC(x1=nes$ft.pence.post, x2=nes$ft.pence.pre, w=nes$wt, paired=TRUE) # with dv and iv testmeansC(dv=nes$ft.bigbiz, iv=nes$gender, w=nes$wt) ## End(Not run)
library(RCPA3) ## Not run: # one sample test against hypothesized value testmeansC(x1=world$literacy, x2=80) # with x1 and x2 testmeansC(x1=ft.trump.post, x2=ft.pence.post, w=wt, data=nes) # with paired x1 and x2 testmeansC(x1=nes$ft.pence.post, x2=nes$ft.pence.pre, w=nes$wt, paired=TRUE) # with dv and iv testmeansC(dv=nes$ft.bigbiz, iv=nes$gender, w=nes$wt) ## End(Not run)
Difference of proportions test with optional sample weights. Reports P-value of two-tailed significance test. Currently limited to testing one response from one dataset. If you want to compare x1 from dataset1 and x2 from dataset2, you can create new dataframe to test as dv ~ iv where dv is vector of x1 and x2 values and iv is vector identifying the source (i.e. dataset1 and dataset2). If you want to compare different responses, such as "Yes" value for x1 and "Agree" value for x2, you will need to transform one of the variables so they have comparable response values.
testpropsC(x1, x2, w, data, dv, iv, digits = 3, response, printC = FALSE, ci.table = TRUE, ci.level = 95, ci.plot = TRUE, main, xlab, xlim, ...)
testpropsC(x1, x2, w, data, dv, iv, digits = 3, response, printC = FALSE, ci.table = TRUE, ci.level = 95, ci.plot = TRUE, main, xlab, xlim, ...)
x1 |
A categorical variable |
x2 |
Value or variable to compare x1 against. |
w |
(Optional) Weights variable. |
data |
(Optional) Specify name of dataset (data frame) with x1 and x2 variables (or dv and iv). |
dv |
Dependent variable |
iv |
Independent variable, should have only two unique values. For comparison purposes, group1 will be first level of iv and group2 will be the second level of iv. To change order of groups, you can modify levels(iv). |
digits |
(Optional) Number of digits to report after decimal place, optional (default: 3). |
response |
(Optional) Identify the response value you wish to compare. If not specified, the function will compare first value of the dv (or x1 variable). If you want to group multiple responses together, use transformC to make dummy variable. |
printC |
(Optional) Do you want results printed to .html file in your working directory? Default is FALSE. Set to TRUE to print results. |
ci.table |
(Optional) Do you want a table reporting confidence interval of the difference of proportions? (default: TRUE) |
ci.level |
(Optional) Desired confidence level, as percentage (default: 95) |
ci.plot |
(Optional) Do you want a plot of the confidence interval of the difference of proportions? (default: TRUE) |
main |
(Optional) Main title for plot of confidence interval of difference |
xlab |
(Optional) Label for x-axis of plot of confidence interval of difference |
xlim |
(Optional) A vector (of length 2) specifying the range of the x-axis, useful to zoom in on CI. By default, |
... |
(Optional) Additional arguments passed to plot function for the CI plot |
No return
Testing Proportions with RCPA3 Package's testpropsC Function 27:33
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 9.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp.201-215. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Hypothesis Tests with One and Two Samples, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) ## Not run: # one sample test: x1 variable against hypothesized value (of x2) testpropsC(x1=nes$gun.bg.checks, x2=.500, w=nes$wt, response="1. Favor a great deal", xlim=c(0, .2)) # two sample test x1 versus x2 testpropsC(x1=approve.local.covid, x2=approve.pres.covid, w=wt, data=nes, response="1. Approve strongly", xlim=c(0, .2)) # test of proportions dv by iv testpropsC(dv=marital, iv=gender, w=wt, data=nes, response="3. Widowed", xlim=c(-.10, 0)) ## End(Not run)
library(RCPA3) ## Not run: # one sample test: x1 variable against hypothesized value (of x2) testpropsC(x1=nes$gun.bg.checks, x2=.500, w=nes$wt, response="1. Favor a great deal", xlim=c(0, .2)) # two sample test x1 versus x2 testpropsC(x1=approve.local.covid, x2=approve.pres.covid, w=wt, data=nes, response="1. Approve strongly", xlim=c(0, .2)) # test of proportions dv by iv testpropsC(dv=marital, iv=gender, w=wt, data=nes, response="3. Widowed", xlim=c(-.10, 0)) ## End(Not run)
Given a variable x, the transformC
function generates and returns a tranformed version of x. For example, transformC
can take a variable x and return standardized x, or the log of x.
transformC(type, x, data, response, cutpoints, groups, confirm = TRUE, ...)
transformC(type, x, data, response, cutpoints, groups, confirm = TRUE, ...)
type |
The type of transformation to be made to x. Options include:
|
x |
The variable to be transformed, a variable that already exists, should be in dataset$var form unless dataset specified in optional data argument. |
data |
(Optional) Name of dataset that contains x variable. |
response |
(Optional) For |
cutpoints |
(Optional) For |
groups |
(Optional) For |
confirm |
(Optional) By default, |
... |
(Optional) Additional arguments pass to |
A transformed version of x variable, a vector with the same length as x, unless type="dummy.set"
in which case transformC returns a data.frame.
Transforming Variables with RCPA3 Package's transformC Function 22:40
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 3.
Philip H. Pollock and Barry C. Edwards, The Essentials of Political Analysis, 6th Edition (Thousand Oaks, CA: Sage Publications, 2020), pp. 55-64. ISBN-13: 978-1506379616; ISBN-10: 150637961.
R Tutorials & Resources for Creating and Transforming Variables, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
Political Science Data Web Site: Find datasets for your own research and resources to help with the analysis.
library(RCPA3) # don't use confirm=FALSE until you've tested the function call transformC("percent.rank", nes$ft.dem, confirm=FALSE) transformC("rank", nes$ft.dem, confirm=FALSE) transformC("whole", runif(min=0,max=100,n=20), confirm=FALSE)
library(RCPA3) # don't use confirm=FALSE until you've tested the function call transformC("percent.rank", nes$ft.dem, confirm=FALSE) transformC("rank", nes$ft.dem, confirm=FALSE) transformC("whole", runif(min=0,max=100,n=20), confirm=FALSE)
Welcomes users to RCPA3 package for An R Companion to Political Analysis, 3rd Edition and provides basic information about using Companion functions and datasets.
welcome(reset = FALSE)
welcome(reset = FALSE)
reset |
(Optional) Do you want to remove objects from your workspace and restore default graphical parameters? Default is FALSE. Removing workspace objects and restoring default graphical parameters can help undo some unintended side-effects of past work. |
No value returned
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 1.
R Tutorials & Resources for Getting Started with R, Compiled by Barry C. Edwards
Sage Edge Resources for Political Analysis Series, for streaming videos, flashcards, and more student resources for textbooks by Pollock and Edwards, from Sage Publications.
library(RCPA3) # Welcome message from RCPA3 package. ## Not run: welcome() ## End(Not run)
library(RCPA3) # Welcome message from RCPA3 package. ## Not run: welcome() ## End(Not run)
A fun, interactive game to practice using R functions. Players must execute functions to make widgets per strict specifications to win the game. The Widget Factory needs your help!
widgetFactory()
widgetFactory()
No value returned
Complete Playlist of RCPA3 Package Tutorial Videos, includes video for this function and many more.
Philip H. Pollock and Barry C. Edwards, An R Companion to Political Analysis, 3rd Edition (Thousand Oaks, CA: Sage Publications, Forthcoming 2022), Chapter 1.
Tutorials & Resources for Using R for Data Analysis, compiled by Barry C. Edwards
library(RCPA3) # Play the Widget Factory game ## Not run: widgetFactory() ## End(Not run)
library(RCPA3) # Play the Widget Factory game ## Not run: widgetFactory() ## End(Not run)
A dataset with variables about countries in the world. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
world
world
A data frame with 169 rows and 206 variables.
Country numerical code
Prevalence of bribing judges
Prevalence of bribing police
Broadband subscription per 100 people
Number of new corporations registered annually
Three-letter abbreviation of country name
National carbon footprint
Numeric country code based on the ISO-3166-1 standard
Percent of GDP spent on education
Composition of GDP: Agricultural sector
Composition of GDP: Industrial sector
Composition of GDP: Service sector
Civil war intensity
Carbon dioxide emissions per capita
Colony of what country?
Does country require citizens to vote?
Confidence in institutions scale
Level of violent conflict in country
Number of internal conflict without foreign invention
Number of internal conflict with foreign invention
Corporate tax rate
Corruption perception index
Country/territory name
Number of attempted coups d'etat since 1950
Number of successful coups d'etat since 1950
Total COVID cases per million
Total COVID deaths per million
Maximum of COVID response stringency index
Mean of COVID response stringency index
Percentage of population fully vaccinated against COVID
Legal status of death penalty
Public debt as a percentage of GDP
Percentage of other democracies in region
Percentage of other democracies in region
Average number of members per district
Effective number of parliamentary parties
Is chief executive a military officer?
National political system
Number of years since the last regime transition
Total ecological footprint
Global economic competitiveness
Rating of overall economic freedom
Rating of overall economic freedom, 5 ordinal categories
Average Schooling Years, Female
Percentage of Females with No Schooling
Average Schooling Years, Male
Percentage of Males with No Schooling
Average rating of quality of educational system
Government effectiveness scale
Level of democracy, 4 ordinal categories
Is country a democracy?
Rating of democracy
Integrity of country's electoral system
Were there riots and protest after election?
Were there riots and protest before election?
Percentage of country's energy that is non-fossil fuel
Effective number of parliamentary parties
Effective number of parliamentary parties
Effective number of parliamentary parties
Number of environmental treaties agreed to
EU member state
Inflow of foreign direct investment (in millions of US dollars)
Number children born per woman
Rating of democracy, 3 ordinal categories
Freedom House rating of democracy
Level of Internet freedom in country, 3 ordinal categories
Measure of Internet freedom
Ethnic factionalization
Ethnic factionalization
Ethnic factionalization
Language factionalization
Religious factionalization
Gas production (in millions of barrels of oil equivalent)
Annual economic growth rate
Gross domestic product per capita (in U.S. dollars)
Gross domestic product per person, 5 ordinal categories
Gender empowerment
Index of gender inequality
GINI index (of income inequality)
Social globalization
Capacity of state to provide for needy citizens
Rating of government integrity
Government spending (all types) as a percentage of GDP
The quality of government
Index of government restrictions on religion
Name of government preferred religion
Index of government religious preference
Average happiness in country
Human development index
Percentage of population aged 15-49 with HIV
Intentional homicides per 100,000 persons
Number of hospital beds per thousand people
Human flight and brain drain from country
Has country ratified treaty for International Criminal Court?
Percentage of population born in another county
Number incarcerated per 100,000 persons
Income tax rate
Does country have an independent judiciary?
Year of independence
Number infants dying before age one per 1,000 live births
Annual inflation rate
Percentage of population that uses the Internet
Rating of effectiveness of country's judiciary
Average rating of judicial independence
Legal protections for private property rights
Legal origin of commercial code of country
Measure of quality of country's legal institutions
Life expectancy at birth
Life expectancy at birth among females
Life expectancy at birth among males
Literacy rate
Does country provide free or subsidized media access for political candidates?
Does country provide free or subsidized media access for political parties?
Median age in years
Net migration
Are Muslims predominate religious group?
Measure of health of oceans adjacent to country
OECD member state?
Oil production, in barrels per day
Oil production, in metric tons
Impact of organized crime on the economy
Peacefulness of country, 5 ordinal categories
Peacefulness of country
Post-materialism
Political terror scale
Political terror scale
Rating of democracy
Percentage of population age 0-14
Percentage of population age 15-64
Percent of population age 65 and older
Percentage population growth/decline annually
Percentage of the population living in urban areas
Size of national population
Size of national population, 3 ordinal categories
Number of people per square kilometer
Percentage of the population below the poverty line
Proportional representation system?
Freedom of the country's press
Freedom of the country's press
Protest activity
Refugees from the country who live in other countries
Impact of population displacement on country
Refugees from other countries in the country
Regime type
Region name
United Nations region
Largest religion by proportion
Does country reserve seats in national legislature for any group?
Freedom of assembly and association
Freedom of domestic movement
Freedom of foreign movement
Independence of the judiciary
Measure of violations of human right and rule of law
Freedom of Religion
Freedom of speech
Number of international human rights treaties ratified
Women's economic rights
Women's political rights
Worker's rights
Average rating of internet availability in schools
Percentage of labor force that is self-employed
Sex ratio at birth
Social hostility toward religion
Percentage of labor force in the military
Total number of people in the military
Public expenditure on education as a percentage of GDP
Public expenditure on health as a percentage of GDP
Public expenditure on the military as a percentage of GDP
Tariff rate on imports
Taxes (all forms) as a percentage of GDP
Impact of terrorism on the county
International trade as percentage of GDP
Predominant religion
Percentage of labor force that is unemployed
Public expenditure on research and development as a percentage of GDP
Ratio of female to male formal employment rates
Inequality-adjusted income index
Inequality-adjusted education index
Union density
Number of verified cases of journalists imprisoned
Adult literacy rate
Percentage covered by a mobile phone network
Number of adult female deaths per 1,000 females
Number of adult male deaths per 1,000 males
Daily newspapers per thousand people
Death rates from non-communicable diseases
Projected 2030 population in millions
Per capita remittance inflows in US dollars
Remittance inflows as a percentage of GDP
Percentage satisfied with their personal health
Overall life satisfaction
Overall life satisfaction among females
Percentage satisfied with their job
Percentage satisfied with their standard of living
Percentage with at least secondary education
Is country a democracy or autocracy?
Ordinal ranking of democracy, 4 categories
Electoral democracy index
Liberall democracy index
Percent saying religion very important
Economic cost of violence on national economy
Turnout of voting age population in 2010s
Percent women in lower house of legislature
Year women first enfranchised
Year women first enfranchised
Percentage of lower house of legislature aged 40 years or younger
Sources vary. See Appendix of printed textbook for further information.