next up previous
Next: Example 3: 1992 pid Up: Programs for data from Previous: Example 1: 1996 pid

Example 2: 1996 pid, libcon, watchtv, spatial distances; make tables

year 1996

VARS
  CF0301
  CF0704
  CF0704A
  CF0724
  CF0803
  CF9088
  CF9096
;

# one-way frequency tables (always important to examine these)
xtable CF0301
xtable CF0704
xtable CF0704A
xtable CF0724
xtable CF0803
xtable CF9088
xtable CF9096

# get rid of unwanted value in party ID
pid <- CF0301;
pid <- ifelse(pid == 9, NA, pid);

# get rid of unwanted value in libcon self-placement
libcon <- CF0803;
libcon <- ifelse(libcon == 9, NA, libcon);

# presvote3 is three major party candidates only:  Dem (1), Rep (2), Third (3)
presvote3 <- CF0704;

# presvote is Dem (0) and Rep (1) candidates only
presvote <- CF0704A - 1;

# watchtv is how much watched campaign on TV: no (1), yes (2)
watchtv <- CF0724;

# one-way frequency tables
xtable pid
xtable libcon
xtable presvote3
xtable presvote
xtable watchtv

# crosstab of libcon given pid
xtable libcon pid

# crosstab of libcon given pid and watchtv
xtable libcon pid watchtv

# crosstab of three-party vote given pid
xtable presvote3 pid

# crosstab of two-party vote given pid
xtable presvote pid

# compute spatial model measure of difference between Dem and Rep candidates
demlibcon <- CF9088;
replibcon <- CF9096;
demdist <- abs(libcon-demlibcon);
repdist <- abs(libcon-replibcon);
distdiff <- demdist-repdist;

# one-way frequency table of party placements and spatial model distances
xtable demlibcon
xtable replibcon
xtable demdist
xtable repdist
xtable distdiff

# crosstab of two-party vote given spatial difference
xtable presvote distdiff


Walter Mebane
Mon Dec 3 06:15:33 EST 2001