POLI 279 MEASUREMENT THEORY
Eighth Assignment
Due 16 June 2006
#
#
# idealKeith2.r -- Implements Simon's IDEAL in R
#
rm(list=ls(all=TRUE))
#
library(rollcall)
load("C:/ucsd_homework_8/s104.Rdata")
rc <- rollcall(s104)
csts <- constrain.legis(rc,x=list("KENNEDY, ED"=c(-1,0),
"HELMS"=c(1,0),
"NUNN"=c(0,1)),d=2)
kpideal <- ideal(rc, d=2, priors=csts, startvals=csts, store.item=TRUE)
sumkpideal <- summary(kpideal,include.beta=TRUE)
#
xxzulu <- format(sumkpideal$x.quant, width=14, digits=8, nsmall=5, justify="left", scientific=FALSE)
write.table(xxzulu,"c:/ucsd_homework_8/tab_simon2_104x_2_quants.txt",sep=" ",row.names = TRUE, col.names = FALSE)
yyzulu <- format(sumkpideal$beta.quant, width=14, digits=8, nsmall=5, justify="left", scientific=FALSE)
write.table(yyzulu,"c:/ucsd_homework_8/tab_simon2_104beta_2_quants.txt",sep=" ",row.names = TRUE, col.names = FALSE)
#
xzulu <- format(kpideal$x, width=14, digits=8, nsmall=5, justify="left", scientific=FALSE)
write.table(xzulu,"c:/ucsd_homework_8/tab_simon2_104x_2.txt",sep=" ",row.names = FALSE, col.names = FALSE)
yzulu <- format(kpideal$beta, width=14, digits=8, nsmall=5, justify="left", scientific=FALSE)
write.table(yzulu,"c:/ucsd_homework_8/tab_simon2_104beta_2.txt",sep=" ",row.names = FALSE, col.names = FALSE)
#
This is essentially the same syntax as the one-dimensional version used in
Question 2 of Homework 7 only I have added some
code to try to get the output into a better format (with only limited success!). "HEFLINd1" " 0.019254228028273" "-0.079878095477918" " 0.111449363496424" "HEFLINd2" " 1.069517278759855" " 0.868838382775220" " 1.279517566620798" "SHELBYd1" " 1.403612009699809" " 1.252414688868802" " 1.544233634475914" "SHELBYd2" " 0.235868409260998" "-0.014348727379616" " 0.418772070489123" "MURKOWSKId1" " 1.840154516370265" " 1.678008774206082" " 2.053228284099351" "MURKOWSKId2" " 0.158078609318838" "-0.050730011968662" " 0.459155524940960" etc etc etc "KOHLd1" "-0.782482605860982" "-0.895595136215096" "-0.661654268440642" "KOHLd2" "-0.064279236064156" "-0.182146234642706" " 0.042390487275275" "SIMPSONd1" " 0.999489090974373" " 0.913485375624682" " 1.109224896347494" "SIMPSONd2" " 0.013901843849605" "-0.115694946041413" " 0.153525374932765" "THOMASd1" " 1.778886363041898" " 1.561671165023279" " 2.004710391501360" "THOMASd2" "-0.381946377022898" "-0.550476255976928" "-0.183191953276217"The first column of numbers is the Posterior Mean and the second and third are the 2.5% and 97.5% quantiles.
100 FORMAT(31X,2I4,30X,I1,37X,A2,3I2,413X,14I3,113X,I2,2X,5I1,28X,I1,
C 19X,I2,5I1,I2,5I1,5X,I2,5I1,I2,5I1,33X,I2,5I1,61X,I2,6X,I1,
C 123X,I2,7X,I2,688X,I1,20X,I1,63X,33I3)
The variables in the file are: I4 2004 Pre Case ID"
I4 2004 Post Case ID"
I1 sex (1=Man, 2=Woman)
A2 Postal abbreviation of state
I2 FIPS state code
I2 ICPSR state code
I2 Congressional District number
I3 Feeling Thermometer: GW Bush"
I3 Feeling Thermometer: John Kerry"
I3 Feeling Thermometer: Nader"
I3 Feeling Thermometer: Cheney"
I3 Feeling Thermometer: John Edwards"
I3 Feeling Thermometer: Laura Bush"
I3 Feeling Thermometer: Hillary Clinton"
I3 Feeling Thermometer: Bill Clinton"
I3 Feeling Thermometer: Colin Powell"
I3 Feeling Thermometer: John Ashcroft"
I3 Feeling Thermometer: John McCain"
I3 Feeling Thermometer: Democratic party"
I3 Feeling Thermometer: Republican party"
I3 Feeling Thermometer: Ronald Reagan"
I2 Liberal/conservative self-placement -7-point scale"
I1 Liberal/conservative Placement - GW Bush"
I1 Liberal/conservative Placement - Kerry"
I1 Liberal/conservative Placement - Nader"
I1 Liberal/conservative Placement - Dem Party"
I1 Liberal/conservative Placement - Rep party"
I1 Party ID (0=Strong Democrat -- 6=Strong Republican) {end of first line of format statement}
I2 Spending and Services - 7-point scale self-placement" C GOVT SHOULD PROVIDE MANY FEWER SERVICES -- GOVT SHOULD PROVIDE MANY MORE SERVICES
I1 Importance of spending/services issue to R"
I1 Spending and Services Placement: GW Bush"
I1 Spending and Services Placement: Kerry"
I1 Spending and Services Placement: Dem party"
I1 Spending and Services Placement: Rep party"
I2 Defense spending - 7-point scale self-placement" C GOVT SHOULD DECREASE DEFENSE SPENDING -- GOVT SHOULD INCREASE DEFENSE SPENDING
I1 Importance of defense spending issue to R"
I1 Defense spending scale: GW Bush placement"
I1 Defense spending scale: Kerry placement"
I1 Defense spending scale: Dem party placement"
I1 Defense spending scale: Rep party placement"
I2 Job and Good Standard of Living -scale self-placement" C GOVT SHOULD SEE TO JOBS AND STANDARD OF LIVING -- GOVT SHOULD LET EACH PERSON GET AHEAD ON OWN
I1 Importance of guaranteed jobs/standard living issue"
I1 Job and Good Standard of Living - GW Bush placement"
I1 Job and Good Standard of Living - Kerry placement"
I1 Job and Good Standard of Living - Dem party placement"
I1 Job and Good Standard of Living - Rep party placement"
I2 Government assistance to blacks-7 point scale self-pl" C GOVT SHOULD HELP BLACKS -- BLACKS SHOULD HELP THEMSELVES
I1 Importance of aid to blacks issue to R"
I1 Aid to blacks Placement: GW Bush"
I1 Aid to blacks Placement: Kerry"
I1 Aid to blacks Placement: Dem party"
I1 Aid to blacks Placement: Rep party"
I2 Women's role - 7-point scale self-placement" C WOMEN AND MEN SHOULD HAVE EQUAL ROLES -- A WOMAN'S PLACE IS IN THE HOME
I1 How important is the issue of women's equal role"
I1 Women's role - GW Bush placement"
I1 Women's role - Kerry placement"
I1 Women's role - Dem party placement"
I1 Women's role - Rep party placement"
I2 Age (18 - 90, 00, 98, 99 missing)
I1 Education (1=1-8, 2=9-11, 3=HS, 4=SC, 5=2YR degree, 6=BA, 7=Advanced, 0,8,9=Missing) {end of 2nd line of format statement}
I2 Income -- 01. None or less than $2,999
02. $3,000 - $4,999
03. $5,000 - $6,999
04. $7,000 - $8,999
05. $9,000 - 10,999
06. $11,000- $12,999
07. $13,000- $14,999
08. $15,000- $16,999
09. $17,000- $19,999
10. $20,000- $21,999
11. $22,000- $24,999
12. $25,000- $29,999
13. $30,000- $34,999
14. $35,000- $39,999
15. $40,000- $44,999
16. $45,000- $49,999
17. $50,000- $59,999
18. $60,000- $69,999
19. $70,000- $79,999
20. $80,000- $89,999
21. $90,000-$104,999
22. $105,000-$119,000
23. $120,000 and over
00 and > 24 missing
I2 Race 10=Black (12,13,14,15, mixed Race)
20=Asian (23,24,25, mixed Race)
30=Native American (34,35, mixed Race)
40=Hispanic (45, mixed Race)
50=White
70=Other
88, 89, and all else missing
I1 Voted?? (1=Voter, 2=Nonvoter Registered, 3=Nonvoter not Registered)
0,4,5,6,7,8,9 Missing
I1 Who Voted For (1=Kerry, 3=Bush, 5=Nader, 7,8,9,0=Missing)
I3 Feeling Thermometer: Hispanics (Hispanic-Americans)"
I3 Feeling Thermometer: Christian Fundamentalists"
I3 Feeling Thermometer: Catholics"
I3 Feeling Thermometer: Feminists"
I3 Feeling Thermometer: Federal Government in Washington"
I3 Feeling Thermometer: Jews"
I3 Feeling Thermometer: Liberals"
I3 Feeling Thermometer - middle class people"
I3 Feeling Thermometer: Labor Unions"
I3 Feeling Thermometer: Poor people"
I3 Feeling Thermometer: The Military"
I3 Feeling Thermometer: Big Business"
I3 Feeling Thermometer: People on welfare"
I3 Feeling Thermometer: Conservatives"
I3 Feeling Thermometer: working class people"
I3 Feeling Thermometer: Older people (the elderly)"
I3 Feeling Thermometer: environmentalists"
I3 Feeling Thermometer: U.S. Supreme Court"
I3 Feeling Thermometer: Gay Men and Lesbians"
I3 Feeling Thermometer: Asian Americans"
I3 Feeling Thermometer: Congress"
I3 Feeling Thermometer: Blacks"
I3 Feeling Thermometer - Southerners"
I3 Feeling Thermometer - men"
I3 Feeling Thermometer - young people"
I3 Feeling Thermometer - illegal immigrants"
I3 Feeling Thermometer - rich people"
I3 Feeling Thermometer - women"
I3 Feeling Thermometer - business people"
I3 Feeling Thermometer - the Catholic Church"
I3 Feeling Thermometer: Whites"
I3 Feeling Thermometer: Israel"
I3 Feeling Thermometer: Muslims" {end of 3rd line of format statement}
Here is what UNFOLD_ELEC2004.CTL looks like:
ELEC2004.DAT
14 2 2 10 0 0
1 1 0 4 3
.001 -0.02 2.0 2.0 1.5 0.0 100.0
(1X,4A1,18X,14F3.0)
777888889
BUSH
KERRY
NADER
CHENEY
EDWARDS
LBUSH
HCLINTON
BCLINTON
POWELL
ASHCROFT
MCCAIN
DEMPARTY
REPPARTY
REAGAN
Run MLSMU6.EXE and get the FORT.22 file. It should
look something like this: BUSH 0.7726 0.2609 160.6132 0.7489 1212.0000
KERRY -0.8656 0.0173 116.4007 0.6712 1212.0000
NADER 0.2228 -1.1055 235.2280 0.3139 1212.0000
CHENEY 0.9038 0.3055 162.0310 0.6294 1212.0000
EDWARDS -0.6827 -0.5858 209.5535 0.5072 1212.0000
LBUSH 0.5631 0.0922 164.3826 0.5649 1212.0000
HCLINTON -0.7768 0.2583 194.4952 0.6520 1212.0000
BCLINTON -0.7275 0.1688 186.9217 0.6771 1212.0000
POWELL 0.3977 -0.1706 179.2403 0.4747 1212.0000
ASHCROFT 0.7728 -0.8225 254.4220 0.4285 1212.0000
MCCAIN 0.2972 -0.7873 247.2073 0.4570 1212.0000
DEMPARTY -0.7286 0.1384 133.5416 0.5838 1212.0000
REPPARTY 0.7826 0.3116 132.1382 0.6533 1212.0000
REAGAN 0.3954 0.2187 213.8857 0.4808 1212.0000
1 -0.2800 -0.9550 7.6844 0.0104 14.0000
2 -0.3859 0.2049 0.9326 0.7621 14.0000
3 0.4892 0.0238 1.1449 0.7892 14.0000
4 -0.2549 0.2999 4.8528 0.1328 14.0000
5 0.8806 -0.0846 1.4779 0.9158 14.0000
etc etc etc