Title: | Datasets and Functions Featured in Pollock and Edwards, an R Companion to Essentials of Political Analysis, Second Edition |
---|---|
Description: | Bundles the datasets and functions used in the textbook by Philip Pollock and Barry Edwards, an R Companion to Essentials of Political Analysis, Second Edition. |
Authors: | Barry Edwards and Philip Pollock |
Maintainer: | Barry Edwards <[email protected]> |
License: | CC0 |
Version: | 2.3.0 |
Built: | 2024-11-27 06:54:04 UTC |
Source: | CRAN |
Calculates adjusted R-Squared statistic based on user-defined inputs. This function can be used after estimating a model that does not report adjusted R-Squared statistic. For svyglm model fit statistics, see fit.svyglm
function documentation.
AdjR2(tdf, null.dev, resid.dev, k)
AdjR2(tdf, null.dev, resid.dev, k)
tdf |
The total degrees of freedom |
null.dev |
The null deviance or total sum of squares |
resid.dev |
The residual deviance or error sum of squares |
k |
The number of parameters used (to reduce deviance) |
Returns an adjusted R-Squared statistic, a numeric value between 0 and 1
AdjR2(200, 1500, 1100, 5) AdjR2(tdf=200, null.dev=1500, resid.dev=1100, k=5)
AdjR2(200, 1500, 1100, 5) AdjR2(tdf=200, null.dev=1500, resid.dev=1100, k=5)
The compmeans
function is imported from descr package.
See compmeans
documentation for details.
The crosstab
function is imported from the descr package.
See crosstab
documentation for details.
The csv.get
function is imported from the Hmisc package.
See csv.get
documentation for details.
The cut2
function is imported from the Hmisc package.
See cut2
documentation for details.
The ddply
function is imported from the plyr package.
See ddply
documentation for details.
The describe
function is imported from the Hmisc package.
See describe
documentation for details.
The freq
function is imported from the descr package.
See freq
documentation for details.
The plotmeans
function is imported from the gplots package.
See plotmeans
documentation for details.
The scatterplot
function is imported from the car package.
See scatterplot
documentation for details.
The spss.get
function is imported from the Hmisc package.
See spss.get
documentation for details.
The stata.get
function is imported from the Hmisc package.
See stata.get
documentation for details.
The svyboxplot function is imported from the survey package.
See svyhist
documentation for details.
The svyby
function is imported from the survey package.
See svyby
documentation for details.
The svychisq
function is imported from the survey package.
See svychisq
documentation for details.
The svydesign
function is imported from the survey package.
See svydesign
documentation for details.
The svyglm
function is imported from the survey package.
See svyglm
documentation for details.
The svymean function is imported from the survey package.
See surveysummary
documentation for details.
The svyplot
function is imported from the survey package.
See svyplot
documentation for details.
The svytable function is imported from the survey package.
See svychisq
documentation for details.
The wtd.chi.sq
function is imported from the weights package.
See wtd.chi.sq
documentation for details.
The wtd.cor
function is imported from the weights package.
See wtd.cor
documentation for details.
The wtd.hist
function is imported from the weights package.
See wtd.hist
documentation for details.
The wtd.mean function is imported from the Hmisc package.
See wtd.stats
documentation for details.
The wtd.quantile function is imported from the Hmisc package.
See wtd.stats
documentation for details.
The wtd.t.test
function is imported from the weights package.
See wtd.t.test
documentation for details.
The wtd.var function is imported from the Hmisc package.
See wtd.stats
documentation for details.
compmeans(...) crosstab(...) csv.get(...) cut2(...) ddply(...) describe(...) freq(...) plotmeans(...) scatterplot(...) spss.get(...) stata.get(...) svyboxplot(...) svyby(...) svychisq(...) svydesign(...) svyglm(...) svymean(...) svyplot(...) svytable(...) wtd.chi.sq(...) wtd.cor(...) wtd.hist(...) wtd.mean(...) wtd.quantile(...) wtd.t.test(...) wtd.var(...)
compmeans(...) crosstab(...) csv.get(...) cut2(...) ddply(...) describe(...) freq(...) plotmeans(...) scatterplot(...) spss.get(...) stata.get(...) svyboxplot(...) svyby(...) svychisq(...) svydesign(...) svyglm(...) svymean(...) svyplot(...) svytable(...) wtd.chi.sq(...) wtd.cor(...) wtd.hist(...) wtd.mean(...) wtd.quantile(...) wtd.t.test(...) wtd.var(...)
... |
See source package help file for details on function usage. |
Prints the lower and upper boundaries of a 95 Percent confidence interval. Also see the CI95 function.
CI95(m, se)
CI95(m, se)
m |
A single number equal to the mean value of a statistic. |
se |
single number equal to the standard error of the statistic. |
Returns the 95
CI95(10, 1) CI95(m=8, se=2)
CI95(10, 1) CI95(m=8, se=2)
Prints the lower and upper boundaries of a 99 Percent confidence interval. Also see the CI95 function.
CI99(m, se)
CI99(m, se)
m |
A single number equal to the mean value of a statistic. |
se |
single number equal to the standard error of the statistic. |
Returns the 99
CI99(10, 1) CI99(m=8, se=2)
CI99(10, 1) CI99(m=8, se=2)
Produces plot of colors available in R. Colored cells labels with numeric value that corresponds to that color. No values supplied to function.
Colors()
Colors()
No value returned
Colors()
Colors()
Generates column percentaged tables for multi-dimensional controlled cross-tabulations, based on function by John Fox. Used by xtabC
function.
colPercents(tab, digits = 2)
colPercents(tab, digits = 2)
tab |
A table of values |
digits |
Number of decimal places to display, default is 2. |
Table of column-percentaged values
This function is called by tablesomersDC
function.
compADPQ(x)
compADPQ(x)
x |
A matrix or data frame |
Returns a list of statistics
Calculates Cramer's V, a measure of association to gauge the strength of the relationship between two nominal-level variables. A score of 0 indicates no relationship; a score of 1 indicates a perfect relationship.
CramersV(chi, r, c, n)
CramersV(chi, r, c, n)
chi |
A number equal to the Chi-Squared statistic |
r |
A number equal to the number of rows |
c |
A number equal to the number of columns |
n |
A number equal to the sample size |
The Cramer's V statistic, a number between 0 and 1.
CramersV(84.18, 2, 2, 1315) CramersV(chi=84.18, r=2, c=2, n=1315)
CramersV(84.18, 2, 2, 1315) CramersV(chi=84.18, r=2, c=2, n=1315)
Model fit statistics for a svyglm weighted regression model
fit.svyglm(svyglm, digits = 3)
fit.svyglm(svyglm, digits = 3)
svyglm |
An object of type svyglm. This object is the output of the svyglm functon. |
digits |
Number of digits to report after decimal place, optional (default = 3). |
Returns a numeric vector of R-Squared and Adjusted R-sSquared statistics.
library(poliscidata) obamaThermModel <- svyglm(obama_therm ~ gender, design=nesD, na.action="na.omit") summary(obamaThermModel) fit.svyglm(obamaThermModel)
library(poliscidata) obamaThermModel <- svyglm(obama_therm ~ gender, design=nesD, na.action="na.omit") summary(obamaThermModel) fit.svyglm(obamaThermModel)
Generates frequency distribution table and bar chart to describe distribution of variable values. Based on freq
function in descr package.
freqC(x, w, plot = TRUE)
freqC(x, w, plot = TRUE)
x |
A vector of variable values, should be in form dataset$var |
w |
Sample weights (optional), should be in form dataset$weighvar |
plot |
Do you want a bar chart? (default set to TRUE) |
A frequency distribution table (a "freqtable" and "matrix" class object)
library(poliscidata) freqC(gss$zodiac, gss$wtss) freqC(x=gss$zodiac, w=gss$wtss)
library(poliscidata) freqC(gss$zodiac, gss$wtss) freqC(x=gss$zodiac, w=gss$wtss)
The General Social Survey polls individuals about their attitudes and beliefs. This dataset is used to demonstrate application of R to political analysis. See book Appendix for variable names and descriptions.
gss
gss
A data frame with 1974 rows and 221 variables.
Abortion Permissible: Woman Wants For Any Reason
Abortion Permissible: Strong Chance of Serious Defect
Abortion Permissible: Woman's Health Seriously Endangered
Abortion Permissible: Woman Married–Wants No More Children
Under How Many Conditions Abortion Permissible?
Under How Many Conditions Abortion Permissible? 3 Categories
Abortion Permissible: Low Income–Can't Afford More Children
Abortion Permissible: Pregnant As Result of Rape
Abortion Permissible: Not Married
Favor Preference in Hiring Blacks
Support Affirmative Action?
Respondent's Age
Respondent's Age (as ordered factor)
Respondent's Age: 2 Categories
Age Group: 3 Categories
Age Group: 5 Categories
How Often Respondent Attends Religious Services
Attendance at Religious Services: Low or High
Attendance at Religious Services: 3 Categories
Attendance at Religious Services: 7 Categories
Authoritarianism Scale
Feelings About the Bible
Is Respondent African American?
Black Stereotypes
Was Respondent Born in This Country
Favor or Oppose Death Penalty For Murder
Number of Children
How Close Do You Feel to Blacks?
How Close to Blacks? 2 Categories
How Close Feel to Whites
How Close Do You Feel to Whites? 2 Categories
Year of Birth
College Teaching: Allow Anti-Religionist to Teach
College Teaching: Should Communist Teacher Be Fired
College Teaching: Allow Homosexual to Teach
College Teaching: Allow Militarist to Teach
College Teaching: Allow Anti-American Muslim Clergymen to Teach
College Teaching: Allow Racist to Teach
Confidence in Government Institutions
Confidence in Military
Confidence in Major Companies
Confidence in Organized Religion
Confidence in Education
Confidence in Exec Branch of Fed Government
Confidence in Banks & Financial Institutions
Confidence in United States Supreme Court
Confidence in Organized Labor
Confidence in Congress
Confidence in Medicine
Confidence in Press
Confidence in Scientific Community
Confidence in Television
Courts Dealing With Criminals
Date of Interview
Respondent's Highest Degree
Is Respondent a Democrat?
Divorce Laws
Should divorce laws make it more difficult?
Highest Year of School
Education: 2 Categories
Education: 4 Categories
Egalitarianism Scale
Egalitarianism: 3 Categories
Egalitarianism: 4 Categories
Should Government Reduce Income Differences?
Country of Family Origin
Evangelical Scale
Female Roles: Mother Working Doesn't Hurt Children
Amount of Fees Paid (to Respondent for Interview)
Fee Given to Get Case (for the Interview)
Female Roles: Better For Man to Work, Woman Tend Home
Female Role (Scale of Values)
Female Role: 2 Categories
Female Roles: Preschool Kids Suffer If Mother Works
Is Respondent Planning/Applying For US Citizenship?
How Fundamentalist Is Respondent Currently?
Is Respondent Fundamentalist?
Opinion of How People Get Ahead
Know God Exists?
Should Marijuana Be Made Legal?
Should Marijuana Be Made Legal? (numeric)
Favor or Oppose Gun Permits?
General Happiness
Should Government Aid Blacks?
Should Government Do More or Less?
To Help Others
Should Government Improve Standard of Living?
Should Government Help Pay For Medical Care?
Household Type (Condensed)
Hispanic Specified
Is Respondent Hispanic?
Homosexual Sex Relations
Homosexuality Always Wrong?
Respondent Id Number
Total Family Income
Interest in Current Issues? (Additive index)
Interviewer: Age of Interviewer
Interested in Economic Issues?
Interested in Local School Issues?
Interested in Environmental Issues?
Interviewer: Race of Interviewer
Interviewer: Interviewer's Race
Interested in Farm Issues?
Interviewer: Is Interviewer Spanish, Hispanic or Latino
Interested in International Issues?
Interested in Medical Discoveries?
Interested in Military Policy?
Interviewer: Interviewer's Race1
Interviewer: Interviewer's Race2
Interviewer: Interviewer's Race3
Interested in New Scientific Discoveries?
Interviewer: Sex of Interviewer
Interested in Space Exploration?
Interested in Technologies?
Interviewer: Years of Service as an Interviewer at NORC
Does Respondent Have Kids?
Allow Anti-Religious Book in Library?
Allow Communists Book in Library?
Allow Homosexuals Book in Library?
Allow Militarists Book in Library?
Allow Anti-American Muslim Clergymen's Books in Library?
Allow Racists Book in Library?
How Long Was Interview
Marital Status
Tolerance Toward Militarists
Geographic Mobility Since Age 16
Interview Done In-Person or Over the Phone
Muslims: Teach in College?
Muslims: Book in Library?
Muslims: Preach?
Muslims: Preach? (as numeric)
Muslims: Preach? (as numeric)
Federal spending: Foreign Aid
Federal spending: Military, Armaments, and Defense
Federal spending: Assistance for Childcare
Federal spending: Solving Problems of Big Cities
Federal spending: Halting Rising Crime Rate
Federal spending: Dealing with Drug Addiction
Federal spending: Improving Nations Education System
Federal spending: Developing Alternative Energy Sources
Federal spending: Improving & Protecting Environment
Federal spending: Welfare
Federal spending: Improving & Protecting Nations Health
Federal spending: Mass Transportation
Federal spending: Parks and Recreation
Federal spending: Improving the Conditions of Blacks
Federal spending: Highways and Bridges
Federal spending: Supporting Scientific Research
Federal spending: Social Security
Federal spending: Space Exploration Program
How Often Does Respondent Read Newspaper
To Obey
Obedience Important in Children?
Have Gun in Home
Political Party Affiliation
Party Id: 3 Categories
Ideological Self-Placement
Important for Child: To Be Well Liked or Popular
Feelings About Pornography Laws
Pornography opinion
Belief in Life After Death
How Often Does Respondent Pray
Sex Before Marriage
Vote Obama or Mccain
Differences Due to Discrimination
Differences Due to Inborn Disability
Differences Due to Lack of Education
Differences Due to Lack of Will
Race of Respondent
Race: Black / White
Racial Liberalism
Born Again?
Region of Interview
Respondent's Religious Preference
Respondent's Religious Preference, limited to Catholic and Protestant
Strength of Affiliation
Strong Religious Affiliation
Respondent Income
Respondent Income: 5 Categories
Tried to Convince Others of Jesus?
Number Correct on Science Quiz
Number Correct on Science Quiz, stored as factor
Respondent's Sex
Number of Brothers and Sisters
Size of Place in 1000s
Social Connectedness
Social Conservatism
Social Trust (Numeric Scale)
Respondent from South?
Favor Spanking to Discipline Child?
Approve of spanking
Econ Liberalism
Allow Speaker in Your Community: Anti-Religionist
Allow Speaker in Your Community: Communist
Allow Speaker in Your Community: Homosexual
Allow Speaker in Your Community: Militarist
Allow Speaker in Your Community: Muslim Clergymen Preaching Hatred
Allow Speaker in Your Community: Allow Racist to Speak
Sex Before Marriage – Teens 14-16
Important for Child: To Think For One's Self
Tolerance Scale
Tolerance Scale (Binned)
Hours Per Day Watching TV
Hours per day
Does Respondent or Spouse Belong to Union
Is Respondent US Citizen
Years in Armed Forces
Did Respondent Vote in 2008 Election
Did Respondent Vote in 2008?
White Stereotypes
Number Words Correct in Vocabulary Test
To Work Hard
Respondent Work for Government or Private Employee
Respondent Self-Emp or Works For Somebody
Labor Force Status
Irish, Italian, Jewish and other Should Overcome Prejudice Without Favors
Weight Variable
Weight Variable (same as wtss)
Sex With Person Other Than Spouse
GSS Year For This Respondent
Respondent's Astrological Sign
2012 General Social Survey. See Appendix Table A.1 of printed textbook for further information
The General Social Survey polls individuals about their attitudes and beliefs. This design dataset is used to demonstrate application of certain R functions to political analysis. See gss
dataset documentation for variable names and descriptions.
gssD
gssD
A design dataset version of the gss dataset used for certain weighted analyses. The variables element has 1974 observations of 221 variables.
2012 General Social Survey. See Appendix Table A.1 of printed textbook for further information
Produces a controlled mean comparison table. Rows defined by values of independent variable and columns defines by values of the control variable.
imeansC(function1 = NULL, function2 = NULL, data, digits = 2)
imeansC(function1 = NULL, function2 = NULL, data, digits = 2)
function1 |
A function identifying the dependent variable in the form ~ depvar |
function2 |
A function specifying the independent and control variables in the form ~ indepvar + controlvar |
data |
A design dataset (like gssD, nesD, statesD, or worldD) |
digits |
Number of digits to report after decimal place, optional (default = 2). |
A controlled mean comparison table (an "ftable" class object)
library(poliscidata) imeansC(function1 = ~ft_dem, function2 = ~gender + married, data=nesD) imeansC(~ft_dem, ~gender + married, nesD)
library(poliscidata) imeansC(function1 = ~ft_dem, function2 = ~gender + married, data=nesD) imeansC(~ft_dem, ~gender + married, nesD)
This function calculates predicted probability for a given logged odds value, often useful for plotting or reporting predicted probabilities.
inverse.logit(logged_odds)
inverse.logit(logged_odds)
logged_odds |
A numeric value, or vector of numeric values. |
Returns predicted probability corresponding the the logged odds value, a numeric value between 0 and 1.
inverse.logit(0) inverse.logit(-5:5)
inverse.logit(0) inverse.logit(-5:5)
Interaction plot uses brkdn.plot
in plotrix package and svyby
function from survey package. Warnings suppressed so the function creates plot without generating intermediate results used to create plot.
iplotC(function1 = NULL, function2 = NULL, data, function3 = NULL, ...)
iplotC(function1 = NULL, function2 = NULL, data, function3 = NULL, ...)
function1 |
A function in the form ~depvar |
function2 |
A function. Here indepvar is typed before controlvar: ~indepvar + controlvar |
data |
Design dataset (e.g. nesD, gssD, statesD, or worldD) |
function3 |
A function. Here indepvar is typed after controlvar: ~controlvar + indepvar |
... |
Further arguments to be passed to |
No value returned
library(poliscidata) iplotC(function1 = ~ ft_dem, function2 = ~ gender + married, data = nesD, function3 = ft_dem ~ married + gender) iplotC(~ft_dem, ~gender+married, nesD, ft_dem~married+gender, xlab="Gender", ylab="Democratic Party Rating", main="Democratic Party Rating by Gender and Marital Status")
library(poliscidata) iplotC(function1 = ~ ft_dem, function2 = ~ gender + married, data = nesD, function3 = ft_dem ~ married + gender) iplotC(~ft_dem, ~gender+married, nesD, ft_dem~married+gender, xlab="Gender", ylab="Democratic Party Rating", main="Democratic Party Rating by Gender and Marital Status")
Displays line types for R plots. No values supplied to function.
lineType()
lineType()
No value returned
lineType()
lineType()
Logistic regression model statistics
logregR2(model, digits = 3)
logregR2(model, digits = 3)
model |
An estimated logistic regression model |
digits |
Number of digits to be displayed after decimal points |
Returns list of statistics about model (a "LogRegR2" class object)
library(poliscidata) obama_state_model <- glm(obama_win12 ~ secularism + gunlaw_rank, data=states, family=binomial) summary(obama_state_model) logregR2(obama_state_model) obama_vote_model <- svyglm(obama_vote ~ ft_dem, design=nesD, family="quasibinomial") summary(obama_vote_model) logregR2(obama_vote_model)
library(poliscidata) obama_state_model <- glm(obama_win12 ~ secularism + gunlaw_rank, data=states, family=binomial) summary(obama_state_model) logregR2(obama_state_model) obama_vote_model <- svyglm(obama_vote ~ ft_dem, design=nesD, family="quasibinomial") summary(obama_vote_model) logregR2(obama_vote_model)
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 5916 rows and 399 variables.
Anti-abortion Scale
Abortion Opinion: Self-Placement, 4 Categories
Abortion Opinion: Self-Placement, 4 Categories
Support for Government assistance to blacks scale, 7 point scale
Child trait more important: considerate or well-behaved
Child trait more important: curiosity or good manners
Child trait more important: independence or respect
Child trait more important: obedience or self-reliance
Authoritarianism (4 point scale based on child trait questions)
Is Respondent Black?
Favor reducing the Federal budget deficit, 7 point scale
Case ID
Does Respondent have a dog (Interview set-up test)
Does Respondent have a dog (Interview set-up test)
Number of opinions Respondent has compared to average person
Approval of Congress
Strength of approve/disapprove Congress handling its job
ftgr_cons minus ftgr_liberals
Close to any political party?
Campaign mobilization: institutional contact
Campaign mobilization: institutional contact - email
Campaign mobilization: institutional contact - in person
Respondent contacted by party/candidate?
Support for government action income inequality (5 point scale)
Government action on income inequality (3 point scale)
Campaign mobilization: institutional contact - by mail
Campaign mobilization: sign up online information or alerts
Campaign mobilization: personal contact - email
Campaign mobilization: personal contact - in person
Campaign mobilization: personal contact - by mail
Campaign mobilization: personal contact - by phone
Campaign mobilization: personal contact - text message
Campaign mobilization: personal contact
Campaign mobilization: personal contact - social network
Campaign mobilization: institutional contact - by phone
Political information - Secretary of the U.N.
Political information - Secretary of the Treasury
Political information - party 2nd in House seats won
Pol info scale
Political information - unemployment rate
Political information - date used for date of unemployment rate
Political information - number used for unemployment rate
Econ conservatism (numeric scale)
Death Penalty Opinion
Support for defense spending, 7 point scale
Party identification: Does Respondent self-identify as Democrat? (coded 0/1)
Demographic: Age Groups
Demographic: Age group
Demographic: Six Age Groups
Demographic: Respondent age on interview date (age group)
Demographic: Education
Demographic: Respondent level of highest education
Demographic: Is Respondent Spanish, Hispanic, or Latino
Demographic: Marital status
Demographic: Native status of parents
Demographic: Race self-identification: mention Black
Demographic: Race self-identification with don't know or refused to say
Demographic: Race self-identification: mention White
Demographic: Respondent race and ethnicity group
Demographic: White/Black
Demographic: Respondent race and ethnicity group
Demographic: Anyone in household belong to labor union
Demographic: Respondent ever served on active duty in Armed Forces
Demographic: Total Number of children in household
Demographic: Does Respondent family own/rent home
Demographic: How many years has Respondent lived in this community?
Homeland security: Approve/disapprove of efforts to reduce terrorism
Homeland security: Likely terrorist attack kill 100/more in next year?
Homeland security: Is fed. gov't a threat to rights and freedoms? (numeric scale)
Homeland security: Is fed. gov't a threat to rights and freedoms?
Homeland security: Favor/Oppose torture for suspected terrorists
Civic engagement: Has Respondent in past 4 years: attended city/school board meeting
Civic engagement: Has Respondent in past 4 years: called radio/TV about political issue
Civic engagement: Contact U.S. Representative or Senator
Civic engagement: written a letter to newspaper/magazine about political issue
Civic engagement: Has Respondent joined a protest march
Civic engagement: sent Facebook/Twitter message about political issue
Civic engagement: Has Respondent in past 4 years: sign internet petition
Civic engagement: Has Respondent in past 4 years: gave money to social/political organization
Civic engagement: Has Respondent signed paper petition
Civic engagement: Has Respondent in past 4 years: given money to religious organization
Discrimination: Amount against Blacks
Discrimination: Against Blacks? (yes/no)
Discrimination: Amount against Gays and Lesbians?
Discrimination: Against gays? (yes/no)
Discrimination: Amount against Hispanics
Discrimination: Against Hispanics? (yes/no)
Discrimination: How much discrimination against blacks, gays, Hispanics, women? (Sum of yes answers)
Discrimination: How much discrimination faced personally?
Discrimination: Amount against Whites
Discrimination: Amount against Women
Discrimination: Against women? (yes/no)
Ever discuss politics with family or friends
Days in past week discussed politics
Economy: How much is former President to blame for poor economy?
Economy: How much is President to blame for poor economy?
Economy: U.S. economy better or worse 1 year from now
Economy: How much better/worse next 12 months
Economy: Currently good or bad
Economy: Better/worse in last year
Economy: Better or worse than 1 year ago
Economy: How much better/worse in last year
Economy: How much unemployment better/worse in last year
Economy: More/less unemployment in next year
Economy: Unemployment better/worse in last year
Economy: Unemployment better/worse than 1 year ago
Economy: Better/worse if Democratic Presidential candidate wins
Economy: Better/worse if Republican Presidential candidate wins
How do you pay for your home?
Political efficacy: Public officials don't care what people think
Political efficacy: Public officials don't care what people think
Political efficacy: Politics/government too complicated to understand
Political efficacy: Politics/government too complicated to understand
Political efficacy: External political efficacy (numeric scale)
Political efficacy: External political efficacy (3 categories)
Political efficacy: Internal political efficacy (numeric scale)
Political efficacy: Internal political efficacy (3 categories)
Political efficacy: Have no say about what government does
Political efficacy: Have no say about what government does
Political efficacy: Good understanding of political issues
Political efficacy: Good understanding of political issues
Political efficacy: How often see both disagreeing parties as right
Equality: It's a big problem that we don't give equal chance to succeed
Equality: Society should make sure everyone has equal opportunity
Equality: If people were treated more fairly would be fewer problems
Equality: Not a big problem if some have more chance in life
Equality: Egalitarianism (numeric scale)
Equality: Egalitarianism: 3 categories
Equality: We have gone too far pushing equal rights
Equality: We'd be better off if worried less about equality
Environment: Environment more important response (on envjob_3) as 0/100
Environment: Favor/oppose increased U.S. offshore drilling
Environment: Is global warming happening or not
Environment: Rising temperatures good or bad
Environment: Anthropogenic climate change
Environment: Should US have more/fewer nuclear power plants
Environment: Environment more important response (on envjob_3) as 0/100
Environment: Environment or jobs more important?
Environment: 7 point scale environment-jobs tradeoff
Opinion about government ensuring fair jobs for blacks
Federal budget increase/decrease: child care
Federal budget increase/decrease: child care (rev. scale)
Federal budget increase/decrease: crime control
Federal budget increase/decrease: crime control (rev. scale)
Federal budget increase/decrease: protecting environment
Federal budget increase/decrease: protecting environment (rev. scale)
Federal budget increase/decrease: aid to the poor
Federal budget increase/decrease: aid to the poor (rev. scale)
Federal Spending Scale (numeric scale, sum of increase responses)
Federal budget increase/decrease: public schools
Federal budget increase/decrease: public schools (rev. scale)
Federal budget increase/decrease: science and technology
Federal budget increase/decrease: science and technology (rev. scale)
Federal budget increase/decrease: Social Security
Federal budget increase/decrease: Social Security (rev. scale)
Federal budget increase/decrease: welfare programs
Federal budget increase/decrease: welfare programs (rev. scale)
Feeling about feminists (recode of ftgr_feminists into 3 categories)
Financial situation: Respondent living with how many family members
Financial situation: Better or worse off 1 year from now
Financial situation: Better or worse off than 1 year ago
Feeling Thermometer: Democratic Party
Feeling Thermometer: Democratic Presidential candidate
Feeling Thermometer: Democratic Vice-Presidential candidate
Feeling Thermometer: G.W. Bush
Feeling Thermometer: Hillary Clinton
Feeling Thermometer: Republican Party
Feeling Thermometer: Republican Presidential candidate
Feeling Thermometer: Republican Vice-Pres candidate
Feeling thermometer: Asian-Americans
Feeling thermometer: Blacks
Feeling thermometer: Hispanics
Feeling thermometer: Illegal Immigrants
Feeling thermometer: Whites
Was Respondent a 2012 Time Series Oversample Case?
Feeling thermometer: Atheists
Feeling thermometer: Big Business
Feeling thermometer: Catholics
Feeling thermometer: Congress
Feeling thermometer: Conservatives
Feeling thermometer: Federal Government
Feeling thermometer: Feminists (3 categories)
Feeling thermometer: Feminists
Feeling thermometer: Gay Men and Lesbians
Feeling thermometer: Liberals
Feeling thermometer: Middle Class People
Feeling thermometer: The Military
Feeling thermometer: Mormons
Feeling thermometer: Muslims
Feeling thermometer: Poor People
Feeling thermometer: Rich People
Feeling thermometer: Tea Party
Feeling thermometer: Labor Unions
Feeling thermometer: The U.S. Supreme Court
Feeling thermometer: People on Welfare
Feeling thermometer: Working Class People
Feeling thermometer: Christian Fundamentalists
Feeling thermometer: Christians
Feeling thermometer: Spouse of Democratic Presidential candidate
Feeling thermometer: Democratic Vice Presidential candidate
Feeling thermometer: House Democratic Candidate
Feeling thermometer: House Independent/3rd-party Candidate
Feeling thermometer: House Republican Candidate
Feeling thermometer: Democratic Presidential candidate
Feeling thermometer: John Roberts
Feeling thermometer: Republican Presidential candidate
Feeling thermometer: Spouse of Republican Presidential candidate
Feeling thermometer: Republican Vice Presidential candidate
Feeling thermometer: Senate Democratic Candidate
Feeling thermometer: Jr. Senator in State Without Race
Feeling thermometer: Non-running Senator in State W/Race
Feeling thermometer: Sr. Senator in State Without Race
Feeling thermometer: Senate Independent/3rd-party Candidate
Feeling thermometer: Senate Republican Candidate
Gay rights: gayrt_adopt==1. Yes
Gay rights: gayrt_discstd_x==1. Approve strongly
Gay rights: Approve same-sex marriage?
Gay rights: gayrt_milstd_x==1. Feel strongly that homosexuals should be allowed to serve
Gay rights: Gay Rights Support (3 categories)
Gay rights: Should gay and lesbian couples be allowed to adopt?
Gay rights: favor laws against gays/lesbians job discrimination (rev.)
Gay rights: favor laws against gays/lesbians job discrimination
Gay rights: Respondent position on gay marriage
Gay rights: allow gays/lesbians serve in US armed forces (reversed)
Gay rights: allow gays/lesbians serve in US armed forces
Respondent's Gender
Pro-government scale (numeric scale)
Should gov't guarantee a job and standard of living? (7 point scale)
Gun control: Should federal gov't make it more difficult to buy a gun?
Gun control: Make it more difficult to buy a gun?
Gun control: Importance of gun access issue to R
Gun control: How important is gun issue?
How satisfied is Respondent with life?
Health care: Support 2010 health care law
Health care: Does Respondent have health insurance
Health care: Health of Respondent
Health care: Smoked Cigarettes
Health care: If smoked, how many now
Is Respondent Hispanic?
Health care: Health Care Law effect on number insured
Health care: Health Care Law effect on health care services
Congress: Approve or disapprove of House incumbent
Congress: House incumbent approval
Congress: How much approve House incumbent
Congress: How much disapprove House incumbent
Congress: How good a job does House incumbent do in district
Immigration: Opinion on immigration status checks on suspects
Immigration: Opinion on allowing citizenship to some illegal aliens
Immigration: U.S. government policy toward unauthorized immigrants
Immigration: How likely immigration will take away jobs
Immigration: What should immigration levels be
Favor or oppose limits on foreign imports
Respondent's family income
Respondent's family income
Respondent's income quintile
Indifference scale
Income gap size compared to 20 years ago
Is increased income inequality in U.S. good?
Does Respondent favor/oppose government reducing income inequality?
Health care: Should care be insured by government or by private medical insurance? (7 point scale)
Involvement in politics: Contact congress?
Involvement in politics: post political message?
Involvement in politics: Number of group memberships
Involvement in politics: Give money to political organization?
Involvement in politics: Sign net petition?
Involvement in politics: Has Respondent done any volunteer work in past 12 months?
Is U.S. too supportive of Israel or not supportive enough
Political knowledge: Know party with most members in House?
Political knowledge: Know party with most members in Senate?
Respondent's Political Ideology (3 categories)
Respondent's Political Ideology (7 point scale)
Ideological placement of Democrats (7 point scale)
Ideological placement of Republicans (7 point scale)
Ideological placement of Republican Pres. Candidate (7 point scale)
Respondent's Political Ideology (7 point scale)
Respondent's Political Ideology (7 point scale)
Linked fate: blacks
Linked fate: Hispanics
Linked fate: other people
Linked fate: whites
Linked fate: women
Demographic: Is Respondent married?
Campaign mobilization: Respondent contacted by Party, Candidates, GOTV (numeric scale)
Mode of interview (face-to-face or internet)
Sex discrimination: How much job discrimination against women
Sex discrimination: Discrimination against women
Sex discrimination: How much attention media should pay to discrimination against women
Sex discrimination: Opportunities compared for women and men
Sex discrimination: Do women complaining about discrimination cause more problems
Sex discrimination: Modern sexism
Sex discrimination: Do women demanding equality seek special favors
Sex discrimination: How much more opportunities do women have
Mormon a Christian religion?
Sampling weights: Weight variable
Sampling weights: Weight variable (rounded)
Obama Rating
Respondent vote for Obama?
Sexual orientation of family and friends
Respondent's sexual orientation
Does Respondent own a dog?
Does Respondent own a gun
Patriotism: Important being American
Patriotism: Emotion seeing flag fly
Patriotism: Love of country
Patriotism scale
Strength Respondent favors/opposes death penalty
Respondent favor/oppose death penalty
Favor death penalty?
Party Identification, 3 categories
Party Identification, 7 categories
Political knowledge: Number political facts correct
Political knowledge, 3 categories
Did Respondent vote for President
For whom did Respondent vote for President
Did Respondent vote in the November general election
Did Respondent vote for U.S. House of Representatives
Should marijuana be legal?
Legalize marijuana?
Political knowledge: Program that federal gov't spends the least on
Political knowledge: What is Medicare
Political knowledge: Number of times president can be elected
Political knowledge: Years Senator Elected
Political knowledge: Size of federal deficit
Political knowledge, 3 categories
Presidential approval: Handling of economy (Recode of presapp_econ)
Respondent's vote in 2012 presidential election
Presidential approval: Handling of economy
Presidential approval: Handling of foreign relations
Presidential approval: Handling of foreign relations
Presidential approval: Handling of health care
Presidential approval: Handling of job
Presidential approval scale
Presidential approval: Handling of war in Afghanistan
Respondent's vote in 2012 presidential election
Respondent's vote in 2012 presidential election
Care who wins Presidential Election
Does Respondent consider voting as duty/choice
Did Respondent vote in the Presidential primary or caucus
Which candidate did Respondent vote for in Pres. primary or caucus
Abortion: Pro-choice Scale
Religion: Catholic, other Christian, other, or not religious?
Religion: Attend services
Religion: Attend services
Religion: Does Christian Respondent consider self born-again?
Religion: Provides guidance in day-to-day living
Religion: Important to Respondent?
Religion: Important to Respondent?
Religion: Important part of Respondent's life
Religion: How often does Respondent pray
Religion: Is Bible word of God or men
Black community: Agree/disagree blacks have gotten less than deserve
Black community: Racial conservatism scale
Black community: Agree/disagree past slavery make life more difficult
Black community: Agree/disagree blacks must try harder to get ahead
Black community: Agree/disagree that blacks should work way up without special favors
Did Respondent vote in November general election?
Respondent's Congressional district (in 113th U.S. Congress)
Sample strata: Primary sampling unit for face-to-face cases
State of Respondent address
How often should gov't use scientific methods to solve problems?
Should the Supreme Court be done away with?
Should it be possible to remove Supreme Court justices?
Respondent from South?
Support for government services/spending (7 point scale)
Sample strata for face-to-face sample component
Sample strata for full sample
Favor the TARP program?
Tea Party support
Traditional values: Agree/disagree world is changing we should adjust
Traditional values: Agree/disagree that more emphasis needed on traditional family values
Traditional values: Agree/disagree are newer lifestyles are breaking down society
Traditional values: Agree/disagree that one should be more tolerant of other moral standards
Traditional values: Moral traditionalism scale
Trust: How often can people be trusted?
Trust: Is government run by a few big interests or for benefit of all?
Trust: How many in government are corrupt?
Trust: How often trust gov't in Wash to do what is right? (reversed)
Trust: How often trust government in Wash to do what is right?
Trust: Does government waste much tax money?
Trust: How many in government are crooked?
International relations: Country better off if we just stayed home
International relations: During last year, U.S. position in world is weaker/stronger/same?
ANES 2012 Time Series Release Version
Did Respondent vote for President in 2008? (Recode of interest_voted2008)
Did Respondent vote in 2012?
Voter type (non, new, voter)
Post-stratified weight for face-to-face cases, preliminary
Post-stratified weight for full sample, preliminary release
Post-stratified weight for web cases, preliminary release
Is Respondent white?
Wiretaps: Favor or oppose authority to wiretap terrorism suspects?
Wiretaps: Has government power gone too far?
Working women: Harder to establish bond with child?
Working women: Women's role (numeric scale)
Working women: Women's role at home or work?
Working women: Better if man works and woman takes care of home and family?
How good/bad to have woman president in next 20 years?
Sampling weight
ANES year
2012 American National Election Survey. See Appendix Table A.2 of printed textbook for further information
The American National Election Survey polls individuals about their political beliefs and behavior. This design dataset is used to demonstrate application of certain R functions to political analysis. See nes
dataset documentation for variable names and descriptions.
nesD
nesD
A design dataset version of the nes dataset used for certain weighted analyses. The variables element has 5916 observations of 399 variables.
2012 American National Election Survey. See Appendix Table A.2 of printed textbook for further information
Generates odds-ratios based on logistic regression model coefficients
orci(model, digits = 3)
orci(model, digits = 3)
model |
An estimated logistic regression model |
digits |
Number of digits after decimal to display |
Returns odds rations and confidence intervals in columns (a matrix class object)
library(poliscidata) obama_state_model <- glm(obama_win12 ~ secularism + gunlaw_rank, data=states, family=binomial) summary(obama_state_model) orci(obama_state_model) obama_vote_model <- svyglm(obama_vote ~ ft_dem, design=nesD, family="quasibinomial") summary(obama_vote_model) orci(obama_vote_model)
library(poliscidata) obama_state_model <- glm(obama_win12 ~ secularism + gunlaw_rank, data=states, family=binomial) summary(obama_state_model) orci(obama_state_model) obama_vote_model <- svyglm(obama_vote ~ ft_dem, design=nesD, family="quasibinomial") summary(obama_vote_model) orci(obama_vote_model)
Comparing Logistic Regression Models with Chi-Squared Test
pchisqC(reduced, full, digits = 3)
pchisqC(reduced, full, digits = 3)
reduced |
The reduced logisitic regression model as an object. This is model with fewer independent variables. |
full |
The full logisitic regression model as an object. This is model with more independent variables. |
digits |
The number of digits to display after decimal point, default is 3. |
The chi-squared statistic, df, and p-value as a vector of numbers to test null hypothesis that full model no better than reduced model.
library(poliscidata) obama_vote_model_reduced <- svyglm(obama_vote ~ ft_dem + white, design=nesD, family="quasibinomial") obama_vote_model_full <- svyglm(obama_vote ~ ft_dem + white + (owngun_owngun=="1. Yes"), design=nesD, family="quasibinomial") pchisqC(obama_vote_model_reduced, obama_vote_model_full)
library(poliscidata) obama_vote_model_reduced <- svyglm(obama_vote ~ ft_dem + white, design=nesD, family="quasibinomial") obama_vote_model_full <- svyglm(obama_vote ~ ft_dem + white + (owngun_owngun=="1. Yes"), design=nesD, family="quasibinomial") pchisqC(obama_vote_model_reduced, obama_vote_model_full)
Displays plotting characters available in R. No values supplied to function.
plotChar()
plotChar()
No return
plotChar()
plotChar()
Plots the mean values of a dependent variable at different values of nominal or ordinal independent variable. Makes use of survey package's svy
plotmeansC(data, function1 = NULL, function2 = NULL, function3, w = 1, ...)
plotmeansC(data, function1 = NULL, function2 = NULL, function3, w = 1, ...)
data |
A dataset (e.g. gss, nes, states, or world) or design dataset (e.g. gssD, nesD, statesD, or worldD) |
function1 |
A function in the form of ~ depvar |
function2 |
A formula in the form of ~ indepvar |
function3 |
A formula in the form of depvar ~ indepvar |
w |
Weights, in the form ~ weightvar (optional, not needed if you use a design dataset) |
... |
Additonal arguments passed to gplots package's |
No return
library(poliscidata) plotmeansC(nesD, ~ft_hclinton, ~pid_x, ft_hclinton~pid_x, xlab="Party Identification", ylab="Ratings of Hillary Clinton", main="Ratings of Hillary Clinton by Party Identification") plotmeansC(nes,~envir,~pid_3,envir~pid_3,w=~wt, xlab="Party Identification", ylab="Percent Pro-Environment", main="Percentage Favoring Environment over Jobs,\n by Party ID")
library(poliscidata) plotmeansC(nesD, ~ft_hclinton, ~pid_x, ft_hclinton~pid_x, xlab="Party Identification", ylab="Ratings of Hillary Clinton", main="Ratings of Hillary Clinton by Party Identification") plotmeansC(nes,~envir,~pid_3,envir~pid_3,w=~wt, xlab="Party Identification", ylab="Percent Pro-Environment", main="Percentage Favoring Environment over Jobs,\n by Party ID")
Prints html-ready table to local working directory. Makes use of xtable package's print.xtable
function. See pp. 22 of An R Companion to Political Analysis for example and more information.
printC(objx)
printC(objx)
objx |
A table or data frame |
No return
Difference of proportions test with optional sample weights. Reports P-value of two-tailed significance test.
prop.testC(y, x, w = NULL, digits = 3)
prop.testC(y, x, w = NULL, digits = 3)
y |
Dependent variable, should be coded as 0 or 1. |
x |
Independent variable, should have only two unique values. |
w |
Weights, optional. |
digits |
Number of digits to report after decimal place, optional (default = 3). |
No return
library(poliscidata) prop.testC(nes$dem, nes$gender, w=nes$nesw)
library(poliscidata) prop.testC(nes$dem, nes$gender, w=nes$nesw)
Prints string to console quickly, but still scolls for visual effect
quickConsolePrint(linetoprint)
quickConsolePrint(linetoprint)
linetoprint |
Text to be printed to console |
No value returned
Sets color for text that effectively contrasts with the background color specified. Used by the Colors
function.
SetTextContrastColor(color)
SetTextContrastColor(color)
color |
A color |
Returns either "black" or "white"
Prints string to console slowly to make text more readable to the user. Used by welcome
function.
slowConsolePrint(linetoprint, slow = 0.05)
slowConsolePrint(linetoprint, slow = 0.05)
linetoprint |
Text to be printed to console |
slow |
Time, in milliseconds, to wait between characters printed to console (default is .05). |
No value returned
This function calculates the Somer's D measure of association statistic. This function makes use of the svytable function from the survey package.
somersD(formula, data)
somersD(formula, data)
formula |
A formula in the form ~ indepvar + depvar |
data |
A design dataset (e.g. gssD, nesD, statesD, or worldD) |
Return Somer's D measure of association statistic, a number between 0 and 1.
library(poliscidata) somersD(~ dem_educ3 + envjob_3, nesD)
library(poliscidata) somersD(~ dem_educ3 + envjob_3, nesD)
Returns case-level information in order specified by user.
sortC(data, id, by, descending = TRUE)
sortC(data, id, by, descending = TRUE)
data |
Dataset to be sorted. |
id |
A variable in the dataset (data) that identfies individual cases, typically the name of states, countries, etc. |
by |
Variable the dataset should be sorted by. |
descending |
Should the cases be sorted in descending order? By default, set to TRUE. |
A data frame of sorted observations.
library(poliscidata) sortC(data=states, id=state, by=abortlaw10) sortC(data=states, id=state, by=abortlaw10, descending=FALSE)
library(poliscidata) sortC(data=states, id=state, by=abortlaw10) sortC(data=states, id=state, by=abortlaw10, descending=FALSE)
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 135 variables.
Abortion restrictions (3 category ranking)
Abortions per 1,000 women (2005)
Number of abortions per 1,000 women aged 15-44 (2008)
2012 Abortion rank (Americans United for Life)
Number of restrictions on abortion (2010)
Abortion restrictions (three tiers of number of restrictions)
Percent of population with advanced degree or higher
Alcohol consumption in gallons per capita (2007)
Percent frequently attend religious serviced (Pew)
Percent of population with college degree or higher
Battleground state in 2004?
Percent of state legislators who are black
Percent black (2004)
Percent black (2008)
Percent black (2010)
Percent voting for Bush in 2000
Percent voting for Bush in 2004
Motor vehicle fatalities (per 100,000 pop)
Motor vehicle fatalities per 100,000 pop (2007)
Cigarette tax per pack (2007)
Cigarette tax per pack: 3 categories (2007)
Cigarette tax per pack (2012)
Cigarette tax per pack: 3 categories (2012)
Packs smoked bimonthly per adult (2003)
Percent of population with college or higher
Percent mass public Conservative
Conservatism score, US House delegation (2006)
Conservatism score, US House delegation (2009)
Conservative advantage, mass public (2012)
Percent mass public conservative (2013)
Cook Index: Higher scores mean more Democratic
3 quantiles of cook_index
Federal defense expenditures per capita
Democratic advantage, mass public (2012)
Percent US House delegation Democratic (2009)
Percent HR delegation Democratic (2011)
Percent US House and Senate Democratic (2006)
Percent mass public Democratic
Percent of state legislators who are Democrats (2006)
Percent of state legislators who are Democrats (2009)
Percent state legislature Democrats (2013)
Population density (2010)
Census division (9 different regions of country)
Earmarks per capita (in dollars)
State electoral vote: McCain (2008)
State electoral vote: Obama (2008)
Obama's Electoral College vote
Romney's Electoral College vote
Billman's policy scale (4 ordinal categories)
Does state have 'most conservative' gay policies?
RECODE of gay_policy (Billman's policy scale)
Lax-Phillips opinion index
Gay rights: public support (3 categories)
Did Bush win electoral vote, 2000?
Did Bush win electoral vote, 2004?
Percent voting for Gore 2000
Percentage workforce government workers (2012)
Background checks for gun purchases per 100,000 pop (2012)
Gun dealers per 100,000 pop
Gun murder rate (2010)
Recode of gun_rank11 so higher number ranks = more gun restrictions
Brady gun rank (2011)
Recode of gun_rank11 (3 ordinal categories)
Brady gun law scale (2011)
Brady campaign rank (2008)
Number of restrictions (2008)
Brady campaign score (2008)
Percent Hispanic (2004)
Percent Hispanic (2008)
Percent Hispanic (2010)
Conservativism ranking of House of Representatives delegation (2011, American Conservative Union)
Conservativism rating of House of Representatives delegation (2011, American Conservative Union)
Liberalism ranking of House of Representatives delegation (2011, Americans for Democratic Action)
Liberalism rating of House of Representatives delegation (2011, Americans for Democratic Action)
Percent population high school education or higher
Percent mass public Independent
Percent voting for Kerry 2004
Percent mass public Liberal
Percent voting for McCain 2008
Percent mass public Moderate
Percent voting for Nader 2000
Did Obama win electoral vote, 2008?
Did Obama win the state in 2012?
Percent voting for Obama 2008
Obama vote share in 2012
Percent population over age 64
Percent public that would always permit abortion (2004 NES)
Percent population aged 18-24 (2004)
Percent population aged 18-24 (2010)
State population, 2000
State population, 2010
State population, 2010 (in 100k)
State population, 2000-2012
State population percentage, 2000-2010
Marijuana laws
Per capita income
Percent public pro-choice
Percent public pro-life
Census region (4 categories)
Percentage Catholic (2012)
Percentage high religiosity (2012)
Percent religion "A great deal of guidance"
Percentage low religiosity (2012)
Percentage Protestant (2012)
Religious observance-belief scale (Pew)
Religiosity (3 categories)
Percent mass public Republican
Romney vote share in 2012
Right to work state?
Secularism scale (Pew)
3 quantiles of secularism
Does state have influential US Senator?
Percentage of population who smoke
Southern state?
State name
Two letter postal abbreviation for state name
Percentage point change in turnout from 2000 to 2004
Percentage point change in turnout from 2004 to 2008
Percentage point change in turnout from 2008 to 2012
Turnout in 2000 presidential election
Turnout in 2004 presidential election
Unemployment rate (2004)
Percentage without health insurance (2012)
Percent workers who are union members (2004)
Percent workers who are union members (2007)
Percent workforce unionized (2010)
Percent urban population (2000)
Percent turnout of voting eligible population in 2000
Percent turnout of voting eligible population in 2004
Percent turnout of voting eligible population in 2008
Percent turnout of voting eligible population in 2012
Percent of state legislators who are women (2007)
Percent of state legislators who are women (2010)
Percent of state legislators who are women (2011)
Percent of state legislators who are women (2015)
Data sources vary. See Appendix Table A.3 of printed textbook for further information.
This is a design dataset with variables about the 50 states. This design dataset is used to demonstrate application of certain R functions to political analysis. See states
dataset documentation for variable names and descriptions.
statesD
statesD
A design dataset version of the states dataset used for certain weighted analyses. The variables element has 50 observations of 135 variables.
Sources vary. See Appendix Table A.3 of printed textbook for further information
Computes statistics for controlled mean comparison table. Used by imeansC
function.
svybyC(formula1 = NULL, formula2 = NULL, data, ...)
svybyC(formula1 = NULL, formula2 = NULL, data, ...)
formula1 |
A formula |
formula2 |
A formula |
data |
Dataset |
... |
Further arguments to be passed to svyby function. |
A svyby-type object
This function reports chi-squared test statistic based on weighted dataset
svychisqC(formula, design)
svychisqC(formula, design)
formula |
Formula expressing the relationship between variables in the form ~ depvar + indepvar |
design |
Weighted design dataset (like gssD, nesD, statesD, or worldD) |
No return
library(poliscidata) svychisqC(~ gay_rights3 + libcon3, nesD)
library(poliscidata) svychisqC(~ gay_rights3 + libcon3, nesD)
This function is called by somersD
function.
tablesomersDC(x, dep = 2)
tablesomersDC(x, dep = 2)
x |
A svytable |
dep |
which dimension stands for the dependent variable (1 = ROWS, 2 = COLS), default is 2. |
No return
Welcomes users to Companion Package to Political Analysis and provides basic information about using Companion functions and datasets.
welcome()
welcome()
No value returned
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 167 rows and 103 variables.
Country numerical code
Colony of what country? (CIA)
Confidence in institutions scale (World Values Survey)
Country/territory name (title case)
Country/territory name (title case), may be same as country
Public debt as a percentage of GDP (CIA)
Democratic decentralization, 2008 (UN)
Full or Part Democracy (Economist, 2014)
Regime type (Economist 2014)
Percentage of other democracies in region
Percentage of other democracies in region: 5 categories
Democracy rank, lower scores more democratic (Economist 2014)
Democracy score, higher scores more democratic (Economist 2014)
Is government a democracy? (Based on regime_type3)
Is government a democracy? Coded 0/100 (Based on regime_type3)
Is regime a democracy? (1990)
Is government a democracy? (may be redundant)
Democracy score, 2011 (UN)
Average # of members per district (World Values Survey)
Effective number of parliamentary parties
Number of years since the last regime transition (Polity)
Government effectiveness scale (Kaufmann 2002)
Effective number of parliamentary parties: 3 categories
Effective number of parliamentary parties (World Values Survey)
EU member state (yes/no)
Total fertility rate: Number children born per woman (CIA)
Freedom House rating of democracy (reversed)
Freedom House 1-7 scale reversed, rescaled 0-12
Ethnic factionalization (combined linguistic and racial) (Alesina et al 2003)
Ethnic factionalization (combined linguistic and racial) (Binned)
Level of ethnic fractionalization: 3 categories
Heritage Foundation rating: bus. freedom (2010)
Heritage Foundation rating: corruption (2010)
Heritage Foundation rating: financial freedom (2010)
Heritage Foundation rating: fiscal freedom (2010)
Heritage Foundation rating: government spending (2010)
Heritage Foundation rating: invest freedom (2010)
Heritage Foundation rating: labor freedom (2010)
Heritage Foundation rating: monetary freedom (2010)
Heritage Foundation rating: overall economic freedom (2010)
4 quantiles of free_overall
Heritage Foundation rating: property rights (2010)
Heritage Foundation rating: free trade (2010)
GDP per capita in 10K US$ (2002)
GDP per capita (US$): 2 categories (2002)
GDP per capita (US$): 3 categories (2002)
GDP in billions in 2008 (World Bank)
GDP per capita (US$) in 2008, 2 categories
GDP per capita (US$) in 2008, 2 categories (may be redundant)
GDP per capita (US$) in 2008 (Binned)
GDP per capita in 2008 (World Bank)
3 quantiles of gdppcap08 (as numeric)
Gender empowerment measure, 3 categories (World Values Survey)
Gender Inequality Index value, 2008 (UN)
Gender Inequality Index rank, 2008 (UN)
Gini coefficient (UN 2004)
Gini coeff (UN 2008)
Income Gini coefficient, 2000-2010 (UN)
Government regulation of religion index, 2008 (CIA)
Human development index (HDI) value, 2010 (UN)
High GDP dummy
Year of independence (CIA)
Percent Women in lower house of legislature, all countries, 2013 (Inter-Parliamentary Union)
Life expectancy at birth among females (CIA)
Life expectancy at birth among males (CIA)
Life expectancy at birth, total population (CIA)
Literacy rate (CIA)
Is Muslim predominate religious group?
Name of country (lower case)
OECD member state (yes/no)
Oil production, in barrels per day (CIA)
Post-materialism, 3 categories (World Values Survey)
Higher scores more democratic (Polity)
Percentage of population age 0-14 (CIA)
Percentage of population age 15-64 (CIA)
Percent of population age 65 and older (CIA)
Median age in years, 2010
Total population in millions, 2010 (UN)
Percentage of the total population living in urban areas, 2010 (UN)
Proportional representation system? (Institute for Democracy and Electoral Assistance)
Protest activity (World Values Survey)
Regime type (Cheibub's Democracy Dictatorship dataset)
United Nations region
Largest religion by proportion (UN)
Rich democracy, interaction of Hi_gdp*democ_regime
Sex ratio at birth (male births per 100 female births), 2010
Public expenditure on education as a percentage of GDP (UN)
Public expenditure on health as a percentage of GDP (UN)
Public expenditure on the military as a percentage of GDP, 2008 (UN)
Union density (www.ilo.org)
Percent growth in the number of Internet users, population based, 2000-2008 (UN)
Internet users per 100 people, 2008 (UN)
Percentage of population below national poverty line, 2000-2008 (UN)
Per capita remittance inflows in US dollars, 2008
Remittance inflows as a percentage of GDP, 2008
Percent saying religion very important, 3 categories
Turnout: most recent election in 2000s (Institute for Democracy and Electoral Assistance)
Turnout: elections in 1990s (Institute for Democracy and Electoral Assistance)
Percent women in lower house of legislature, democracies only, 2005 (Inter-Parliamentary Union)
Percent women in lower house of legislature, democracies only, 2009 (Inter-Parliamentary Union)
Percent Women in lower house of legislature, democracies only, 2013 (Inter-Parliamentary Union)
Year women first enfranchised (Inter-Parliamentary Union)
Women's suffrage (Inter-Parliamentary Union)
Sources vary. See Appendix Table A.4 of printed textbook for further information.
This is a design dataset with variables about countries in the world. This dataset is used to demonstrate application of R to political analysis. See world
dataset documentation for variable names and descriptions.
worldD
worldD
A design dataset version of the world dataset used for certain weighted analyses. The variables element has 167 observations of 103 variables.
Sources vary. See Appendix Table A.4 of printed textbook for further information
The wtd.boxplot function is no longer being used by the poliscidata package. Please use the svyboxplot function instead.
See svyhist
documentation for details; also see pp. 67-69 of The R Companion to Political Analysis, 2nd Edition.
wtd.boxplot(...)
wtd.boxplot(...)
... |
Any arguments used will yield same warning message. |
Warning message only.
Takes in variable and finds median, works with sampling weights
wtd.median(x, weights = NULL)
wtd.median(x, weights = NULL)
x |
A variable |
weights |
Sampling weights of variable (optional) |
Makes use of the wtd.quantile function, part of the Hmisc package
Returns the median value of the variable
library(poliscidata) wtd.median(nes$budget_deficit_x, nes$wt)
library(poliscidata) wtd.median(nes$budget_deficit_x, nes$wt)
Takes in variable and finds mode, works with sampling weights
wtd.mode(x, weights = NULL)
wtd.mode(x, weights = NULL)
x |
A variable |
weights |
Sampling weights of variable (optional) |
Makes use of the freq function, part of the descr package
Returns the modal value of the variable
library(poliscidata) wtd.mode(gss$zodiac, gss$wtss)
library(poliscidata) wtd.mode(gss$zodiac, gss$wtss)
Takes in variable and calculates standard deviation, works with sampling weights.
wtd.sd(x, weights = NULL)
wtd.sd(x, weights = NULL)
x |
A variable (must be numeric), should be in dataset$var form. |
weights |
Sampling weights of variable (optional), should be in dataset$weightvar form. |
Makes use of the freq function, part of the descr package.
Returns the standard deviation of the variable, a numeric value.
library(poliscidata) wtd.sd(nes$polknow_combined, nes$wt)
library(poliscidata) wtd.sd(nes$polknow_combined, nes$wt)
This function conducts a weighted t-test
wtd.ttestC(f1, f2, data, digits = 3)
wtd.ttestC(f1, f2, data, digits = 3)
f1 |
Function identifying interval-level dependent variable in the form ~ depvar |
f2 |
A function that defines groups to be compared in the form ~ indepvar |
data |
A design dataset such as gssD, nesD, statesD, or worldD |
digits |
Number of digits to report after decimal place, optional (default = 3). |
No return
library(poliscidata) wtd.ttestC(f1 = ~ ftgr_gay, f2 = ~ gender, data = nesD) wtd.ttestC(~ ft_rep, ~ gender, nesD)
library(poliscidata) wtd.ttestC(f1 = ~ ftgr_gay, f2 = ~ gender, data = nesD) wtd.ttestC(~ ft_rep, ~ gender, nesD)
Controlled cross tabulation analysis with optional weights
xtabC(function1, data, digits = 2)
xtabC(function1, data, digits = 2)
function1 |
A function of the relationship to be analyzed expressed in the form ~ depvar + indepvar + controlvar |
data |
A design dataset (e.g. gssD, nesD, statesD, worldD) |
digits |
Number of digits to report after decimal place, optional (default = 2). |
A controlled cross tabulation as a multi-dimensional array.
library(poliscidata) xtabC(~ divlaw2 + attend3 + kids, gssD)
library(poliscidata) xtabC(~ divlaw2 + attend3 + kids, gssD)
Generates cross-tabulation of dependent and indendent variables, also creates a mosiac plot. Makes use of the crosstab function in the descr package.
xtp( data, y, x, w = NULL, ylab = NULL, xlab = NULL, main = NULL, digits = 2, chisq = FALSE )
xtp( data, y, x, w = NULL, ylab = NULL, xlab = NULL, main = NULL, digits = 2, chisq = FALSE )
data |
Dataset (like gss, nes, states, or world) |
y |
Dependent variable |
x |
Independent variable |
w |
Weights (optional) |
ylab |
Y-axis label (optional) |
xlab |
X-axis label (optional) |
main |
Main label for plot (optional) |
digits |
Number of digits to report after decimal place, optional (default = 2) |
chisq |
Do you want Chi-Squared test reported? (default is FALSE) |
A data frame of the cross tabulation results
library(poliscidata) xtp(gss, grass, attend3, wtss)
library(poliscidata) xtp(gss, grass, attend3, wtss)
This function makes use of the crosstab function from the descr package
xtp.chi2(data, y, x, w = NULL, digits = 1, prop.c = FALSE)
xtp.chi2(data, y, x, w = NULL, digits = 1, prop.c = FALSE)
data |
Dataset to be sorted |
y |
Dependent variable |
x |
Independent variable |
w |
Weights (optional) |
digits |
Number of digits to report after decimal place, optional (default = 1). |
prop.c |
Do you want column percentages reported in table? (default is FALSE) |
Returns a data frame of cross tabulation results
library(poliscidata) xtp.chi2(gss, pornlaw, attend3, wtss)
library(poliscidata) xtp.chi2(gss, pornlaw, attend3, wtss)