Package 'poliscidata'

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

Help Index


Calculates adjusted R-Squared statistic

Description

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.

Usage

AdjR2(tdf, null.dev, resid.dev, k)

Arguments

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)

Value

Returns an adjusted R-Squared statistic, a numeric value between 0 and 1

Examples

AdjR2(200, 1500, 1100, 5)
   
   AdjR2(tdf=200, null.dev=1500, resid.dev=1100, k=5)

Imported Functions Made Available to Users

Description

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.

Usage

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(...)

Arguments

...

See source package help file for details on function usage.


Calculates a 95 Percent Confidence Interval

Description

Prints the lower and upper boundaries of a 95 Percent confidence interval. Also see the CI95 function.

Usage

CI95(m, se)

Arguments

m

A single number equal to the mean value of a statistic.

se

single number equal to the standard error of the statistic.

Value

Returns the 95

Examples

CI95(10, 1)
  
  CI95(m=8, se=2)

Calculates a 99 Percent Confidence Interval

Description

Prints the lower and upper boundaries of a 99 Percent confidence interval. Also see the CI95 function.

Usage

CI99(m, se)

Arguments

m

A single number equal to the mean value of a statistic.

se

single number equal to the standard error of the statistic.

Value

Returns the 99

Examples

CI99(10, 1)
  
  CI99(m=8, se=2)

Displays R Colors

Description

Produces plot of colors available in R. Colored cells labels with numeric value that corresponds to that color. No values supplied to function.

Usage

Colors()

Value

No value returned

Examples

Colors()

Column Percentages

Description

Generates column percentaged tables for multi-dimensional controlled cross-tabulations, based on function by John Fox. Used by xtabC function.

Usage

colPercents(tab, digits = 2)

Arguments

tab

A table of values

digits

Number of decimal places to display, default is 2.

Value

Table of column-percentaged values


Calculates a statistic for measure of association in cross-tabulation

Description

This function is called by tablesomersDC function.

Usage

compADPQ(x)

Arguments

x

A matrix or data frame

Value

Returns a list of statistics


Calculates Cramer's V

Description

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.

Usage

CramersV(chi, r, c, n)

Arguments

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

Value

The Cramer's V statistic, a number between 0 and 1.

Examples

CramersV(84.18, 2, 2, 1315)
  
  CramersV(chi=84.18, r=2, c=2, n=1315)

Calculates model fit statistics for a svyglm weighted regression model

Description

Model fit statistics for a svyglm weighted regression model

Usage

fit.svyglm(svyglm, digits = 3)

Arguments

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).

Value

Returns a numeric vector of R-Squared and Adjusted R-sSquared statistics.

Examples

library(poliscidata)
   
   obamaThermModel <- svyglm(obama_therm ~ gender, design=nesD, na.action="na.omit")
   summary(obamaThermModel)
   fit.svyglm(obamaThermModel)

Generates table and figure describing distribution of variable values.

Description

Generates frequency distribution table and bar chart to describe distribution of variable values. Based on freq function in descr package.

Usage

freqC(x, w, plot = TRUE)

Arguments

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)

Value

A frequency distribution table (a "freqtable" and "matrix" class object)

Examples

library(poliscidata)
   
   freqC(gss$zodiac, gss$wtss)
   
   freqC(x=gss$zodiac, w=gss$wtss)

GSS dataset for R Companion to Essentials of Political Analysis, Second Edition

Description

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.

Usage

gss

Format

A data frame with 1974 rows and 221 variables.

abany

Abortion Permissible: Woman Wants For Any Reason

abdefect

Abortion Permissible: Strong Chance of Serious Defect

abhlth

Abortion Permissible: Woman's Health Seriously Endangered

abnomore

Abortion Permissible: Woman Married–Wants No More Children

abortion

Under How Many Conditions Abortion Permissible?

abortion_3

Under How Many Conditions Abortion Permissible? 3 Categories

abpoor

Abortion Permissible: Low Income–Can't Afford More Children

abrape

Abortion Permissible: Pregnant As Result of Rape

absingle

Abortion Permissible: Not Married

affrmact

Favor Preference in Hiring Blacks

affrmact2

Support Affirmative Action?

age

Respondent's Age

age.f

Respondent's Age (as ordered factor)

age2

Respondent's Age: 2 Categories

age_3

Age Group: 3 Categories

age_5

Age Group: 5 Categories

attend

How Often Respondent Attends Religious Services

attend2

Attendance at Religious Services: Low or High

attend3

Attendance at Religious Services: 3 Categories

attend7

Attendance at Religious Services: 7 Categories

authoritarianism

Authoritarianism Scale

bible

Feelings About the Bible

black

Is Respondent African American?

black_traits

Black Stereotypes

born

Was Respondent Born in This Country

cappun

Favor or Oppose Death Penalty For Murder

childs

Number of Children

closeblk

How Close Do You Feel to Blacks?

closeblk2

How Close to Blacks? 2 Categories

closewht

How Close Feel to Whites

closewht2

How Close Do You Feel to Whites? 2 Categories

cohort

Year of Birth

colath

College Teaching: Allow Anti-Religionist to Teach

colcom

College Teaching: Should Communist Teacher Be Fired

colhomo

College Teaching: Allow Homosexual to Teach

colmil

College Teaching: Allow Militarist to Teach

colmslm

College Teaching: Allow Anti-American Muslim Clergymen to Teach

colrac

College Teaching: Allow Racist to Teach

con_govt

Confidence in Government Institutions

conarmy

Confidence in Military

conbus

Confidence in Major Companies

conclerg

Confidence in Organized Religion

coneduc

Confidence in Education

confed

Confidence in Exec Branch of Fed Government

confinan

Confidence in Banks & Financial Institutions

conjudge

Confidence in United States Supreme Court

conlabor

Confidence in Organized Labor

conlegis

Confidence in Congress

conmedic

Confidence in Medicine

conpress

Confidence in Press

consci

Confidence in Scientific Community

contv

Confidence in Television

courts

Courts Dealing With Criminals

dateintv

Date of Interview

degree

Respondent's Highest Degree

dem

Is Respondent a Democrat?

divlaw

Divorce Laws

divlaw2

Should divorce laws make it more difficult?

educ

Highest Year of School

educ_2

Education: 2 Categories

educ_4

Education: 4 Categories

egalit_scale

Egalitarianism Scale

egalit_scale3

Egalitarianism: 3 Categories

egalit_scale4

Egalitarianism: 4 Categories

eqwlth

Should Government Reduce Income Differences?

ethnic

Country of Family Origin

evangelical

Evangelical Scale

fechld

Female Roles: Mother Working Doesn't Hurt Children

feelevel

Amount of Fees Paid (to Respondent for Interview)

feeused

Fee Given to Get Case (for the Interview)

fefam

Female Roles: Better For Man to Work, Woman Tend Home

femrole

Female Role (Scale of Values)

femrole2

Female Role: 2 Categories

fepresch

Female Roles: Preschool Kids Suffer If Mother Works

fucitzn

Is Respondent Planning/Applying For US Citizenship?

fund

How Fundamentalist Is Respondent Currently?

fund2

Is Respondent Fundamentalist?

getahead

Opinion of How People Get Ahead

god_r

Know God Exists?

grass

Should Marijuana Be Made Legal?

grass.legal

Should Marijuana Be Made Legal? (numeric)

gunlaw

Favor or Oppose Gun Permits?

happy

General Happiness

helpblk

Should Government Aid Blacks?

helpnot

Should Government Do More or Less?

helpoth

To Help Others

helppoor

Should Government Improve Standard of Living?

helpsick

Should Government Help Pay For Medical Care?

hhtype1

Household Type (Condensed)

hispanic

Hispanic Specified

hispanic_2

Is Respondent Hispanic?

homosex

Homosexual Sex Relations

homosex2

Homosexuality Always Wrong?

id

Respondent Id Number

income06

Total Family Income

int_info_scale

Interest in Current Issues? (Additive index)

intage

Interviewer: Age of Interviewer

intecon

Interested in Economic Issues?

inteduc

Interested in Local School Issues?

intenvir

Interested in Environmental Issues?

intethn

Interviewer: Race of Interviewer

intethn_2

Interviewer: Interviewer's Race

intfarm

Interested in Farm Issues?

inthisp

Interviewer: Is Interviewer Spanish, Hispanic or Latino

intintl

Interested in International Issues?

intmed

Interested in Medical Discoveries?

intmil

Interested in Military Policy?

intrace1

Interviewer: Interviewer's Race1

intrace2

Interviewer: Interviewer's Race2

intrace3

Interviewer: Interviewer's Race3

intsci

Interested in New Scientific Discoveries?

intsex

Interviewer: Sex of Interviewer

intspace

Interested in Space Exploration?

inttech

Interested in Technologies?

intyrs

Interviewer: Years of Service as an Interviewer at NORC

kids

Does Respondent Have Kids?

libath

Allow Anti-Religious Book in Library?

libcom

Allow Communists Book in Library?

libhomo

Allow Homosexuals Book in Library?

libmil

Allow Militarists Book in Library?

libmslm

Allow Anti-American Muslim Clergymen's Books in Library?

librac

Allow Racists Book in Library?

lngthinv

How Long Was Interview

marital

Marital Status

militarist_tol

Tolerance Toward Militarists

mobile16

Geographic Mobility Since Age 16

mode

Interview Done In-Person or Over the Phone

mslm_col

Muslims: Teach in College?

mslm_lib

Muslims: Book in Library?

mslm_spk

Muslims: Preach?

mslm_spk.yes

Muslims: Preach? (as numeric)

mslm_spk.high

Muslims: Preach? (as numeric)

nataid

Federal spending: Foreign Aid

natarms

Federal spending: Military, Armaments, and Defense

natchld

Federal spending: Assistance for Childcare

natcity

Federal spending: Solving Problems of Big Cities

natcrime

Federal spending: Halting Rising Crime Rate

natdrug

Federal spending: Dealing with Drug Addiction

nateduc

Federal spending: Improving Nations Education System

natenrgy

Federal spending: Developing Alternative Energy Sources

natenvir

Federal spending: Improving & Protecting Environment

natfare

Federal spending: Welfare

natheal

Federal spending: Improving & Protecting Nations Health

natmass

Federal spending: Mass Transportation

natpark

Federal spending: Parks and Recreation

natrace

Federal spending: Improving the Conditions of Blacks

natroad

Federal spending: Highways and Bridges

natsci

Federal spending: Supporting Scientific Research

natsoc

Federal spending: Social Security

natspac

Federal spending: Space Exploration Program

news

How Often Does Respondent Read Newspaper

obey

To Obey

obey2

Obedience Important in Children?

owngun

Have Gun in Home

partyid

Political Party Affiliation

partyid_3

Party Id: 3 Categories

polviews

Ideological Self-Placement

popular

Important for Child: To Be Well Liked or Popular

pornlaw

Feelings About Pornography Laws

pornlaw2

Pornography opinion

postlife

Belief in Life After Death

pray

How Often Does Respondent Pray

premarsx

Sex Before Marriage

pres08

Vote Obama or Mccain

racdif1

Differences Due to Discrimination

racdif2

Differences Due to Inborn Disability

racdif3

Differences Due to Lack of Education

racdif4

Differences Due to Lack of Will

race

Race of Respondent

race_2

Race: Black / White

racial_liberal3

Racial Liberalism

reborn_r

Born Again?

region

Region of Interview

relig

Respondent's Religious Preference

relig2

Respondent's Religious Preference, limited to Catholic and Protestant

reliten

Strength of Affiliation

reliten2

Strong Religious Affiliation

rincom06

Respondent Income

rincom06_5

Respondent Income: 5 Categories

savesoul_r

Tried to Convince Others of Jesus?

science_quiz

Number Correct on Science Quiz

science_quiz.f

Number Correct on Science Quiz, stored as factor

sex

Respondent's Sex

sibs

Number of Brothers and Sisters

size

Size of Place in 1000s

social_connect

Social Connectedness

social_cons3

Social Conservatism

social_trust

Social Trust (Numeric Scale)

south

Respondent from South?

spanking

Favor Spanking to Discipline Child?

spanking2

Approve of spanking

spend3

Econ Liberalism

spkath

Allow Speaker in Your Community: Anti-Religionist

spkcom

Allow Speaker in Your Community: Communist

spkhomo

Allow Speaker in Your Community: Homosexual

spkmil

Allow Speaker in Your Community: Militarist

spkmslm

Allow Speaker in Your Community: Muslim Clergymen Preaching Hatred

spkrac

Allow Speaker in Your Community: Allow Racist to Speak

teensex

Sex Before Marriage – Teens 14-16

thnkself

Important for Child: To Think For One's Self

tolerance

Tolerance Scale

tolerance4

Tolerance Scale (Binned)

tvhours

Hours Per Day Watching TV

tvhours5

Hours per day

union

Does Respondent or Spouse Belong to Union

uscitzn

Is Respondent US Citizen

vetyears

Years in Armed Forces

vote08_coded

Did Respondent Vote in 2008 Election

voted08

Did Respondent Vote in 2008?

white_traits

White Stereotypes

wordsum

Number Words Correct in Vocabulary Test

workhard

To Work Hard

wrkgvt

Respondent Work for Government or Private Employee

wrkslf

Respondent Self-Emp or Works For Somebody

wrkstat

Labor Force Status

wrkwayup

Irish, Italian, Jewish and other Should Overcome Prejudice Without Favors

wtss

Weight Variable

wtssall

Weight Variable (same as wtss)

xmarsex

Sex With Person Other Than Spouse

year

GSS Year For This Respondent

zodiac

Respondent's Astrological Sign

Source

2012 General Social Survey. See Appendix Table A.1 of printed textbook for further information


GSS design dataset for R Companion to Essentials of Political Analysis, Second Edition

Description

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.

Usage

gssD

Format

A design dataset version of the gss dataset used for certain weighted analyses. The variables element has 1974 observations of 221 variables.

Source

2012 General Social Survey. See Appendix Table A.1 of printed textbook for further information


Controlled Mean Comparison Table

Description

Produces a controlled mean comparison table. Rows defined by values of independent variable and columns defines by values of the control variable.

Usage

imeansC(function1 = NULL, function2 = NULL, data, digits = 2)

Arguments

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).

Value

A controlled mean comparison table (an "ftable" class object)

Examples

library(poliscidata)
   
   imeansC(function1 = ~ft_dem, function2 = ~gender + married, data=nesD)
   
   imeansC(~ft_dem, ~gender + married, nesD)

Calculates predicted probability for a given logged odds value

Description

This function calculates predicted probability for a given logged odds value, often useful for plotting or reporting predicted probabilities.

Usage

inverse.logit(logged_odds)

Arguments

logged_odds

A numeric value, or vector of numeric values.

Value

Returns predicted probability corresponding the the logged odds value, a numeric value between 0 and 1.

Examples

inverse.logit(0)
   
   inverse.logit(-5:5)

Interaction plot

Description

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.

Usage

iplotC(function1 = NULL, function2 = NULL, data, function3 = NULL, ...)

Arguments

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 brkdn.plot function (plotrix package)

Value

No value returned

Examples

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

Description

Displays line types for R plots. No values supplied to function.

Usage

lineType()

Value

No value returned

Examples

lineType()

Logistic regression model statistics

Description

Logistic regression model statistics

Usage

logregR2(model, digits = 3)

Arguments

model

An estimated logistic regression model

digits

Number of digits to be displayed after decimal points

Value

Returns list of statistics about model (a "LogRegR2" class object)

Examples

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)

NES dataset for R Companion to Essentials of Political Analysis, Second Edition

Description

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.

Usage

nes

Format

A data frame with 5916 rows and 399 variables.

abort_scale

Anti-abortion Scale

abort4

Abortion Opinion: Self-Placement, 4 Categories

abortpre_4point

Abortion Opinion: Self-Placement, 4 Categories

aidblack_self

Support for Government assistance to blacks scale, 7 point scale

auth_consid

Child trait more important: considerate or well-behaved

auth_cur

Child trait more important: curiosity or good manners

auth_ind

Child trait more important: independence or respect

auth_obed

Child trait more important: obedience or self-reliance

authoritarianism

Authoritarianism (4 point scale based on child trait questions)

black

Is Respondent Black?

budget_deficit_x

Favor reducing the Federal budget deficit, 7 point scale

caseid

Case ID

casistart_iwrset4

Does Respondent have a dog (Interview set-up test)

casistartpo_iwrset4

Does Respondent have a dog (Interview set-up test)

cog_opin_x

Number of opinions Respondent has compared to average person

congapp_job_x

Approval of Congress

congapp_jobst

Strength of approve/disapprove Congress handling its job

conservatism

ftgr_cons minus ftgr_liberals

cses_closepty

Close to any political party?

cses_contct

Campaign mobilization: institutional contact

cses_email

Campaign mobilization: institutional contact - email

cses_ftf

Campaign mobilization: institutional contact - in person

cses_gotv

Respondent contacted by party/candidate?

cses_govtact

Support for government action income inequality (5 point scale)

cses_govtact_3

Government action on income inequality (3 point scale)

cses_mail

Campaign mobilization: institutional contact - by mail

cses_mobph

Campaign mobilization: sign up online information or alerts

cses_perseml

Campaign mobilization: personal contact - email

cses_persftf

Campaign mobilization: personal contact - in person

cses_persmail

Campaign mobilization: personal contact - by mail

cses_persph

Campaign mobilization: personal contact - by phone

cses_perstxt

Campaign mobilization: personal contact - text message

cses_persuade

Campaign mobilization: personal contact

cses_persweb

Campaign mobilization: personal contact - social network

cses_phone

Campaign mobilization: institutional contact - by phone

cses_poliinffour

Political information - Secretary of the U.N.

cses_poliinfone

Political information - Secretary of the Treasury

cses_poliinfthree

Political information - party 2nd in House seats won

cses_polinf_x

Pol info scale

cses_polinftwo

Political information - unemployment rate

cses_polinftwo_date

Political information - date used for date of unemployment rate

cses_polinftwo_rate

Political information - number used for unemployment rate

cses_spending

Econ conservatism (numeric scale)

deathpen

Death Penalty Opinion

defsppr_self

Support for defense spending, 7 point scale

dem

Party identification: Does Respondent self-identify as Democrat? (coded 0/1)

dem_age_group_r

Demographic: Age Groups

dem_age3

Demographic: Age group

dem_age6

Demographic: Six Age Groups

dem_agegrp_iwdate

Demographic: Respondent age on interview date (age group)

dem_educ3

Demographic: Education

dem_edugroup

Demographic: Respondent level of highest education

dem_hisp

Demographic: Is Respondent Spanish, Hispanic, or Latino

dem_marital

Demographic: Marital status

dem_parents

Demographic: Native status of parents

dem_racecps_black

Demographic: Race self-identification: mention Black

dem_racecps_racedkrf

Demographic: Race self-identification with don't know or refused to say

dem_racecps_white

Demographic: Race self-identification: mention White

dem_raceeth

Demographic: Respondent race and ethnicity group

dem_raceeth2

Demographic: White/Black

dem_raceeth4

Demographic: Respondent race and ethnicity group

dem_unionhh

Demographic: Anyone in household belong to labor union

dem_veteran

Demographic: Respondent ever served on active duty in Armed Forces

dem2_numchild

Demographic: Total Number of children in household

dem3_ownhome

Demographic: Does Respondent family own/rent home

dem3_yearscomm

Demographic: How many years has Respondent lived in this community?

dhs_appterr_x

Homeland security: Approve/disapprove of efforts to reduce terrorism

dhs_attack

Homeland security: Likely terrorist attack kill 100/more in next year?

dhs_threat_x

Homeland security: Is fed. gov't a threat to rights and freedoms? (numeric scale)

dhs_threat3

Homeland security: Is fed. gov't a threat to rights and freedoms?

dhs_torture_x

Homeland security: Favor/Oppose torture for suspected terrorists

dhsinvolv_board

Civic engagement: Has Respondent in past 4 years: attended city/school board meeting

dhsinvolv_call

Civic engagement: Has Respondent in past 4 years: called radio/TV about political issue

dhsinvolv_contact1

Civic engagement: Contact U.S. Representative or Senator

dhsinvolv_letter

Civic engagement: written a letter to newspaper/magazine about political issue

dhsinvolv_march

Civic engagement: Has Respondent joined a protest march

dhsinvolv_message

Civic engagement: sent Facebook/Twitter message about political issue

dhsinvolv_netpetition

Civic engagement: Has Respondent in past 4 years: sign internet petition

dhsinvolv_org

Civic engagement: Has Respondent in past 4 years: gave money to social/political organization

dhsinvolv_petition

Civic engagement: Has Respondent signed paper petition

dhsinvolv_relig

Civic engagement: Has Respondent in past 4 years: given money to religious organization

discrim_blacks

Discrimination: Amount against Blacks

discrim_blacks_r

Discrimination: Against Blacks? (yes/no)

discrim_gays

Discrimination: Amount against Gays and Lesbians?

discrim_gays_r

Discrimination: Against gays? (yes/no)

discrim_hispanics

Discrimination: Amount against Hispanics

discrim_hispanics_r

Discrimination: Against Hispanics? (yes/no)

discrim_scale

Discrimination: How much discrimination against blacks, gays, Hispanics, women? (Sum of yes answers)

discrim_self

Discrimination: How much discrimination faced personally?

discrim_whites

Discrimination: Amount against Whites

discrim_women

Discrimination: Amount against Women

discrim_women_r

Discrimination: Against women? (yes/no)

discuss_disc

Ever discuss politics with family or friends

discuss_discpstwk

Days in past week discussed politics

ecblame_fmpr

Economy: How much is former President to blame for poor economy?

ecblame_pres

Economy: How much is President to blame for poor economy?

econ_ecnext_x

Economy: U.S. economy better or worse 1 year from now

econ_ecnextamt

Economy: How much better/worse next 12 months

econ_ecnow

Economy: Currently good or bad

econ_ecpast

Economy: Better/worse in last year

econ_ecpast_x

Economy: Better or worse than 1 year ago

econ_ecpastamt

Economy: How much better/worse in last year

econ_unlast

Economy: How much unemployment better/worse in last year

econ_unnext

Economy: More/less unemployment in next year

econ_unpast

Economy: Unemployment better/worse in last year

econ_unpast_x

Economy: Unemployment better/worse than 1 year ago

econcand_dwin

Economy: Better/worse if Democratic Presidential candidate wins

econcand_rwin

Economy: Better/worse if Republican Presidential candidate wins

ecperil_home

How do you pay for your home?

effic_carerev

Political efficacy: Public officials don't care what people think

effic_carestd

Political efficacy: Public officials don't care what people think

effic_complicrev

Political efficacy: Politics/government too complicated to understand

effic_complicstd

Political efficacy: Politics/government too complicated to understand

effic_external

Political efficacy: External political efficacy (numeric scale)

effic_external3

Political efficacy: External political efficacy (3 categories)

effic_internal

Political efficacy: Internal political efficacy (numeric scale)

effic_internal3

Political efficacy: Internal political efficacy (3 categories)

effic_sayrev

Political efficacy: Have no say about what government does

effic_saystd

Political efficacy: Have no say about what government does

effic_undrev

Political efficacy: Good understanding of political issues

effic_undstd

Political efficacy: Good understanding of political issues

efficpo_bothside

Political efficacy: How often see both disagreeing parties as right

egal_bigprob

Equality: It's a big problem that we don't give equal chance to succeed

egal_equal

Equality: Society should make sure everyone has equal opportunity

egal_fewerprobs

Equality: If people were treated more fairly would be fewer problems

egal_notbigprob

Equality: Not a big problem if some have more chance in life

egal_scale

Equality: Egalitarianism (numeric scale)

egal_scale_3

Equality: Egalitarianism: 3 categories

egal_toofar

Equality: We have gone too far pushing equal rights

egal_worryless

Equality: We'd be better off if worried less about equality

envir

Environment: Environment more important response (on envjob_3) as 0/100

envir_drill

Environment: Favor/oppose increased U.S. offshore drilling

envir_gwarm

Environment: Is global warming happening or not

envir_gwgood

Environment: Rising temperatures good or bad

envir_gwhow

Environment: Anthropogenic climate change

envir_nuke

Environment: Should US have more/fewer nuclear power plants

enviro.yes

Environment: Environment more important response (on envjob_3) as 0/100

envjob_3

Environment: Environment or jobs more important?

envjob_self

Environment: 7 point scale environment-jobs tradeoff

fairjob_opin_x

Opinion about government ensuring fair jobs for blacks

fedspend_child

Federal budget increase/decrease: child care

fedspend_childr

Federal budget increase/decrease: child care (rev. scale)

fedspend_crime

Federal budget increase/decrease: crime control

fedspend_crimer

Federal budget increase/decrease: crime control (rev. scale)

fedspend_enviro

Federal budget increase/decrease: protecting environment

fedspend_enviror

Federal budget increase/decrease: protecting environment (rev. scale)

fedspend_poor

Federal budget increase/decrease: aid to the poor

fedspend_poorr

Federal budget increase/decrease: aid to the poor (rev. scale)

fedspend_scale

Federal Spending Scale (numeric scale, sum of increase responses)

fedspend_schools

Federal budget increase/decrease: public schools

fedspend_schoolsr

Federal budget increase/decrease: public schools (rev. scale)

fedspend_scitech

Federal budget increase/decrease: science and technology

fedspend_scitechr

Federal budget increase/decrease: science and technology (rev. scale)

fedspend_ss

Federal budget increase/decrease: Social Security

fedspend_ssr

Federal budget increase/decrease: Social Security (rev. scale)

fedspend_welfare

Federal budget increase/decrease: welfare programs

fedspend_welfarer

Federal budget increase/decrease: welfare programs (rev. scale)

fem3

Feeling about feminists (recode of ftgr_feminists into 3 categories)

finance_finfam

Financial situation: Respondent living with how many family members

finance_finnext_x

Financial situation: Better or worse off 1 year from now

finance_finpast_x

Financial situation: Better or worse off than 1 year ago

ft_dem

Feeling Thermometer: Democratic Party

ft_dpc

Feeling Thermometer: Democratic Presidential candidate

ft_dvpc

Feeling Thermometer: Democratic Vice-Presidential candidate

ft_gwb

Feeling Thermometer: G.W. Bush

ft_hclinton

Feeling Thermometer: Hillary Clinton

ft_rep

Feeling Thermometer: Republican Party

ft_rpc

Feeling Thermometer: Republican Presidential candidate

ft_rvpc

Feeling Thermometer: Republican Vice-Pres candidate

ftcasi_asian

Feeling thermometer: Asian-Americans

ftcasi_black

Feeling thermometer: Blacks

ftcasi_hisp

Feeling thermometer: Hispanics

ftcasi_illegal

Feeling thermometer: Illegal Immigrants

ftcasi_white

Feeling thermometer: Whites

ftf_oversample

Was Respondent a 2012 Time Series Oversample Case?

ftgr_atheists

Feeling thermometer: Atheists

ftgr_bigbus

Feeling thermometer: Big Business

ftgr_catholics

Feeling thermometer: Catholics

ftgr_congress

Feeling thermometer: Congress

ftgr_cons

Feeling thermometer: Conservatives

ftgr_fedgov

Feeling thermometer: Federal Government

ftgr_fem3

Feeling thermometer: Feminists (3 categories)

ftgr_feminists

Feeling thermometer: Feminists

ftgr_gay

Feeling thermometer: Gay Men and Lesbians

ftgr_liberals

Feeling thermometer: Liberals

ftgr_middle

Feeling thermometer: Middle Class People

ftgr_military

Feeling thermometer: The Military

ftgr_mormons

Feeling thermometer: Mormons

ftgr_muslims

Feeling thermometer: Muslims

ftgr_poor

Feeling thermometer: Poor People

ftgr_rich

Feeling thermometer: Rich People

ftgr_tea

Feeling thermometer: Tea Party

ftgr_unions

Feeling thermometer: Labor Unions

ftgr_ussc

Feeling thermometer: The U.S. Supreme Court

ftgr_welfare

Feeling thermometer: People on Welfare

ftgr_working

Feeling thermometer: Working Class People

ftgr_xfund

Feeling thermometer: Christian Fundamentalists

ftgr_xian

Feeling thermometer: Christians

ftpo_dpcsp

Feeling thermometer: Spouse of Democratic Presidential candidate

ftpo_dvpc

Feeling thermometer: Democratic Vice Presidential candidate

ftpo_hdc

Feeling thermometer: House Democratic Candidate

ftpo_hoth

Feeling thermometer: House Independent/3rd-party Candidate

ftpo_hrc

Feeling thermometer: House Republican Candidate

ftpo_pres

Feeling thermometer: Democratic Presidential candidate

ftpo_roberts

Feeling thermometer: John Roberts

ftpo_rpc

Feeling thermometer: Republican Presidential candidate

ftpo_rpcsp

Feeling thermometer: Spouse of Republican Presidential candidate

ftpo_rvpc

Feeling thermometer: Republican Vice Presidential candidate

ftpo_sdc

Feeling thermometer: Senate Democratic Candidate

ftpo_senjr

Feeling thermometer: Jr. Senator in State Without Race

ftpo_sennot

Feeling thermometer: Non-running Senator in State W/Race

ftpo_sensr

Feeling thermometer: Sr. Senator in State Without Race

ftpo_soth

Feeling thermometer: Senate Independent/3rd-party Candidate

ftpo_src

Feeling thermometer: Senate Republican Candidate

gay_adopt

Gay rights: gayrt_adopt==1. Yes

gay_disc

Gay rights: gayrt_discstd_x==1. Approve strongly

gay_marry

Gay rights: Approve same-sex marriage?

gay_mil

Gay rights: gayrt_milstd_x==1. Feel strongly that homosexuals should be allowed to serve

gay_rights3

Gay rights: Gay Rights Support (3 categories)

gayrt_adopt

Gay rights: Should gay and lesbian couples be allowed to adopt?

gayrt_discrev_x

Gay rights: favor laws against gays/lesbians job discrimination (rev.)

gayrt_discstd_x

Gay rights: favor laws against gays/lesbians job discrimination

gayrt_marry

Gay rights: Respondent position on gay marriage

gayrt_milrev_x

Gay rights: allow gays/lesbians serve in US armed forces (reversed)

gayrt_milstd_x

Gay rights: allow gays/lesbians serve in US armed forces

gender

Respondent's Gender

govrole_scale

Pro-government scale (numeric scale)

guarpr_self

Should gov't guarantee a job and standard of living? (7 point scale)

gun_control

Gun control: Should federal gov't make it more difficult to buy a gun?

gun_control2

Gun control: Make it more difficult to buy a gun?

gun_importance

Gun control: Importance of gun access issue to R

gun_importance3

Gun control: How important is gun issue?

happ_lifesatisf

How satisfied is Respondent with life?

health_2010hcr_x

Health care: Support 2010 health care law

health_insured

Health care: Does Respondent have health insurance

health_self

Health care: Health of Respondent

health_smoke

Health care: Smoked Cigarettes

health_smokeamt

Health care: If smoked, how many now

hispanic

Is Respondent Hispanic?

hlthlaw_num

Health care: Health Care Law effect on number insured

hlthlaw_qual

Health care: Health Care Law effect on health care services

hseinc_approval

Congress: Approve or disapprove of House incumbent

hseinc_approval_x

Congress: House incumbent approval

hseinc_appstr

Congress: How much approve House incumbent

hseinc_disstr

Congress: How much disapprove House incumbent

hseinc_hinctouch

Congress: How good a job does House incumbent do in district

immig_checks

Immigration: Opinion on immigration status checks on suspects

immig_citizen

Immigration: Opinion on allowing citizenship to some illegal aliens

immig_policy

Immigration: U.S. government policy toward unauthorized immigrants

immigpo_jobs

Immigration: How likely immigration will take away jobs

immigpo_level

Immigration: What should immigration levels be

imports_limit

Favor or oppose limits on foreign imports

inc_incgroup_pre

Respondent's family income

incgroup_prepost

Respondent's family income

income5

Respondent's income quintile

indifference

Indifference scale

ineq_incgap_x

Income gap size compared to 20 years ago

ineqinc_ineqgb

Is increased income inequality in U.S. good?

ineqinc_ineqreduc

Does Respondent favor/oppose government reducing income inequality?

inspre_self

Health care: Should care be insured by government or by private medical insurance? (7 point scale)

involv_contact

Involvement in politics: Contact congress?

involv_message

Involvement in politics: post political message?

involv_numorgs_4

Involvement in politics: Number of group memberships

involv_org

Involvement in politics: Give money to political organization?

involv_petition

Involvement in politics: Sign net petition?

involv_voltr

Involvement in politics: Has Respondent done any volunteer work in past 12 months?

israel_support

Is U.S. too supportive of Israel or not supportive enough

knowl_housemaj

Political knowledge: Know party with most members in House?

knowl_senmaj

Political knowledge: Know party with most members in Senate?

libcon3

Respondent's Political Ideology (3 categories)

libcpo_self

Respondent's Political Ideology (7 point scale)

libcpre_ptyd

Ideological placement of Democrats (7 point scale)

libcpre_ptyr

Ideological placement of Republicans (7 point scale)

libcpre_rpc

Ideological placement of Republican Pres. Candidate (7 point scale)

libcpre_self

Respondent's Political Ideology (7 point scale)

libcpre_self_x

Respondent's Political Ideology (7 point scale)

link_black_scale

Linked fate: blacks

link_hisp_scale

Linked fate: Hispanics

link_oth_scale

Linked fate: other people

link_white_scale

Linked fate: whites

link_wom_scale

Linked fate: women

married

Demographic: Is Respondent married?

mobilpo_x

Campaign mobilization: Respondent contacted by Party, Candidates, GOTV (numeric scale)

mode

Mode of interview (face-to-face or internet)

modsex_disc

Sex discrimination: How much job discrimination against women

modsex_discamt

Sex discrimination: Discrimination against women

modsex_media_x

Sex discrimination: How much attention media should pay to discrimination against women

modsex_oppor_x

Sex discrimination: Opportunities compared for women and men

modsex_prob

Sex discrimination: Do women complaining about discrimination cause more problems

modsex_scale

Sex discrimination: Modern sexism

modsex_special

Sex discrimination: Do women demanding equality seek special favors

modsex_wommore

Sex discrimination: How much more opportunities do women have

mormon_xn

Mormon a Christian religion?

nesw

Sampling weights: Weight variable

nesw_rnd

Sampling weights: Weight variable (rounded)

obama_therm

Obama Rating

obama_vote

Respondent vote for Obama?

orientn_knowgay

Sexual orientation of family and friends

orientn_rgay

Respondent's sexual orientation

own_dog

Does Respondent own a dog?

owngun_owngun

Does Respondent own a gun

patriot_amident

Patriotism: Important being American

patriot_flag

Patriotism: Emotion seeing flag fly

patriot_love

Patriotism: Love of country

patriotism

Patriotism scale

penalty_dpenstr

Strength Respondent favors/opposes death penalty

penalty_favdpen

Respondent favor/oppose death penalty

penalty_favopp_x

Favor death penalty?

pid_3

Party Identification, 3 categories

pid_x

Party Identification, 7 categories

polknow_combined

Political knowledge: Number political facts correct

polknow3

Political knowledge, 3 categories

postvote_presvt

Did Respondent vote for President

postvote_presvtwho

For whom did Respondent vote for President

postvote_rvote

Did Respondent vote in the November general election

postvote_votehs

Did Respondent vote for U.S. House of Representatives

pot_legal

Should marijuana be legal?

pot_legal3

Legalize marijuana?

preknow_leastsp

Political knowledge: Program that federal gov't spends the least on

preknow_medicare

Political knowledge: What is Medicare

preknow_prestimes

Political knowledge: Number of times president can be elected

preknow_senterm

Political knowledge: Years Senator Elected

preknow_sizedef

Political knowledge: Size of federal deficit

preknow3

Political knowledge, 3 categories

pres_econ

Presidential approval: Handling of economy (Recode of presapp_econ)

pres_vote12

Respondent's vote in 2012 presidential election

presapp_econ_x

Presidential approval: Handling of economy

presapp_foreign

Presidential approval: Handling of foreign relations

presapp_foreign_x

Presidential approval: Handling of foreign relations

presapp_health_x

Presidential approval: Handling of health care

presapp_job_x

Presidential approval: Handling of job

presapp_scale

Presidential approval scale

presapp_war_x

Presidential approval: Handling of war in Afghanistan

presvote2012_2

Respondent's vote in 2012 presidential election

presvote2012_x

Respondent's vote in 2012 presidential election

preswin_care

Care who wins Presidential Election

preswin_dutychoice_x

Does Respondent consider voting as duty/choice

prevote_primv

Did Respondent vote in the Presidential primary or caucus

prevote_primvwho

Which candidate did Respondent vote for in Pres. primary or caucus

prochoice_scale

Abortion: Pro-choice Scale

relig_4cat

Religion: Catholic, other Christian, other, or not religious?

relig_attend

Religion: Attend services

relig_attend3

Religion: Attend services

relig_bornagn

Religion: Does Christian Respondent consider self born-again?

relig_guide

Religion: Provides guidance in day-to-day living

relig_imp

Religion: Important to Respondent?

relig_imp2

Religion: Important to Respondent?

relig_import

Religion: Important part of Respondent's life

relig_pray

Religion: How often does Respondent pray

relig_wordgod

Religion: Is Bible word of God or men

resent_deserve

Black community: Agree/disagree blacks have gotten less than deserve

resent_racial_scale

Black community: Racial conservatism scale

resent_slavery

Black community: Agree/disagree past slavery make life more difficult

resent_try

Black community: Agree/disagree blacks must try harder to get ahead

resent_workway

Black community: Agree/disagree that blacks should work way up without special favors

rvote2012_x

Did Respondent vote in November general election?

sample_district

Respondent's Congressional district (in 113th U.S. Congress)

sample_ftfpsu

Sample strata: Primary sampling unit for face-to-face cases

sample_state

State of Respondent address

science_use

How often should gov't use scientific methods to solve problems?

scourt_elim_x

Should the Supreme Court be done away with?

scourt_remove_x

Should it be possible to remove Supreme Court justices?

south

Respondent from South?

spsrvpr_ssself

Support for government services/spending (7 point scale)

strata_ftf

Sample strata for face-to-face sample component

strata_full

Sample strata for full sample

tarp_favopp_x

Favor the TARP program?

tea_supp_x

Tea Party support

trad_adjust

Traditional values: Agree/disagree world is changing we should adjust

trad_famval

Traditional values: Agree/disagree that more emphasis needed on traditional family values

trad_lifestyle

Traditional values: Agree/disagree are newer lifestyles are breaking down society

trad_tolerant

Traditional values: Agree/disagree that one should be more tolerant of other moral standards

trad_values_scale

Traditional values: Moral traditionalism scale

trust_social

Trust: How often can people be trusted?

trustgov_bigintrst

Trust: Is government run by a few big interests or for benefit of all?

trustgov_corrpt

Trust: How many in government are corrupt?

trustgov_trustgrev

Trust: How often trust gov't in Wash to do what is right? (reversed)

trustgov_trustgstd

Trust: How often trust government in Wash to do what is right?

trustgov_waste

Trust: Does government waste much tax money?

trustgvpo_crook

Trust: How many in government are crooked?

usworld_stay

International relations: Country better off if we just stayed home

usworld_stronger

International relations: During last year, U.S. position in world is weaker/stronger/same?

version

ANES 2012 Time Series Release Version

voted2008

Did Respondent vote for President in 2008? (Recode of interest_voted2008)

voted2012

Did Respondent vote in 2012?

voter_type

Voter type (non, new, voter)

weight_ftf

Post-stratified weight for face-to-face cases, preliminary

weight_full

Post-stratified weight for full sample, preliminary release

weight_web

Post-stratified weight for web cases, preliminary release

white

Is Respondent white?

wiretap_warrant

Wiretaps: Favor or oppose authority to wiretap terrorism suspects?

wiretappo_toofar

Wiretaps: Has government power gone too far?

women_bond_x

Working women: Harder to establish bond with child?

women_role

Working women: Women's role (numeric scale)

women_role_2

Working women: Women's role at home or work?

women_works_x

Working women: Better if man works and woman takes care of home and family?

wpres_gdbd_x

How good/bad to have woman president in next 20 years?

wt

Sampling weight

year

ANES year

Source

2012 American National Election Survey. See Appendix Table A.2 of printed textbook for further information


NES design dataset for R Companion to Essentials of Political Analysis, Second Edition

Description

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.

Usage

nesD

Format

A design dataset version of the nes dataset used for certain weighted analyses. The variables element has 5916 observations of 399 variables.

Source

2012 American National Election Survey. See Appendix Table A.2 of printed textbook for further information


Translate logistic regression coefficients into odds ratios

Description

Generates odds-ratios based on logistic regression model coefficients

Usage

orci(model, digits = 3)

Arguments

model

An estimated logistic regression model

digits

Number of digits after decimal to display

Value

Returns odds rations and confidence intervals in columns (a matrix class object)

Examples

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

Description

Comparing Logistic Regression Models with Chi-Squared Test

Usage

pchisqC(reduced, full, digits = 3)

Arguments

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.

Value

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.

Examples

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

Description

Displays plotting characters available in R. No values supplied to function.

Usage

plotChar()

Value

No return

Examples

plotChar()

Plots mean comparison

Description

Plots the mean values of a dependent variable at different values of nominal or ordinal independent variable. Makes use of survey package's svy

Usage

plotmeansC(data, function1 = NULL, function2 = NULL, function3, w = 1, ...)

Arguments

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 plotmeans function

Value

No return

Examples

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

Description

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.

Usage

printC(objx)

Arguments

objx

A table or data frame

Value

No return


Difference of Proportions Test

Description

Difference of proportions test with optional sample weights. Reports P-value of two-tailed significance test.

Usage

prop.testC(y, x, w = NULL, digits = 3)

Arguments

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).

Value

No return

Examples

library(poliscidata)
   
   prop.testC(nes$dem, nes$gender, w=nes$nesw)

Prints string to console quickly

Description

Prints string to console quickly, but still scolls for visual effect

Usage

quickConsolePrint(linetoprint)

Arguments

linetoprint

Text to be printed to console

Value

No value returned


Sets contrasting color for text

Description

Sets color for text that effectively contrasts with the background color specified. Used by the Colors function.

Usage

SetTextContrastColor(color)

Arguments

color

A color

Value

Returns either "black" or "white"


Prints string to console slowly

Description

Prints string to console slowly to make text more readable to the user. Used by welcome function.

Usage

slowConsolePrint(linetoprint, slow = 0.05)

Arguments

linetoprint

Text to be printed to console

slow

Time, in milliseconds, to wait between characters printed to console (default is .05).

Value

No value returned


Calculates Somer's D

Description

This function calculates the Somer's D measure of association statistic. This function makes use of the svytable function from the survey package.

Usage

somersD(formula, data)

Arguments

formula

A formula in the form ~ indepvar + depvar

data

A design dataset (e.g. gssD, nesD, statesD, or worldD)

Value

Return Somer's D measure of association statistic, a number between 0 and 1.

Examples

library(poliscidata)
   
   somersD(~ dem_educ3 + envjob_3, nesD)

Returns case-level information in order

Description

Returns case-level information in order specified by user.

Usage

sortC(data, id, by, descending = TRUE)

Arguments

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.

Value

A data frame of sorted observations.

Examples

library(poliscidata)
   
   sortC(data=states, id=state, by=abortlaw10)
   
   sortC(data=states, id=state, by=abortlaw10, descending=FALSE)

States dataset for R Companion to Essentials of Political Analysis, Second Edition

Description

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.

Usage

states

Format

A data frame with 50 rows and 135 variables.

abort_rank3

Abortion restrictions (3 category ranking)

abort_rate05

Abortions per 1,000 women (2005)

abort_rate08

Number of abortions per 1,000 women aged 15-44 (2008)

abortion_rank12

2012 Abortion rank (Americans United for Life)

abortlaw10

Number of restrictions on abortion (2010)

abortlaw3

Abortion restrictions (three tiers of number of restrictions)

adv_or_more

Percent of population with advanced degree or higher

alcohol

Alcohol consumption in gallons per capita (2007)

attend_pct

Percent frequently attend religious serviced (Pew)

ba_or_more

Percent of population with college degree or higher

battle04

Battleground state in 2004?

blkleg

Percent of state legislators who are black

blkpct04

Percent black (2004)

blkpct08

Percent black (2008)

blkpct10

Percent black (2010)

bush00

Percent voting for Bush in 2000

bush04

Percent voting for Bush in 2004

carfatal

Motor vehicle fatalities (per 100,000 pop)

carfatal07

Motor vehicle fatalities per 100,000 pop (2007)

cig_tax

Cigarette tax per pack (2007)

cig_tax_3

Cigarette tax per pack: 3 categories (2007)

cig_tax12

Cigarette tax per pack (2012)

cig_tax12_3

Cigarette tax per pack: 3 categories (2012)

cigarettes

Packs smoked bimonthly per adult (2003)

college

Percent of population with college or higher

conpct_m

Percent mass public Conservative

cons_hr06

Conservatism score, US House delegation (2006)

cons_hr09

Conservatism score, US House delegation (2009)

conserv_advantage

Conservative advantage, mass public (2012)

conserv_public

Percent mass public conservative (2013)

cook_index

Cook Index: Higher scores mean more Democratic

cook_index3

3 quantiles of cook_index

defexpen

Federal defense expenditures per capita

dem_advantage

Democratic advantage, mass public (2012)

dem_hr09

Percent US House delegation Democratic (2009)

demhr11

Percent HR delegation Democratic (2011)

demnat06

Percent US House and Senate Democratic (2006)

dempct_m

Percent mass public Democratic

demstate06

Percent of state legislators who are Democrats (2006)

demstate09

Percent of state legislators who are Democrats (2009)

demstate13

Percent state legislature Democrats (2013)

density

Population density (2010)

division

Census division (9 different regions of country)

earmarks_pcap

Earmarks per capita (in dollars)

evm

State electoral vote: McCain (2008)

evo

State electoral vote: Obama (2008)

evo2012

Obama's Electoral College vote

evr2012

Romney's Electoral College vote

gay_policy

Billman's policy scale (4 ordinal categories)

gay_policy_con

Does state have 'most conservative' gay policies?

gay_policy2

RECODE of gay_policy (Billman's policy scale)

gay_support

Lax-Phillips opinion index

gay_support3

Gay rights: public support (3 categories)

gb_win00

Did Bush win electoral vote, 2000?

gb_win04

Did Bush win electoral vote, 2004?

gore00

Percent voting for Gore 2000

govt_worker

Percentage workforce government workers (2012)

gun_check

Background checks for gun purchases per 100,000 pop (2012)

gun_dealer

Gun dealers per 100,000 pop

gun_murder10

Gun murder rate (2010)

gun_rank_rev

Recode of gun_rank11 so higher number ranks = more gun restrictions

gun_rank11

Brady gun rank (2011)

gun_rank3

Recode of gun_rank11 (3 ordinal categories)

gun_scale11

Brady gun law scale (2011)

gunlaw_rank

Brady campaign rank (2008)

gunlaw_rank3_rev

Number of restrictions (2008)

gunlaw_scale

Brady campaign score (2008)

hispanic04

Percent Hispanic (2004)

hispanic08

Percent Hispanic (2008)

hispanic10

Percent Hispanic (2010)

hr_cons_rank11

Conservativism ranking of House of Representatives delegation (2011, American Conservative Union)

hr_conserv11

Conservativism rating of House of Representatives delegation (2011, American Conservative Union)

hr_lib_rank11

Liberalism ranking of House of Representatives delegation (2011, Americans for Democratic Action)

hr_liberal11

Liberalism rating of House of Representatives delegation (2011, Americans for Democratic Action)

hs_or_more

Percent population high school education or higher

indpct_m

Percent mass public Independent

kerry04

Percent voting for Kerry 2004

libpct_m

Percent mass public Liberal

mccain08

Percent voting for McCain 2008

modpct_m

Percent mass public Moderate

nader00

Percent voting for Nader 2000

obama_win08

Did Obama win electoral vote, 2008?

obama_win12

Did Obama win the state in 2012?

obama08

Percent voting for Obama 2008

obama2012

Obama vote share in 2012

over64

Percent population over age 64

permit

Percent public that would always permit abortion (2004 NES)

pop_18_24

Percent population aged 18-24 (2004)

pop_18_24_10

Percent population aged 18-24 (2010)

pop2000

State population, 2000

pop2010

State population, 2010

pop2010_hun_thou

State population, 2010 (in 100k)

popchng0010

State population, 2000-2012

popchngpct

State population percentage, 2000-2010

pot_policy

Marijuana laws

prcapinc

Per capita income

prochoice

Percent public pro-choice

prolife

Percent public pro-life

region

Census region (4 categories)

relig_cath

Percentage Catholic (2012)

relig_high

Percentage high religiosity (2012)

relig_import

Percent religion "A great deal of guidance"

relig_low

Percentage low religiosity (2012)

relig_prot

Percentage Protestant (2012)

religiosity

Religious observance-belief scale (Pew)

religiosity3

Religiosity (3 categories)

reppct_m

Percent mass public Republican

romney2012

Romney vote share in 2012

rtw

Right to work state?

secularism

Secularism scale (Pew)

secularism3

3 quantiles of secularism

seniority_sen2

Does state have influential US Senator?

smokers12

Percentage of population who smoke

south

Southern state?

state

State name

stateid

Two letter postal abbreviation for state name

to_0004

Percentage point change in turnout from 2000 to 2004

to_0408

Percentage point change in turnout from 2004 to 2008

to_0812

Percentage point change in turnout from 2008 to 2012

trnout00

Turnout in 2000 presidential election

trnout04

Turnout in 2004 presidential election

unemploy

Unemployment rate (2004)

uninsured_pct

Percentage without health insurance (2012)

union04

Percent workers who are union members (2004)

union07

Percent workers who are union members (2007)

union10

Percent workforce unionized (2010)

urban

Percent urban population (2000)

vep00_turnout

Percent turnout of voting eligible population in 2000

vep04_turnout

Percent turnout of voting eligible population in 2004

vep08_turnout

Percent turnout of voting eligible population in 2008

vep12_turnout

Percent turnout of voting eligible population in 2012

womleg_2007

Percent of state legislators who are women (2007)

womleg_2010

Percent of state legislators who are women (2010)

womleg_2011

Percent of state legislators who are women (2011)

womleg_2015

Percent of state legislators who are women (2015)

Source

Data sources vary. See Appendix Table A.3 of printed textbook for further information.


States design dataset for R Companion to Essentials of Political Analysis, Second Edition

Description

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.

Usage

statesD

Format

A design dataset version of the states dataset used for certain weighted analyses. The variables element has 50 observations of 135 variables.

Source

Sources vary. See Appendix Table A.3 of printed textbook for further information


Computes summary statistics

Description

Computes statistics for controlled mean comparison table. Used by imeansC function.

Usage

svybyC(formula1 = NULL, formula2 = NULL, data, ...)

Arguments

formula1

A formula

formula2

A formula

data

Dataset

...

Further arguments to be passed to svyby function.

Value

A svyby-type object


Chi-Squared Statistic for Relationship Between Categorical Variables using Weighted Dataset

Description

This function reports chi-squared test statistic based on weighted dataset

Usage

svychisqC(formula, design)

Arguments

formula

Formula expressing the relationship between variables in the form ~ depvar + indepvar

design

Weighted design dataset (like gssD, nesD, statesD, or worldD)

Value

No return

Examples

library(poliscidata)
   
   svychisqC(~ gay_rights3 + libcon3, nesD)

Produces summary statistics

Description

This function is called by somersD function.

Usage

tablesomersDC(x, dep = 2)

Arguments

x

A svytable

dep

which dimension stands for the dependent variable (1 = ROWS, 2 = COLS), default is 2.

Value

No return


Function to Introduce Users to R Companion Environment

Description

Welcomes users to Companion Package to Political Analysis and provides basic information about using Companion functions and datasets.

Usage

welcome()

Value

No value returned


World dataset for R Companion to Essentials of Political Analysis, Second Edition

Description

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.

Usage

world

Format

A data frame with 167 rows and 103 variables.

arda

Country numerical code

colony

Colony of what country? (CIA)

confidence

Confidence in institutions scale (World Values Survey)

country

Country/territory name (title case)

country1

Country/territory name (title case), may be same as country

debt

Public debt as a percentage of GDP (CIA)

decent08

Democratic decentralization, 2008 (UN)

dem_economist

Full or Part Democracy (Economist, 2014)

dem_level4

Regime type (Economist 2014)

dem_other

Percentage of other democracies in region

dem_other5

Percentage of other democracies in region: 5 categories

dem_rank14

Democracy rank, lower scores more democratic (Economist 2014)

dem_score14

Democracy score, higher scores more democratic (Economist 2014)

democ

Is government a democracy? (Based on regime_type3)

democ.yes

Is government a democracy? Coded 0/100 (Based on regime_type3)

democ_regime

Is regime a democracy? (1990)

democ_regime08

Is government a democracy? (may be redundant)

democ11

Democracy score, 2011 (UN)

district_size3

Average # of members per district (World Values Survey)

dnpp_3

Effective number of parliamentary parties

durable

Number of years since the last regime transition (Polity)

effectiveness

Government effectiveness scale (Kaufmann 2002)

enpp3_democ

Effective number of parliamentary parties: 3 categories

enpp3_democ08

Effective number of parliamentary parties (World Values Survey)

eu

EU member state (yes/no)

fertility

Total fertility rate: Number children born per woman (CIA)

fhrate04_rev

Freedom House rating of democracy (reversed)

fhrate08_rev

Freedom House 1-7 scale reversed, rescaled 0-12

frac_eth

Ethnic factionalization (combined linguistic and racial) (Alesina et al 2003)

frac_eth2

Ethnic factionalization (combined linguistic and racial) (Binned)

frac_eth3

Level of ethnic fractionalization: 3 categories

free_business

Heritage Foundation rating: bus. freedom (2010)

free_corrupt

Heritage Foundation rating: corruption (2010)

free_finance

Heritage Foundation rating: financial freedom (2010)

free_fiscal

Heritage Foundation rating: fiscal freedom (2010)

free_govspend

Heritage Foundation rating: government spending (2010)

free_invest

Heritage Foundation rating: invest freedom (2010)

free_labor

Heritage Foundation rating: labor freedom (2010)

free_monetary

Heritage Foundation rating: monetary freedom (2010)

free_overall

Heritage Foundation rating: overall economic freedom (2010)

free_overall_4

4 quantiles of free_overall

free_property

Heritage Foundation rating: property rights (2010)

free_trade

Heritage Foundation rating: free trade (2010)

gdp_10_thou

GDP per capita in 10K US$ (2002)

gdp_cap2

GDP per capita (US$): 2 categories (2002)

gdp_cap3

GDP per capita (US$): 3 categories (2002)

gdp08

GDP in billions in 2008 (World Bank)

gdpcap08_2

GDP per capita (US$) in 2008, 2 categories

gdpcap2_08

GDP per capita (US$) in 2008, 2 categories (may be redundant)

gdpcap3_08

GDP per capita (US$) in 2008 (Binned)

gdppcap08

GDP per capita in 2008 (World Bank)

gdppcap08_3

3 quantiles of gdppcap08 (as numeric)

gender_equal3

Gender empowerment measure, 3 categories (World Values Survey)

gender_unequal

Gender Inequality Index value, 2008 (UN)

gender_unequal_rank

Gender Inequality Index rank, 2008 (UN)

gini04

Gini coefficient (UN 2004)

gini08

Gini coeff (UN 2008)

gini10

Income Gini coefficient, 2000-2010 (UN)

govregrel

Government regulation of religion index, 2008 (CIA)

hdi

Human development index (HDI) value, 2010 (UN)

hi_gdp

High GDP dummy

indy

Year of independence (CIA)

ipu_wom13_all

Percent Women in lower house of legislature, all countries, 2013 (Inter-Parliamentary Union)

lifeex_f

Life expectancy at birth among females (CIA)

lifeex_m

Life expectancy at birth among males (CIA)

lifeex_total

Life expectancy at birth, total population (CIA)

literacy

Literacy rate (CIA)

muslim

Is Muslim predominate religious group?

natcode

Name of country (lower case)

oecd

OECD member state (yes/no)

oil

Oil production, in barrels per day (CIA)

pmat12_3

Post-materialism, 3 categories (World Values Survey)

polity

Higher scores more democratic (Polity)

pop_0_14

Percentage of population age 0-14 (CIA)

pop_15_64

Percentage of population age 15-64 (CIA)

pop_65_older

Percent of population age 65 and older (CIA)

pop_age

Median age in years, 2010

pop_total

Total population in millions, 2010 (UN)

pop_urban

Percentage of the total population living in urban areas, 2010 (UN)

pr_sys

Proportional representation system? (Institute for Democracy and Electoral Assistance)

protact3

Protest activity (World Values Survey)

regime_type3

Regime type (Cheibub's Democracy Dictatorship dataset)

regionun

United Nations region

religoin

Largest religion by proportion (UN)

rich_democ

Rich democracy, interaction of Hi_gdp*democ_regime

sexratio

Sex ratio at birth (male births per 100 female births), 2010

spendeduc

Public expenditure on education as a percentage of GDP (UN)

spendhealth

Public expenditure on health as a percentage of GDP (UN)

spendmil

Public expenditure on the military as a percentage of GDP, 2008 (UN)

unions

Union density (www.ilo.org)

unnetgro

Percent growth in the number of Internet users, population based, 2000-2008 (UN)

unnetuse

Internet users per 100 people, 2008 (UN)

unpovnpl

Percentage of population below national poverty line, 2000-2008 (UN)

unremitp

Per capita remittance inflows in US dollars, 2008

unremitt

Remittance inflows as a percentage of GDP, 2008

vi_rel3

Percent saying religion very important, 3 categories

votevap00s

Turnout: most recent election in 2000s (Institute for Democracy and Electoral Assistance)

votevap90s

Turnout: elections in 1990s (Institute for Democracy and Electoral Assistance)

women05

Percent women in lower house of legislature, democracies only, 2005 (Inter-Parliamentary Union)

women09

Percent women in lower house of legislature, democracies only, 2009 (Inter-Parliamentary Union)

women13

Percent Women in lower house of legislature, democracies only, 2013 (Inter-Parliamentary Union)

womyear

Year women first enfranchised (Inter-Parliamentary Union)

womyear2

Women's suffrage (Inter-Parliamentary Union)

Source

Sources vary. See Appendix Table A.4 of printed textbook for further information.


World design dataset for R Companion to Essentials of Political Analysis, Second Edition

Description

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.

Usage

worldD

Format

A design dataset version of the world dataset used for certain weighted analyses. The variables element has 167 observations of 103 variables.

Source

Sources vary. See Appendix Table A.4 of printed textbook for further information


Weighted Box Plot

Description

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.

Usage

wtd.boxplot(...)

Arguments

...

Any arguments used will yield same warning message.

Value

Warning message only.


Find Median of Variable

Description

Takes in variable and finds median, works with sampling weights

Usage

wtd.median(x, weights = NULL)

Arguments

x

A variable

weights

Sampling weights of variable (optional)

Details

Makes use of the wtd.quantile function, part of the Hmisc package

Value

Returns the median value of the variable

Examples

library(poliscidata)
   
   wtd.median(nes$budget_deficit_x, nes$wt)

Find Mode of Variable

Description

Takes in variable and finds mode, works with sampling weights

Usage

wtd.mode(x, weights = NULL)

Arguments

x

A variable

weights

Sampling weights of variable (optional)

Details

Makes use of the freq function, part of the descr package

Value

Returns the modal value of the variable

Examples

library(poliscidata)
   
   wtd.mode(gss$zodiac, gss$wtss)

Find Standard Deviation of Variable

Description

Takes in variable and calculates standard deviation, works with sampling weights.

Usage

wtd.sd(x, weights = NULL)

Arguments

x

A variable (must be numeric), should be in dataset$var form.

weights

Sampling weights of variable (optional), should be in dataset$weightvar form.

Details

Makes use of the freq function, part of the descr package.

Value

Returns the standard deviation of the variable, a numeric value.

Examples

library(poliscidata)
   
   wtd.sd(nes$polknow_combined, nes$wt)

Weighted T-Test

Description

This function conducts a weighted t-test

Usage

wtd.ttestC(f1, f2, data, digits = 3)

Arguments

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).

Value

No return

Examples

library(poliscidata)
   
   wtd.ttestC(f1 = ~ ftgr_gay, f2 = ~ gender, data = nesD)
   
   wtd.ttestC(~ ft_rep, ~ gender, nesD)

Controlled cross tabulation analysis with optional weights

Description

Controlled cross tabulation analysis with optional weights

Usage

xtabC(function1, data, digits = 2)

Arguments

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).

Value

A controlled cross tabulation as a multi-dimensional array.

Examples

library(poliscidata)
   
   xtabC(~ divlaw2 + attend3 + kids, gssD)

Cross tabulation Analysis

Description

Generates cross-tabulation of dependent and indendent variables, also creates a mosiac plot. Makes use of the crosstab function in the descr package.

Usage

xtp(
  data,
  y,
  x,
  w = NULL,
  ylab = NULL,
  xlab = NULL,
  main = NULL,
  digits = 2,
  chisq = FALSE
)

Arguments

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)

Value

A data frame of the cross tabulation results

Examples

library(poliscidata)
   
   xtp(gss, grass, attend3, wtss)

Cross tabulation Analysis with Chi-Squared Statistic

Description

This function makes use of the crosstab function from the descr package

Usage

xtp.chi2(data, y, x, w = NULL, digits = 1, prop.c = FALSE)

Arguments

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)

Value

Returns a data frame of cross tabulation results

Examples

library(poliscidata)
   
   xtp.chi2(gss, pornlaw, attend3, wtss)