Skip to content

Instantly share code, notes, and snippets.

@xmarquez
Last active December 12, 2015 09:39
Show Gist options
  • Save xmarquez/4753716 to your computer and use it in GitHub Desktop.
Save xmarquez/4753716 to your computer and use it in GitHub Desktop.
Code for post on the Normativeness of Democracy
# Auxiliary functions for working with various surveys
library(reshape2)
library(plyr)
library(foreign)
library(ggplot2)
construct_network <- function(adjacencyMatrix, threshold=0.5, vertexattributes=NULL) {
stopifnot(require(network))
adjacencyMatrix <- ifelse(adjacencyMatrix < threshold, 0, adjacencyMatrix)
net <- as.network(adjacencyMatrix,type="ajacency",directed=FALSE, ignore.eval= FALSE, names.eval="similarity")
for(i in names(vertexattributes)) {
#print(as.vector(vertexattributes[ ,i]))
set.vertex.attribute(net, i, as.vector(vertexattributes[ ,i]))
}
net
}
autoplot.network <- function(net, ..., mode="fruchtermanreingold",label="vertex.names",xlab="",ylab="",alpha=NULL, layout.par=NULL) {
stopifnot(require(network),require(sna))
d <- as.matrix.network.adjacency(net) # get sociomatrix
#plotcord <- data.frame(position_matrix)
layout.fun <- try(match.fun(paste("gplot.layout.", mode,
sep = "")), silent = TRUE)
if (class(layout.fun) == "try-error")
stop("Error in gplot: no layout function for mode ",
mode)
plotcord <- data.frame(layout.fun(d, layout.par=layout.par))
colnames(plotcord) = c("X1","X2")
edglist <- as.matrix.network.edgelist(net)
edges <- data.frame(plotcord[edglist[,1],], plotcord[edglist[,2],])
for(i in list.edge.attributes(net)) {
edges <- cbind(edges,get.edge.attribute(net$mel, i))
}
for(i in list.vertex.attributes(net)) {
plotcord <- cbind(plotcord,get.vertex.attribute(net, i))
}
names(plotcord)[3:length(names(plotcord))] <- list.vertex.attributes(net)
colnames(edges) <- c("X1","Y1","X2","Y2",list.edge.attributes(net))
map <- aes_string(x="X1",y="X2",...)
edgeMap <- aes_string(x="X1", y="Y1", xend = "X2", yend = "Y2",alpha=alpha)
labelMap <- aes_string(x="X1",y="X2",label=label)
pnet <- ggplot() +
geom_segment(mapping=edgeMap,
data=edges,color="grey") +
geom_point(mapping=map, data=plotcord) +
scale_x_continuous(breaks = NULL) + scale_y_continuous(breaks = NULL) +
geom_text(mapping=labelMap,data=plotcord,color="black") +labs(x=xlab,y=ylab)+theme_bw()
pnet
}
create_ccp_network <- function(data=ccp,vars=c("democ","assem","equal","express","freerel","assoc"),vertexattributes = c( "country.x", "cowcode", "systyear", "mean", "sd", "median", "pct025", "pct975", "cumMean"),threshold=0.5) {
stopifnot(require(cluster),require(network))
matrixData <- as.data.frame(data[ , vars])
matrixData <- colwise(as.numeric)(matrixData)
adjacencyMatrix <- as.matrix(daisy(matrixData, metric="gower"))
dimnames(adjacencyMatrix)[[1]] <- paste(data[ , vertexattributes[1]])
dimnames(adjacencyMatrix)[[2]] <- paste(data[ , vertexattributes[1]])
adjacencyMatrix <- 1 - adjacencyMatrix
adjacencyMatrix <- ifelse(adjacencyMatrix < threshold, 0, adjacencyMatrix)
net <- as.network(adjacencyMatrix,type="adjacency",directed=FALSE, ignore.eval= FALSE, names.eval="similarity")
for(i in vertexattributes) {
set.vertex.attribute(net, i, as.vector(data[ ,i]))
}
#print(net)
net
}
plot_ccp_network <- function(data=ccp,vars=c("democ","assem","equal","express","freerel","assoc"),title="",threshold=0.5, color="mean",size="cumMean",vertexattributes=c( "cowcode", "country.x", "systyear", "mean", "sd", "median", "pct025", "pct975", "cumMean"), label=expression(paste(vertex.names,systyear))) {
stopifnot(require(ggplot2))
net <- create_ccp_network(data=data,vars=vars,threshold=threshold, vertexattributes=vertexattributes)
autoplot(net, color=color,size=size,alpha="similarity",label=label) + labs(alpha="Degree of similarity",color="Mean UDS score \nin 2006", size="Cumulative UDS score\nas of 2006", title=title)
}
find_communities <- function(vars=c("democ","assem","equal","express","freerel","assoc"),data=ccp,threshold=0) {
stopifnot(require(igraph), require(cluster))
adjacencyMatrix <- as.matrix(daisy(as.data.frame(data[ ,vars])))
adjacencyMatrix <- 1 - adjacencyMatrix
adjacencyMatrix <- ifelse(adjacencyMatrix < threshold, 0, adjacencyMatrix)
dimnames(adjacencyMatrix)[[1]] <- paste(data$country.x)
dimnames(adjacencyMatrix)[[2]] <- paste(data$country.y)
g <- graph.adjacency(adjacencyMatrix,mode="undirected",weighted=TRUE)
groups <- fastgreedy.community(g)
groups
}
extract_row <- function(df, n=1) {
df[sample(nrow(df), n), ]
}
compare_from_subset2 <- function(data=data.4,vars=names(data.4[7:295]), subsetVar = "meanCut", n = 2) {
stopifnot(require(cluster),require(plyr))
d <- ddply(data, c(subsetVar), extract_row,n=n)
# d <- d[ , c("country.x",vars,subsetVar) ]
# print(d)
d <- d[ , vars ]
distMat <- as.matrix(1-daisy(d, metric="gower"))
dimnames(distMat)[[1]] <- rep(levels(data[ , subsetVar]),each=n)
dimnames(distMat)[[2]] <- rep(levels(data[ , subsetVar]),each=n)
distMat
}
calculate_similarities_3 <- function(data=data.4,vars=liberalDemVars, n = 100, subsetVar="meanCut", FUN="mean") {
meanV <- replicate(n, compare_from_subset2(data=data,vars=vars, subsetVar=subsetVar))
apply(meanV, c(1,2), FUN=FUN)
}
create_network2 <- function(adjacencyMatrix,threshold=0.5) {
stopifnot(require(network))
adjacencyMatrix <- 1 - adjacencyMatrix
adjacencyMatrix <- ifelse(adjacencyMatrix < threshold, 0, adjacencyMatrix)
net <- as.network(adjacencyMatrix,type="adjacency",directed=FALSE, ignore.eval= FALSE, names.eval="similarity")
#print(net)
net
}
plot.matrix <- function(d, ..., events.vars, mode="fruchtermanreingold",xlab="",ylab="",alpha=NULL, layout.par=NULL,actors.labels="countries",events.labels="characteristics", eventAttributes) {
stopifnot(require(network),require(sna),require(ggplot2))
e <- as.matrix(d[ , events.vars])
e <- ifelse(is.na(e),0,1)
net <- as.network(e, bipartite="TRUE")
mapping <- list(...)
mapping[sapply(mapping, is.null)] <- "NULL"
#print(mapping)
parsed <- lapply(mapping, function(x) parse(text = x)[[1]])
#print(parsed)
actorAttributes <- d[ , -events.vars ]
#print(head(actorAttributes))
#print(head(eventAttributes))
vertex.attr <- rbind(actorAttributes,eventAttributes)
plotcord <- data.frame(gplot.layout.fruchtermanreingold(net, layout.par=layout.par))
colnames(plotcord) = c("X1","X2")
plotcord <- cbind(plotcord,vertex.attr)
edglist <- as.matrix.network.edgelist(net)
edges <- data.frame(plotcord[edglist[,1],], plotcord[edglist[,2],])
colnames(edges) <- c("X1","Y1",paste("events",names(vertex.attr),sep=""),"X2","Y2",paste("actors",names(vertex.attr),sep=""))
#print(head(edges))
map <- aes_string(x="X1",y="X2",...)
labelMap <- aes_string(x="X1",y="X2",...)
edgeMap <- aes_string(x="X1", y="Y1", xend = "X2", yend = "Y2")
pnet <- ggplot() +
geom_segment(mapping=edgeMap,
data=edges,color="lightgrey") +
geom_point(mapping=map, data=plotcord) +
scale_x_continuous(breaks = NULL) + scale_y_continuous(breaks = NULL) +
geom_text(mapping=labelMap,data=plotcord,color="black") +labs(x=xlab,y=ylab)+theme_bw()
pnet
}
cowcodes2 cowcode2 ccdcodelet ccdcodenum wdicode imf_code politycode bankscode dpicode uncode un_region un_region_name un_continent un_continent_name aclp_region ccode
700 700 AFG 1 AFG 512 700 10 AFG 4 34 Southern Asia 142 Asia 9 700
339 339 ALB 3 ALB 914 339 20 ALB 8 39 Southern Europe 150 Europe 9 339
615 615 DZA 50 DZA 612 615 30 DZA 12 15 Northern Africa 2 Africa 6 615
540 540 AGO 2 AGO 614 540 35 AGO 24 17 Middle Africa 2 Africa 1 540
58 58 ATG 8 ATG 311 58 37 ATG 28 29 Caribbean 19 Americas 8 58
160 160 ARG 5 ARG 213 160 40 ARG 32 5 South America 19 Americas 7 160
371 371 ARM 6 ARM 911 371 45 ARM 51 145 Western Asia 142 Asia 9 371
900 900 AUS 9 AUS 193 900 50 AUS 36 53 Australia and New Zealand 9 Oceania 10 900
305 305 AUT 10 AUT 122 305 61 AUT 40 155 Western Europe 150 Europe 10 305
373 373 AZE 11 AZE 912 373 64 AZE 31 145 Western Asia 142 Asia 9 373
31 31 BHS 19 BHS 313 31 69 BHS 44 29 Caribbean 19 Americas 8 31
692 692 BHR 18 BHR 419 692 65 BHR 48 145 Western Asia 142 Asia 11 692
771 771 BGD 16 BGD 513 771 901 BGD 50 34 Southern Asia 142 Asia 2 771
53 53 BRB 25 BRB 316 53 70 BRB 52 29 Caribbean 19 Americas 8 53
370 370 BLR 21 BLR 913 370 75 BLR 112 151 Eastern Europe 150 Europe 9 370
211 211 BEL 13 BEL 124 211 80 BEL 56 155 Western Europe 150 Europe 10 211
80 80 BLZ 22 BLZ 339 80 90 BLZ 84 13 Central America 19 Americas 8 80
434 434 BEN 14 BEN 638 434 310 BEN 204 11 Western Africa 2 Africa 1 434
760 760 BTN 27 BTN 514 760 66 BTN 64 34 Southern Asia 142 Asia 2 760
145 145 BOL 23 BOL 218 145 100 BOL 68 5 South America 19 Americas 7 145
346 346 BIH 20 BIH 963 346 107 BIH 70 39 Southern Europe 150 Europe 9 346
571 571 BWA 28 BWA 616 571 110 BWA 72 18 Southern Africa 2 Africa 1 571
140 140 BRA 24 BRA 223 140 120 BRA 76 5 South America 19 Americas 7 140
835 835 BRN 26 BRN 516 835 125 BRN 96 35 South-Eastern Asia 142 Asia 4 835
355 355 BGR 17 BGR 918 355 130 BGR 100 151 Eastern Europe 150 Europe 9 355
439 439 BFA 15 BFA 748 439 1230 BFA 854 11 Western Africa 2 Africa 1 439
516 516 BDI 12 BDI 618 516 150 BDI 108 14 Eastern Africa 2 Africa 1 516
811 811 KHM 93 KHM 522 811 160 KHM 116 35 South-Eastern Asia 142 Asia 4 811
471 471 CMR 35 CMR 622 471 170 CMR 120 17 Middle Africa 2 Africa 1 471
20 20 CAN 30 CAN 156 20 180 CAN 124 21 Northern America 19 Americas 10 20
402 402 CPV 39 CPV 624 402 185 CPV 132 11 Western Africa 2 Africa 1 402
482 482 CAF 29 CAF 626 482 190 CAF 140 17 Middle Africa 2 Africa 1 482
483 483 TCD 168 TCD 628 483 210 TCD 148 17 Middle Africa 2 Africa 1 483
155 155 CHL 32 CHL 228 155 220 CHL 152 5 South America 19 Americas 7 155
710 710 CHN 33 CHN 924 710 230 CHN 156 30 Eastern Asia 142 Asia 3 710
100 100 COL 37 COL 233 100 240 COL 170 5 South America 19 Americas 7 100
581 581 COM 38 COM 632 581 245 COM 174 14 Eastern Africa 2 Africa 1 581
484 484 COG 36 COG 634 484 250 COG 178 17 Middle Africa 2 Africa 1 484
94 94 CRI 40 CRI 238 94 270 CRI 188 13 Central America 19 Americas 7 94
437 437 CIV 34 CIV 662 437 580 CIV 384 11 Western Africa 2 Africa 1 437
344 344 HRV 76 HRV 960 344 275 HRV 191 39 Southern Europe 150 Europe 9 344
40 40 CUB 41 CUB 928 40 280 CUB 192 29 Caribbean 19 Americas 7 40
352 352 CYP 42 CYP 423 352 290 CYP 196 145 Western Asia 142 Asia 10 352
316 316 CZE 43 CZE 935 316 301 CZE 203 151 Eastern Europe 150 Europe 9 316
390 390 DNK 48 DNK 128 390 320 DNK 208 154 Northern Europe 150 Europe 10 390
522 522 DJI 46 DJI 611 522 325 DJI 262 14 Eastern Africa 2 Africa 1 522
54 54 DMA 47 DMA 321 54 327 DMA 212 29 Caribbean 19 Americas 8 54
42 42 DOM 49 DOM 243 42 330 DOM 214 29 Caribbean 19 Americas 7 42
860 NA NA NA NA NA NA NA NA NA NA South-Eastern Asia NA Asia NA 860
130 130 ECU 51 ECU 248 130 340 ECU 218 5 South America 19 Americas 7 130
651 651 EGY 52 EGY 469 651 NA EGY 818 15 Northern Africa 2 Africa 6 651
92 92 SLV 155 SLV 253 92 350 SLV 222 13 Central America 19 Americas 7 92
411 411 GNQ 70 GNQ 642 411 355 GNQ 226 17 Middle Africa 2 Africa 1 411
531 531 ERI 53 ERI 643 531 375 ERI 232 14 Eastern Africa 2 Africa 1 531
366 366 EST 55 EST 939 366 360 EST 233 154 Northern Europe 150 Europe 9 366
530 530 ETH 56 ETH 644 530 370 ET1 231 14 Eastern Africa 2 Africa 1 530
950 950 FJI 59 FJI 819 950 1216 FJI 242 54 Melanesia 9 Oceania 5 950
375 375 FIN 58 FIN 172 375 380 FIN 246 154 Northern Europe 150 Europe 10 375
220 220 FRA 60 FRA 132 220 390 FRA 250 155 Western Europe 150 Europe 10 220
481 481 GAB 62 GAB 646 481 400 GAB 266 17 Middle Africa 2 Africa 1 481
420 420 GMB 68 GMB 648 420 410 GMB 270 11 Western Africa 2 Africa 1 420
372 372 GEO 65 GEO 915 372 415 GEO 268 145 Western Asia 142 Asia 9 372
255 255 DEU 45 DEU 134 255 420 DEU 276 155 Western Europe 150 Europe 10 255
452 452 GHA 66 GHA 652 452 440 GHA 288 11 Western Africa 2 Africa 1 452
350 350 GRC 71 GRC 174 350 450 GRC 300 39 Southern Europe 150 Europe 10 350
55 55 GRD 72 GRD 328 55 455 GRD 308 29 Caribbean 19 Americas 8 55
90 90 GTM 73 GTM 258 90 460 GTM 320 13 Central America 19 Americas 7 90
438 438 GIN 67 GIN 656 438 470 GIN 324 11 Western Africa 2 Africa 1 438
404 404 GNB 69 GNB 654 404 475 GNB 624 11 Western Africa 2 Africa 1 404
110 110 GUY 74 GUY 336 110 480 GUY 328 5 South America 19 Americas 8 110
41 41 HTI 77 HTI 263 41 490 HTI 332 29 Caribbean 19 Americas 8 41
91 91 HND 75 HND 268 91 500 HND 340 13 Central America 19 Americas 7 91
310 310 HUN 78 HUN 944 310 62 HUN 348 151 Eastern Europe 150 Europe 9 310
395 395 ISL 84 ISL 176 395 510 ISL 352 154 Northern Europe 150 Europe 10 395
750 750 IND 80 IND 534 750 520 IND 356 34 Southern Asia 142 Asia 2 750
850 850 IDN 79 IDN 536 850 530 IDN 360 35 South-Eastern Asia 142 Asia 4 850
630 630 IRN 82 IRN 429 630 540 IRN 364 34 Southern Asia 142 Asia 6 630
645 645 IRQ 83 IRQ 433 645 550 IRQ 368 145 Western Asia 142 Asia 6 645
205 205 IRL 81 IRL 178 205 1212 IRL 372 154 Northern Europe 150 Europe 10 205
666 666 ISR 85 ISR 436 666 560 ISR 376 145 Western Asia 142 Asia 6 666
325 325 ITA 86 ITA 136 325 570 ITA 380 39 Southern Europe 150 Europe 10 325
51 51 JAM 87 JAM 343 51 590 JAM 388 29 Caribbean 19 Americas 8 51
740 740 JPN 89 JPN 158 740 600 JPN 392 30 Eastern Asia 142 Asia 10 740
663 663 JOR 88 JOR 439 663 610 JOR 400 145 Western Asia 142 Asia 6 663
705 705 KAZ 90 KAZ 916 705 615 KAZ 398 143 Central Asia 142 Asia 9 705
501 501 KEN 91 KEN 664 501 620 KEN 404 14 Eastern Africa 2 Africa 1 501
946 946 KIR 94 KIR 826 946 625 KIR 296 57 Micronesia 9 Oceania 5 946
731 731 PRK 142 PRK NA 731 631 PRK 408 30 Eastern Asia 142 Asia 3 731
732 732 KOR 96 KOR 542 732 632 KOR 410 30 Eastern Asia 142 Asia 3 732
690 690 KWT 97 KWT 443 690 640 KWT 414 145 Western Asia 142 Asia 11 690
703 703 KGZ 92 KGZ 917 703 645 KGZ 417 143 Central Asia 142 Asia 9 703
812 812 LAO 98 LAO 544 812 650 LAO 418 35 South-Eastern Asia 142 Asia 4 812
367 367 LVA 108 LVA 941 367 660 LVA 428 154 Northern Europe 150 Europe 9 367
660 660 LBN 99 LBN 446 660 670 LBN 422 145 Western Asia 142 Asia 6 660
570 570 LSO 105 LSO 666 570 680 LSO 426 18 Southern Africa 2 Africa 1 570
450 450 LBR 100 LBR 668 450 690 LBR 430 11 Western Africa 2 Africa 1 450
620 620 LBY 101 LBY 672 620 700 LBY 434 15 Northern Africa 2 Africa 11 620
368 368 LTU 106 LTU 946 368 710 LTU 440 154 Northern Europe 150 Europe 9 368
212 212 LUX 107 LUX 137 212 720 LUX 442 155 Western Europe 150 Europe 10 212
343 343 MKD 115 MKD 962 343 725 MKD 807 39 Southern Europe 150 Europe 9 343
580 580 MDG 111 MDG 674 580 730 MDG 450 14 Eastern Africa 2 Africa 1 580
553 553 MWI 123 MWI 676 553 740 MWI 454 14 Eastern Africa 2 Africa 1 553
820 820 MYS 124 MYS 548 820 750 MYS 458 35 South-Eastern Asia 142 Asia 4 820
781 781 MDV 112 MDV 556 781 760 MDV 462 34 Southern Asia 142 Asia 2 781
432 432 MLI 116 MLI 678 432 770 MLI 466 11 Western Africa 2 Africa 1 432
338 338 MLT 117 MLT 181 338 780 MLT 470 39 Southern Europe 150 Europe 10 338
983 983 MHL 114 MHL 867 983 785 MHL 584 57 Micronesia 9 Oceania 5 983
435 435 MRT 121 MRT 682 435 790 MRT 478 11 Western Africa 2 Africa 1 435
590 590 MUS 122 MUS 684 590 800 MUS 480 14 Eastern Africa 2 Africa 1 590
70 70 MEX 113 MEX 273 70 810 MEX 484 13 Central America 19 Americas 7 70
987 987 FSN 61 FSM 868 987 812 FSM 583 57 Micronesia 9 Oceania 5 987
359 359 MDA 110 MDA 921 359 813 MDA 498 151 Eastern Europe 150 Europe 9 359
712 712 MNG 119 MNG 948 712 820 MNG 496 30 Eastern Asia 142 Asia 3 712
600 600 MAR 109 MAR 686 600 830 MAR 504 15 Northern Africa 2 Africa 6 600
541 541 MOZ 120 MOZ 688 541 835 MOZ 508 14 Eastern Africa 2 Africa 1 541
775 775 MMR 118 MMR 518 775 140 MMR 104 35 South-Eastern Asia 142 Asia 4 775
565 565 NAM 125 NAM 728 565 837 NAM 516 18 Southern Africa 2 Africa 1 565
970 970 NUR 132 836 970 NA 520 57 Micronesia 9 Oceania 5 970
790 790 NPL 131 NPL 558 790 840 NPL 524 34 Southern Asia 142 Asia 2 790
210 210 NLD 129 NLD 138 210 850 NLD 528 155 Western Europe 150 Europe 10 210
920 920 NZL 133 NZL 196 920 860 NZL 554 53 Australia and New Zealand 9 Oceania 10 920
93 93 NIC 128 NIC 278 93 870 NIC 558 13 Central America 19 Americas 7 93
436 436 NER 126 NER 692 436 880 NER 562 11 Western Africa 2 Africa 1 436
475 475 NGA 127 NGA 694 475 890 NGA 566 11 Western Africa 2 Africa 1 475
385 385 NOR 130 NOR 142 385 1091 NOR 578 154 Northern Europe 150 Europe 10 385
698 698 OMN 134 OMN 449 698 895 OMN 512 145 Western Asia 142 Asia 11 698
770 770 PAK 135 PAK 564 769 900 PAK 586 34 Southern Asia 142 Asia 2 770
770 770 PAK 135 PAK 564 770 900 PAK 586 34 Southern Asia 142 Asia 2 770
986 986 PLU 139 PLW 565 986 905 PLW 585 57 Micronesia 9 Oceania 5 986
95 95 PAN 136 PAN 283 95 910 PAN 591 13 Central America 19 Americas 7 95
910 910 PNG 140 PNG 853 910 915 PNG 598 54 Melanesia 9 Oceania 5 910
150 150 PRY 144 PRY 288 150 920 PRY 600 5 South America 19 Americas 7 150
135 135 PER 137 PER 293 135 930 PER 604 5 South America 19 Americas 7 135
840 840 PHL 138 PHL 566 840 940 PHL 608 35 South-Eastern Asia 142 Asia 4 840
290 290 POL 141 POL 964 290 950 POL 616 151 Eastern Europe 150 Europe 9 290
235 235 PRT 143 PRT 182 235 960 PRT 620 39 Southern Europe 150 Europe 10 235
694 694 QAT 145 QAT 453 694 965 QAT 634 145 Western Asia 142 Asia 11 694
360 360 ROM 146 ROM 968 360 970 ROM 642 151 Eastern Europe 150 Europe 9 360
365 374 RUS 147 RUS 922 365 1190 RUS 643 151 Eastern Europe 150 Europe 9 365
517 517 RWA 148 RWA 714 517 980 RWA 646 14 Eastern Africa 2 Africa 1 517
990 990 WSM 190 WSM 862 990 1270 WSM 882 61 Polynesia 9 Oceania 5 990
403 403 STP 158 STP 716 403 985 STP 678 17 Middle Africa 2 Africa 1 403
670 670 SAU 149 SAU 456 670 990 SAU 682 145 Western Asia 142 Asia 11 670
433 433 SEN 151 SEN 722 433 1000 SEN 686 11 Western Africa 2 Africa 1 433
345 347 SEN 202 YUG 965 347 1290 YUG NA 39 Southern Europe 150 Europe 9 345
591 591 SYC 165 SYC 718 591 1005 SYC 690 14 Eastern Africa 2 Africa 1 591
451 451 SLE 154 SLE 724 451 1010 SLE 694 11 Western Africa 2 Africa 1 451
830 830 SGP 152 SGP 576 830 1020 SGP 702 35 South-Eastern Asia 142 Asia 4 830
317 317 SVK 160 SVK 936 317 302 SVK 703 151 Eastern Europe 150 Europe 9 317
349 349 SVN 161 SVN 961 349 1023 SVN 705 39 Southern Europe 150 Europe 9 349
940 940 SLB 153 SLB 813 940 1025 SLB 90 54 Melanesia 9 Oceania 5 940
520 520 SOM 157 SOM 726 520 1030 SOM 706 14 Eastern Africa 2 Africa 1 520
560 560 ZAF 195 ZAF 199 560 1040 ZAF 710 18 Southern Africa 2 Africa 1 560
230 230 ESP 54 ESP 184 230 1060 ESP 724 39 Southern Europe 150 Europe 10 230
780 780 LKA 104 LKA 524 780 200 LKA 144 34 Southern Asia 142 Asia 2 780
60 60 KNA 95 KNA 361 60 1063 KNA 659 29 Caribbean 19 Americas 8 60
56 56 LCA 102 LCA 362 56 NA LCA 662 29 Caribbean 19 Americas 8 56
57 57 VCT 184 VCT 364 57 1065 VCT 670 29 Caribbean 19 Americas 8 57
625 625 SDN 150 SDN 732 625 1070 SDN 736 15 Northern Africa 2 Africa 1 625
115 115 SUR 159 SUR 366 115 1075 SUR 740 5 South America 19 Americas 8 115
572 572 SWZ 164 SWZ 734 572 1080 SWZ 748 18 Southern Africa 2 Africa 1 572
380 380 SWE 163 SWE 144 380 1092 SWE 752 154 Northern Europe 150 Europe 10 380
225 225 CHE 31 CHE 146 225 1100 CHE 756 155 Western Europe 150 Europe 10 225
652 652 SYR 166 SYR 463 652 1110 SYR 760 145 Western Asia 142 Asia 6 652
713 713 TAW 167 528 713 231 TWN NA NA Eastern Asia 142 Asia 3 713
702 702 TJK 171 TJK 923 702 1115 TJK 762 143 Central Asia 142 Asia 9 702
510 510 TZA 178 TZA 738 510 1120 TZA 834 14 Eastern Africa 2 Africa 1 510
800 800 THA 170 THA 578 800 1130 THA 764 35 South-Eastern Asia 142 Asia 4 800
461 461 TGO 169 TGO 742 461 1140 TGO 768 11 Western Africa 2 Africa 1 461
955 955 TON 173 TON 866 955 1215 TON 776 61 Polynesia 9 Oceania 5 955
52 52 TTO 174 TTO 369 52 1150 TTO 780 29 Caribbean 19 Americas 8 52
616 616 TUN 175 TUN 744 616 1160 TUN 788 15 Northern Africa 2 Africa 6 616
640 640 TUR 176 TUR 186 640 1170 TUR 792 145 Western Asia 142 Asia 6 640
701 701 TKM 172 TKM 925 701 1172 TKM 795 143 Central Asia 142 Asia 9 701
947 947 SMA 156 TUV 135 947 982 TUV 798 61 Polynesia 9 Oceania 5 947
500 500 UGA 179 UGA 746 500 1180 UGA 800 14 Eastern Africa 2 Africa 1 500
369 369 UKR 180 UKR 926 369 1183 UKR 804 151 Eastern Europe 150 Europe 9 369
696 696 ARE 4 ARE 466 696 NA ARE 784 145 Western Asia 142 Asia 11 696
200 200 GBR 63 GBR 112 200 1210 GBR 826 154 Northern Europe 150 Europe 10 200
2 2 USA 182 USA 111 2 1220 USA 840 21 Northern America 19 Americas 10 2
165 165 URY 181 URY 298 165 1240 URY 858 5 South America 19 Americas 7 165
704 704 UZB 183 UZB 927 704 1241 UZB 860 143 Central Asia 142 Asia 9 704
935 935 VUT 189 VUT 846 935 1243 VUT 548 54 Melanesia 9 Oceania 5 935
101 101 VEN 185 VEN 299 101 1250 VEN 862 5 South America 19 Americas 7 101
816 818 VNM 186 VNM 582 818 1262 VNM 704 35 South-Eastern Asia 142 Asia 4 816
679 679 YEM 191 YEM 474 679 1280 YEM 887 145 Western Asia 142 Asia 6 679
490 490 ZAR 196 ZAR 636 490 260 ZAR 180 17 Middle Africa 2 Africa 1 490
551 551 ZMB 197 ZMB 754 551 1300 ZMB 894 14 Eastern Africa 2 Africa 1 551
552 552 ZWE 198 ZWE 698 552 1214 ZWE 716 14 Eastern Africa 2 Africa 1 552
country cowcode lon lat lonmin lonmax latmin latmax
United States Of America 2 -95.712891 37.09024 -124.39 -66.94 18.9110642 71.389888
Canada 20 -106.346771 56.130366 -142 -50 41.6765559 83.115061
Bahamas 31 -77.39628 25.03428 -79.5377959 -72.7120686 20.9121311 27.263362
Cuba 40 -77.781167 21.521757 -85.071256 -74.1322231 19.8258994 23.2767521
Haiti 41 -72.285215 18.971187 -74.4809103 -71.621754 18.0220783 20.0896142
Dominican Republic 42 -70.162651 18.735693 -72.0075099 -68.3234068 17.4700909 19.9317185
Jamaica 51 -77.297508 18.109581 -78.3688461 -76.183159 17.7057243 18.5253104
Trinidad And Tobago 52 -61.222503 10.691803 -61.9310689 -60.4924177 10.0431694 11.3625357
Barbados 53 -59.543198 13.193887 -59.6510303 -59.4200975 13.0449995 13.335126
Dominica 54 -61.370976 15.414999 -61.4798301 -61.2403035 15.207682 15.6400639
Grenada 55 -61.679 12.1165 -61.8027279 -61.3779974 11.9848728 12.5301829
St. Lucia 56 -60.983333 14.016667 NA NA NA NA
St. Vincent And The Grenadines 57 -61.196251 13.2533835 -61.4610171 -61.1134244 12.5326587 13.3842132
Antigua And Barbuda 58 -61.796428 17.060816 -62.347657 -61.6574192 16.9325319 17.729564
St. Kitts And Nevis 60 -62.782998 17.357822 -62.8646171 -62.5396943 17.094157 17.4182012
Mexico 70 -102.552784 23.634501 -118.364313 -86.7105711 14.534548 32.7187631
Belize 80 -88.49765 17.189877 -89.2275879 -87.4537253 15.8856189 18.4959419
United Provinces Of Central America 89 -90.230759 15.783471 NA NA NA NA
Guatemala 90 -90.230759 15.783471 -92.2318359 -88.2256154 13.7400214 17.8157114
Honduras 91 -86.241905 15.199999 -89.355148 -83.1360769 12.9842246 17.4171037
El Salvador 92 -88.89653 13.794185 -90.1268106 -87.6837516 13.1554312 14.4505567
Nicaragua 93 -85.207229 12.865416 -87.6910686 -82.5920716 10.7080549 15.0302755
Costa Rica 94 -83.753428 9.748917 -87.0945131 -82.5526571 5.4991534 11.2196808
Panama 95 -80.782127 8.537981 -83.0522411 -77.158488 7.2035564 9.647779
Great Colombia 99 -74.297333 4.570868 NA NA NA NA
Colombia 100 -74.297333 4.570868 -81.7359299 -66.851923 -4.22711 13.3973501
Venezuela 101 -66.58973 6.42375 -73.3515581 -59.805666 0.6475291 12.2019032
Guyana 110 -58.93018 4.860416 -61.414905 -56.49112 1.164724 8.5482551
Surinam 115 -56.027783 3.919305 -58.0705059 -53.9510244 1.837306 6.0092832
Ecuador 130 -78.183406 -1.831239 -92.0107728 -75.188794 -5.0143511 1.6647727
Peru 135 -75.015152 -9.189967 -81.3285041 -68.652329 -18.3515803 -0.038777
Brazil 140 -51.92528 -14.235004 -73.982817 -34.7929077 -33.7517528 5.2716019
Bolivia 145 -63.588653 -16.290154 -69.64499 -57.453803 -22.8980899 -9.669323
Paraguay 150 -58.443832 -23.442503 -62.6380511 -54.258562 -27.5883343 -19.2877065
Chile 155 -71.542969 -35.675147 -109.454801 -66.4182016 -55.9797808 -17.4983293
Argentina 160 -63.616672 -38.416097 -73.5603601 -53.637481 -55.0577146 -21.7808136
Uruguay 165 -55.765835 -32.522779 -58.43915 -53.0779286 -34.9733882 -30.0852149
Ireland 205 -8.24389 53.41291 -10.66958 -5.9947001 51.4219377 55.3885
Netherlands 210 5.291266 52.132633 3.3316 7.2275102 50.7503837 53.6756
Belgium 211 4.469936 50.503887 2.5449406 6.4081241 49.497013 51.5051449
Luxembourg 212 6.129583 49.815273 5.7356699 6.5309701 49.447779 50.18282
France 220 2.213749 46.227638 -5.1412279 9.5600678 41.3423276 51.0889618
Monaco 221 7.4246158 43.7384176 7.4091049 7.4397977 43.7247428 43.7519029
Liechtenstein 223 9.555373 47.166 9.47162 9.6356501 47.04829 47.2705467
Switzerland 225 8.227512 46.818188 5.95608 10.4923401 45.81792 47.8084546
Spain 230 -3.74922 40.463667 -18.1696379 5.098 27.6377894 45.244
Andorra 232 1.601554 42.546245 1.4087052 1.786639 42.4287488 42.655791
Portugal 235 -8.224454 39.399872 -31.275158 -6.1902091 32.40374 42.1542048
Hanover 240 9.716667 52.366667 NA NA NA NA
Bavaria 245 11.566667 48.133333 NA NA NA NA
Germany (Prussia) 255 13.398889 52.500556 NA NA NA NA
German Federal Republic 260 7.099722 50.733889 NA NA NA NA
German Democratic Republic 265 13.398889 52.500556 NA NA NA NA
Baden 267 8.4 49.016667 NA NA NA NA
Saxony 269 13.733333 51.033333 NA NA NA NA
Wurttemberg 271 9.179444 48.778611 NA NA NA NA
Hesse-Kassel (Electoral) 273 9.5 51.316667 NA NA NA NA
Hesse-Darmstadt (Ducal) 275 8.65 49.866667 NA NA NA NA
Mecklenburg-Schwerin 280 11.416667 53.633333 NA NA NA NA
Poland 290 19.145136 51.919438 14.1228641 24.1458931 49.0020252 54.8358123
Austria-Hungary 300 16.35 48.2 NA NA NA NA
Austria 305 14.550072 47.516231 9.5307834 17.1606862 46.3723358 49.0206081
Hungary 310 19.503304 47.162494 16.1133863 22.897379 45.7370889 48.585234
Czechoslovakia 315 14.416667 50.083333 NA NA NA NA
Czech Republic 316 15.472962 49.817492 12.090589 18.8592361 48.5518081 51.0557185
Slovakia 317 19.699024 48.669026 16.8331821 22.5592818 47.731159 49.6138051
Italy/Sardinia 325 8.9800261 40.0861417 8.1310155 9.8290368 38.8590772 41.3132062
Papal States 327 12.602778 42.821111 NA NA NA NA
Two Sicilies 329 14.258333 40.845 NA NA NA NA
San Marino 331 12.466667 43.933333 NA NA NA NA
Modena 332 10.933333 44.65 NA NA NA NA
Parma 335 10.333333 44.8 NA NA NA NA
Tuscany 337 11.25 43.783333 NA NA NA NA
Malta 338 14.375416 35.937496 14.1835259 14.5755001 35.805811 36.0821467
Albania 339 20.168331 41.153332 19.2639041 21.0572394 39.6447296 42.6610819
Serbia 340 20.466667 44.8 NA NA NA NA
Montenegro 341 19.37439 42.708678 18.4337921 20.3577649 41.8497308 43.558743
Macedonia (Former Yugoslav Republic Of) 343 21.7 41.6 NA NA NA NA
Croatia 344 15.2 45.1 13.4896912 19.4480523 42.3922652 46.5552234
Yugoslavia (Serbia) 345 20 44 NA NA NA NA
Bosnia-Herzegovina 346 17.679076 43.915886 15.7223665 19.621935 42.5564068 45.2766262
Slovenia 349 14.995463 46.151241 13.3753355 16.5966857 45.4216739 46.876659
Greece 350 21.824312 39.074208 19.3724227 29.6451476 34.8010211 41.7490577
Cyprus 352 33.429859 35.126413 32.2687076 34.6045 34.632303 35.7071999
Bulgaria 355 25.48583 42.733883 22.3573446 28.6092632 41.2354469 44.2151244
Moldova 359 28.369885 47.411631 26.6168559 30.162538 45.466904 48.491944
Romania 360 24.96676 45.943161 20.2617593 29.7571015 43.6186193 48.265274
Russia (Soviet Union) 365 51.3635194 51.2206431 51.347512 51.3795268 51.2136541 51.2276311
Estonia 366 25.013607 58.595272 21.7723826 28.2089248 57.509316 59.7003026
Latvia 367 24.603189 56.879635 20.9623429 28.2414029 55.6747769 58.0855688
Lithuania 368 23.881275 55.169438 20.9494105 26.8355913 53.8968787 56.4503209
Ukraine 369 31.16558 48.379433 22.1371589 40.2285809 44.386463 52.379581
Belarus (Byelorussia) 370 27.953389 53.709807 23.1783377 32.7768202 51.262011 56.1718719
Armenia 371 45.038189 40.069099 43.4472118 46.634222 38.840244 41.300993
Georgia 372 43.356892 42.315407 40.0066113 46.736119 41.054942 43.586627
Azerbaijan 373 47.576927 40.143105 44.7646831 50.3680657 38.3919901 41.9123402
Finland 375 25.748151 61.92411 20.5474108 31.5870999 59.7025822 70.0922932
Sweden 380 18.643501 60.128161 10.9631866 24.1665923 55.3367024 69.0600236
Norway 385 8.468946 60.472024 4.5000962 31.1682684 57.959599 71.1854762
Denmark 390 9.501785 56.26392 8.0725589 15.1972813 54.5591211 57.7518131
Iceland 395 -19.020835 64.963051 -24.5465239 -13.4958153 63.2961021 66.5663183
Cape Verde 402 -23.6050817 15.1217288 -25.3609944 -22.6577782 14.8023513 17.2052865
Sao Tome And Principe 403 6.613081 0.18636 6.4604759 7.4630641 -0.0140044 1.7017723
Guinea-Bissau 404 -15.180413 11.803749 -16.7117356 -13.6275045 10.8599702 12.6847224
Equatorial Guinea 411 10.267895 1.650801 5.602367 11.3333 -1.4599463 3.8142257
Gambia 420 -15.310139 13.443182 -16.8136312 -13.7986107 13.0651826 13.8263891
Mali 432 -3.996166 17.570692 -12.2388849 4.2666666 10.147811 25.0000585
Senegal 433 -14.452362 14.497401 -17.5298482 -11.348607 12.3072891 16.6930544
Benin 434 2.315834 9.30769 0.7766672 3.8433429 6.2356319 12.4086111
Mauritania 435 -10.940835 21.00789 -17.0701337 -4.8333343 14.721273 27.2944447
Niger 436 8.081666 17.607789 0.1666672 15.9990339 11.693756 23.5000002
Cote D'Ivoire 437 -5.54708 7.539989 -8.6020589 -2.493031 4.3510071 10.7400151
Guinea 438 -9.696645 9.945587 -15.0782061 -7.637853 7.1909091 12.6746168
Burkina Faso (Upper Volta) 439 -1 12 NA NA NA NA
Liberia 450 -9.429499 6.428055 -11.4742481 -7.3692549 4.3154139 8.551986
Sierra Leone 451 -11.779889 8.460555 -13.3020067 -10.271651 6.8990253 9.9999724
Ghana 452 -1.023194 7.946527 -3.260786 1.1993625 4.7388737 11.1666675
Togo 461 0.824782 8.619543 -0.1440418 1.8090501 6.1123578 11.1394957
Cameroon 471 12.354722 7.369722 8.4947635 16.1944079 1.6558999 13.0833991
Nigeria 475 8.675277 9.081999 2.676932 14.6779814 4.2698571 13.8856449
Gabon 481 11.609444 -0.803689 8.6990528 14.5205562 -3.9583722 2.3181094
Central African Republic 482 20.939444 6.611111 14.4150981 27.4583051 2.2208575 11.0179569
Chad 483 18.732207 15.454166 13.4699999 24.0000011 7.442975 23.449235
Congo 484 15.827659 -0.228021 11.1495478 18.6436111 -5.0289487 3.707791
Congo, Democratic Republic Of (Zaire) 490 15.3716684 -4.3103947 14.4087785 15.5018469 -4.9250684 -4.2678038
Uganda 500 32.290275 1.373333 29.5734335 35.0330493 -1.4815419 4.2230008
Kenya 501 37.906193 -0.023559 33.9098212 41.9068317 -4.6796816 5.0334209
Tanzania/Tanganyika 510 29.6962677 -6.5456701 29.0584946 31.2024592 -8.8108635 -3.3466477
Zanzibar 511 39.316667 -6.133333 NA NA NA NA
Burundi 516 29.918886 -3.373056 29.000993 30.8501728 -4.4692284 -2.309987
Rwanda 517 29.873888 -1.940278 28.8617547 30.8994008 -2.8398397 -1.0475717
Somalia 520 46.199616 5.152149 40.994373 51.4130288 -1.6620412 11.9886144
Djibouti 522 42.590275 11.825138 41.7597221 43.4169731 10.9319442 12.7133956
Ethiopia 530 40.489673 9.145 32.997734 47.9999999 3.4041356 14.8942145
Eritrea 531 39.782334 15.179384 36.4333479 43.1429772 12.354723 18.0212099
Angola 540 17.873887 -11.202692 11.669562 24.0844443 -18.039104 -4.3879444
Mozambique 541 35.529562 -18.665695 30.2155496 40.8391213 -26.8681086 -10.471202
Zambia 551 27.849332 -13.133897 21.9963877 33.7022218 -18.077418 -8.2032836
Zimbabwe (Rhodesia) 552 29.154857 -19.015438 25.237368 33.0682357 -22.4245232 -15.609319
Malawi 553 34.301525 -13.254308 32.6788891 35.9241664 -17.1352784 -9.3671539
South Africa 560 22.937506 -30.559482 16.4608321 32.8909911 -34.8329773 -22.1253868
Transvaal 563 28.233333 -25.716667 NA NA NA NA
Orange Free State 564 26.216667 -29.1 NA NA NA NA
Namibia 565 18.49041 -22.95764 11.7242468 25.2617519 -28.9706387 -16.9634854
Lesotho 570 28.233608 -29.609988 27.011231 29.4557087 -30.6755788 -28.5708011
Botswana 571 24.684866 -22.328474 19.998905 29.3753036 -26.9075451 -17.778137
Swaziland 572 31.465866 -26.522503 30.7910943 32.1348445 -27.3173633 -25.7185194
Madagascar (Malagasy) 580 46.735881 -19.0432942 46.734532 46.73723 -19.0446432 -19.0419452
Comoros 581 43.266667 -11.683333 NA NA NA NA
Mauritius 590 57.552152 -20.348404 55.7666 63.5035945 -21.637 -10.3192548
Seychelles 591 55.491977 -4.679574 46.1977848 56.294294 -10.2270331 -4.2097858
Morocco 600 -7.09262 31.791702 -13.1728913 -0.9969757 27.6666665 35.9225072
Algeria 615 1.659626 28.033886 -8.6666671 11.9999997 18.968147 37.089829
Tunisia 616 9.537499 33.886917 7.5223135 11.5992174 30.2280336 37.347132
Libya 620 17.228331 26.3351 9.3914664 25.146954 19.5004298 33.1667871
Sudan 625 30.217636 12.862807 21.814939 38.5842192 9.3472209 22.2249184
Iran (Persia) 630 53.688046 32.427908 44.0318907 63.3333366 25.0594286 39.7816755
Turkey/Ottoman Empire 640 28 41 NA NA NA NA
Iraq 645 43.679291 33.223191 38.7936029 48.5759163 29.0612079 37.380932
Egypt 651 30.802498 26.820553 24.6967748 36.8945446 21.9999999 31.671535
Syria 652 38.996815 34.802075 35.7165956 42.376309 32.311136 37.320569
Lebanon 660 35.862285 33.854721 35.1037781 36.62372 33.0550256 34.69209
Jordan 663 36.238414 30.585164 34.9583368 39.301154 29.1850361 33.3746878
Israel 666 35 31 NA NA NA NA
Saudi Arabia 670 45.079162 23.885942 34.5489979 55.6666999 16.379528 32.154284
Yemen (Arab Republic Of Yemen) 678 44.0838889 15.1527778 44.0678815 44.0998963 15.1420075 15.1635476
Yemen, People'S Republic Of 680 45.033333 12.8 NA NA NA NA
Kuwait 690 47.966667 29.366667 NA NA NA NA
Bahrain 692 50.5577 26.0667 50.3781509 50.8228639 25.5798401 26.3265283
Qatar 694 51.183884 25.354826 50.7500553 51.6432601 24.471118 26.1830927
United Arab Emirates 696 53.847818 23.424076 51.4997702 56.4053766 22.6315138 26.0696541
Oman 698 55.923255 21.512583 52.0000018 59.8393974 16.650336 26.4053947
Afghanistan 700 67.709953 33.93911 60.5170005 74.8898619 29.3772 38.4908767
Turkmenistan 701 59.556278 38.969719 52.4477432 66.7073531 35.12876 42.798844
Tajikistan 702 71.276093 38.861034 67.3420121 75.1539564 36.6719898 41.044367
Kyrgyz Republic 703 74.6 42.866667 NA NA NA NA
Uzbekistan 704 64.585262 41.377491 55.9982179 73.148946 37.1722571 45.590075
Kazakhstan 705 66.923684 48.019573 46.4936719 87.315415 40.5685841 55.4419839
China 710 104.195397 35.86166 73.4994136 134.7728099 18.1535216 53.560974
Tibet 711 91.1 29.65 NA NA NA NA
Mongolia 712 103.846656 46.862496 87.73762 119.9319489 41.5815201 52.1486965
Taiwan 713 120.960515 23.69781 116.7118601 122.0069052 20.5637908 26.3873533
Korea 730 127.233333 38.316667 NA NA NA NA
Korea, People'S Republic Of 731 127 40.75121 -118.3062712 -118.2742564 34.0565722 34.0750586
Korea, Republic Of 732 127 34.0658159 -73.9849304 -73.9529156 40.7427567 40.7596622
Japan 740 138.252924 36.204824 122.9338302 153.9874306 24.0460446 45.5227719
India 750 78.96288 20.593684 68.1623859 97.395555 6.7471389 35.5043404
Bhutan 760 90.433601 27.514162 88.7464735 92.1252321 26.702016 28.360825
Pakistan 770 69.345116 30.375321 60.8729721 77.8356668 23.6946946 37.084107
Bangladesh 771 90.356331 23.684994 88.0085887 92.6801153 20.7543802 26.6342434
Myanmar (Burma) 775 96 22 NA NA NA NA
Sri Lanka (Ceylon) 780 80.771797 7.873054 79.6289063 81.8787029 5.9190779 9.8358504
Maldives 781 73.4977747 3.9870284 72.6385815 73.7192702 -0.7035846 7.1062798
Nepal 790 84.124008 28.394857 80.0522222 88.1992978 26.3477794 30.4469452
Thailand 800 100.992541 15.870032 97.343396 105.636812 5.612851 20.465143
Cambodia (Kampuchea) 811 104.9048424 11.5675652 104.8888645 104.9202459 11.5659677 11.569475
Laos 812 102.495496 19.85627 100.0832139 107.69483 13.90972 22.502872
Vietnam (Annam/Cochin China/Tonkin) 815 106.681944 10.769444 NA NA NA NA
Vietnam, Democratic Republic Of 816 105 21 NA NA NA NA
Vietnam, Republic Of 817 106.681944 10.769444 NA NA NA NA
Malaysia 820 101.975766 4.210484 99.640573 119.2658119 0.8538209 7.363468
Singapore 830 103.819836 1.352083 103.6056246 104.0856805 1.166398 1.4708809
Brunei 835 114.727669 4.535277 114.0760633 115.3635623 4.002508 5.0471668
Philippines 840 121.774017 12.879721 116.7029193 126.6043837 4.6134443 19.5740241
Indonesia 850 113.921327 -0.789275 95.004677 141.0195621 -10.997112 5.9068839
East Timor 860 125.727539 -8.874217 124.0429847 127.3416347 -9.504195 -8.1268067
Australia 900 133.775136 -25.274398 112.9214544 159.105459 -54.7772185 -9.2210836
Papua New Guinea 910 147.116667 -9.5 NA NA NA NA
New Zealand 920 174.885971 -40.900557 165.8694369 179.0625357 -52.6194185 -29.2313419
Vanuatu 935 166.959158 -15.376706 166.5417588 170.2384597 -20.2522929 -13.0724554
Solomon Islands 940 160.156194 -9.64571 155.4862405 167.2830811 -11.8616847 -6.5892403
Fiji 950 178.065032 -17.713371 176.9094944 -178.2301068 -20.6759701 -12.480116
Kiribati 970 -157.3599202 1.8668577 -157.5614933 -150.1958942 -11.4465192 4.6999585
Nauru 971 166.931503 -0.522778 166.9095486 166.9589281 -0.5541894 -0.5026395
Tonga 972 -175.198242 -21.178986 -175.6813217 -173.7024841 -21.4734606 -15.5663926
Tuvalu 973 179.4726562 -10.7280717 176.0588907 179.8710608 -10.8009338 -5.64223
Marshall Islands 983 171.184478 7.131474 160.7979585 172.1701812 4.5729556 14.673255
Palau 986 134.58252 7.51498 131.1692199 134.7210985 3.0011389 8.0940234
Micronesia, Fed. Sts. 987 158 6 NA NA NA NA
Samoa 990 -172.104629 -13.759029 -172.7985992 -171.405859 -14.0765884 -13.4344024
United Kingdom 200 -0.116667 51.5 NA NA NA NA
variable Question
cowcode Correlates of War country code (www.correlatesofwar.org).
country Country name.
systyear Year in which the constitutional system was promulgated.
systid Unique identification number for the constitutional system.
evntyear Year of promulgation of the most recent constitutional event.
endyear Year through which the data for the event is guaranteed valid.
evntid Unique identification number for the constitutional event.
evnttype Event type (e.g. amendment, new, etc.).
source What is the source for the text of the Constitution?
langsrce In what language is the source document written (not the original, but the one used for coding)?
translat Who translated this constitution into English?
doctit What is the document entitled?
model Does the constitution (most likely in the preamble) identify any models on which the constitution was based?
length How long in words is the constitution?
docs How many documents does the constitution consist of?
tranprov Does the constitution contain any transitional provisions?
preamble Does the constitution have an introduction or preamble?
preambw What is the length in words of the introduction or preamble? (Asked only if PREAMBLE is answered 1)
rightsw In what form are 'rights' included in the constitution?
rghtwrds How many words is the 'rights' section of the constitution? (Asked only if RIGHTSW is answered 2, or if RIGHTSW is answered 3)
colony How does the Constitution treat the status of colonies, protectorates, and territories?
colrule What political status does the constitution assign to the residents of colonies, protectorates, or territories?
indcon Does constitution refer to decolonization or the process by which the state became independent?
region Does the Constitution mention a broader regional group of which the nation is a part?
regions What broader regional group is this country a part of? (Asked only if REGION is answered 1)
prevcond Does the constitution refer to social, political, or economic conditions in the time before the birth of the state or in the time of a former constitution?
truthcom Does the Constitution provide for a commission for truth and reconciliation?
prevlead Does the constitution mention anything about crimes committed by the previous regime?
democ Does the constitution refer to 'democracy' or 'democratic'?
oath Does the constitution stipulate that some public office holders take an oath to support or abide by the constitution?
socialsm Does the constitution refer to 'socialism' or 'socialist'?
market Does the constitution refer to the 'free market,' 'capitalism,' or an analogous term?
forinves Does the Constitution mention 'foreign investment' or 'foreign capital'?
fortrad Does the constitution mention foreign or international trade?
dignity Does the constitution refer to the 'dignity of man' or human 'dignity'?
god Does the Constitution mention 'God' or any other Deities?
figures Are there any political figures/theorists/philosophers mentioned in the Constitution?
solid Does the constitution refer to 'fraternity' or 'solidarity'?
overthrw Does the constitution suggest that citizens should have the right to overthrow their government under certain circumstances?
terr Does the constitution define the geographic borders/territory of the state?
capital Does the constitution contain provisions specifying the location of the capital (if so, please specify the location in the comments section)?
anthem Does the constitution contain provisions concerning the national anthem?
flag Does the constitution contain provisions concerning the national flag?
motto Does the constitution contain a national motto?
amend Does the constitution provide for at least one procedure for amending the constitution?
unamend Are any parts of the constitution unamendable? (Asked only if AMEND is answered 1)
amndamaj Do constitutional amendments require more than a simple majority by the legislature to be approved?
amndapct What proportion of the vote is needed to approve a constitutional amendment?
execindp Does the constitution contain an explicit declaration regarding the INDEPENDENCE of the central executive organ(s)?
execnum How many executives are specified in the constitution?
hoshog Is the executive identified explicitly as the Head of State or Head of Government? (Asked only if EXECNUM is answered 2)
hosid Is one of the executives explicitly referred to as the 'Head of State'? (Asked only if EXECNUM is answered 3)
hogid Is one of the executives explicitly referred to as the 'Head of Government'? (Asked only if EXECNUM is answered 3)
hosname What name does the constitution assign the office of the the Head of State?
hoselect How is the Head of State selected?
hoselsys Which of these best categorizes the electoral system for the Head of State? (Asked only if HOSELECT is answered 2)
hosterm What is the maximum term length of the Head of State?
hosterml What restrictions are in place regarding the number of terms the Head of State may serve?
hosage What is the minimum age limit for becoming the Head of State?
hosrest_ what additional restrictions does the constitution place on becoming the head of state?
hosdiss Are there provisions for dismissing the Head of State?
hosdcond_ under what grounds can the head of state be dismissed?
hossucc Should the head of state need to be replaced before the normally scheduled replacement process, what is the process of replacement?
hosimm Is the Head of State provided with immunity from prosecution?
hosstaff Does the constitution specify a council or advisory group (other than the cabinet)?
hosdec Does the Head of State have decree power?
hosdecim Which arrangement describes the implementation procedure for Head of State decrees?
hosdecex Once implemented, what arrangement describes the expiration procedures for Head of State decrees?
hospard Does the Head of State have the power to pardon?
hogname What name does the constitution assign the Head of Government?
hogelect How is the Head of Government selected?
hogterm What is the maximum term length of the Head of Government?
hogterml What restrictions are in place regarding the number of terms the Head of Government may serve?
hogage What is the minimum age limit for becoming the Head of Government?
hoglegr What restrictions does the constitution place on the Head of Government's role in the Legislature?
hogrest_ what additional restrictions does the constitution place on becoming the head of Government?
hogdiss Are there provisions for dismissing the Head of Government?
hogdcond_ under what grounds can the head of government be dismissed?
hogsucc Should the head of government need to be replaced before the normally scheduled replacement process, what is the process of replacement?
hogimm Is the Head of Government provided with immunity from prosecution?
hogdec Does the Head of Government have decree power?
hogdecim Which arrangement describes the implementation procedure for Head of Government decrees?
hogdecex Once implemented, what arrangement describes the expiration procedures for Head of Government decrees?
hogpard Does the Head of Government have the power to pardon?
depexec Does the constitution specify a deputy executive of any kind (e.g., deputy prime minister, vice president)?
depname What is the name of the office of the deputy executive?
depsel How is the deputy executive selected?
cabinet Does the constitution mention the executive cabinet/ministers?
cabdiss_ who has the authority to dismiss the cabinet/ministers?
atgen Does the constitution provide for an attorney general or public prosecutor responsible for representing the government in criminal or civil cases?
em Does the constitution have provisions for calling a state of emergency?
emdecl Who can declare a state of emergency? (Asked only if EM is answered 1)
emappr_ who approves a state of emergency? (asked only if em is answered 1)
emcond_ under which of the following circumstances can a state of emergency be called?
emrights Does the constitution provide for suspension or restriction of rights during states of emergency?
emother_ other than rights, what (if any) operations of government are affected by a state of emergency?
legisl Does the constitution provide for a central representative body (a legislature)?
housenum How many chambers or houses does the Legislature contain?
legjoint Does the constitution specify that the chambers should meet jointly for any reason?
lhname What name is given to the first (or only) chamber?
lhlead Who presides over the first (or only) chamber?
lhseats How many members compose the first (or only) chamber of the Legislature?
lhlegis Is the first (or only) chamber of the Legislature given the power to legislate?
lhselect_ how are members of the first (or only) chamber of the legislature selected?
lhcohort Are members of the first (or only) chamber elected in the same cohort, or in staggered cohorts?
lhelsys Does the constitution specify the electoral system for the first (or only) chamber?
lhage What is the minimum age limit for eligibility to serve as a member of the first (or only) chamber of the Legislature?
lhrest_ what additional restrictions does the constitution place on the eligibility to serve as a member of the first (or only) chamber of the Legislature?
lhterm What is the maximum term length for members of the first (or only) chamber of the Legislature?
lhtrmlim What restrictions are in place regarding the number of terms members of the first (or only) chamber may serve?
lhquota Does the constitution stipulate a quota for representation of certain groups in the first (or only) chamber?
lhquotad_ which groups does the constitution stipulate a quota for in the first (or only) chamber of the Legislature?
uhname What name is given to the Second Chamber?
uhlead Who presides over the Second Chamber?
uhseats How many members compose the Second Chamber of the Legislature?
uhlegisl Is the Second Chamber of the Legislature given the power to legislate?
uhselect_ how are members of the second chamber selected?
uhcohort Are members of the Second Chamber elected in the same cohort, or in staggered cohorts?
uhelsys Does the constitution specify the electoral system for the Second Chamber?
uhage What is the minimum age limit for eligibility to serve as a member of the Second Chamber of the Legislature?
uhrest_ what additional restrictions does the constitution place on the eligibility to serve as a member of the Second Chamber of the Legislature?
uhterm What is the maximum term length for members of the Second Chamber of the Legislature?
uhtrmlim What restrictions are in place regarding the number of terms members of the second chamber may serve?
uhquota Does the constitution stipulate a quota for representation of certain groups in the Second Chamber?
uhquotad_ which groups does the constitution stipulate a quota for in the second chamber?
legdiss Who, if anybody, can dismiss the legislature?
remleg Are there provisions for removing individual legislators?
legrep What provisions are there for replacing individual legislators who have been removed, resign, or die?
immunity Does the constitution provide for immunity for the members of the Legislature under some conditions?
intexec Does the legislature have the power to interpellate members of the the legislature on a regular basis?
invexe Does the legislature have the power to investigate the activities of the executive branch?
leg_in_ who does the constitution specify can initiate general legislation?
legsupr Is a supermajority needed for passing any legislation?
legapp Who has the power to approve/reject legislation once it has been passed by the legislature (not including reviews for constitutionality)?
legappdf Which of the following describes the default mode for the approval of legislation?
legapppt Does the approving/vetoing actor have the power to approve/reject parts of the bill, the bill in its entirety, or both?
override Can vetoes of legislation be overridden?
overwho Who can override vetoes of legislation?
overpct What proportion of the vote is needed to override a veto?
specleg_ does the constitution provide for any of the following special legislative processes?
attend What provisions does the constitution make regarding attendance by legislators?
exsess_ who, if anybody, can convene an extraordinary session of the legislature or extend an ongoing session?
profleg Does the Constitution require that legislators give up any other profession (i.e. work exclusively as legislators)?
assets Does the Constitution require that legislators disclose their earnings and/or assets?
income_ who is involved in the determination of legislator's compensation?
pubmeet Does the constitution prescribe whether or not the meetings of the Legislature are (generally) held in public?
pubmin Is a record of the deliberations of the Legislature published?
recvote Are votes in the legislature a matter of public record, secret, or both (depending on the topic)?
quorum Is a quorum required for a session of the legislature to be official?
quorumw What is the quorum needed (% of membership)?
commit Are legislative committees mentioned in the Constitution?
levjud Does the court system provide for any of the following?
judcrts_ for which of the following specialized courts does the constitution contain provisions?
judind Does the constitution contain an explicit declaration regarding the independence of the central judicial organ(s)?
judprec Does the constitution stipulate that courts have to take into account decisions of higher courts?
judfin Are judicial decisions by the highest ordinary court final?
hocop Does the constitution provide for judicial opinions of the Highest Ordinary Court?
hocopw_ which of the following is mentioned about opinions for the highest ordinary court?
illadmin Does the constitution contain provisions protecting the individual against illegal or ultra-vires administrative actions?
concop Does the constitution mention judicial opinions of the Constitutional Court?
concopw_ which of the following describes the provisions for opinions for the constitutional court?
interp_ to whom does the constitution assign the responsibility for the interpretation of the constitution?
unconper What proportion of the vote of the court is required to find legislation unconstitutional?
challeg_ who has standing to initiate challenge to the constitutionality of legislation?
amparo Does the constitution provide for a right to petition for 'amparo'?
jrem Are there provisions for dismissing judges?
jermcon_ under what conditions can judges be dismissed?
judsal Does the constitution explicitly state that judicial salaries are protected from governmental intervention?
judretir Is there a mandatory retirement age for judges?
fedunit Is the state described as either federal, confederal, or unitary?
federal_ does the constitution recognize any of the following subnational governments?
fedsep Which level of government has superior legal status in the case of conflict?
fedrev Does the constitution contain provisions allowing review of the legislation of organs?
seccess Are there provisions for the secession or withdrawal of parts of the state?
access Does the Constitution provide for accession or adoption of territory outside of the country into the constitutional regime?
indpolgr_ are any of the following political rights or benefits specifically granted to indigenous groups?
indcit Are indigenous groups explicitly granted full citizenship? (Asked only if
part Does the constitution refer to political parties?
partrght Does the constitution provide for a right to form political parties?
partprf Does the constitution express a preference for one or more political parties?
partprh Does the constitution prohibit one or more political parties?
partunco_ who is given the power to make determinations of unconstitutional political parties?
initiat Does the constitution provide for the ability of individuals to propose legislative initiatives (referenda from below)?
what are the prerequisites for an initiative to be considered (please check all that apply)?
referen Does the constitution provide for the ability to propose a referendum (or plebiscite)?
referenp_ who can propose a referendum?
voteres Does the constitution place any restrictions on the right to vote?
votemin What is the minimum age limit for voting?
votelim_ besides age limits, which additional restrictions does the constitution place on voting?
voteun Does the constitution make a claim to universal adult suffrage?
oversght Does the constitution provide for an electoral commission or electoral court to oversee the election process?
compvote Does the constitution make voting mandatory, at least for some elections?
freeelec Does the constitution prescribe that electoral ballots be secret?
electsch What are the arrangements for the scheduling of elections?
camppubf Are there any provisions for the public financing of campaigns?
electfin Are there any provisions for limits on money used for campaigns?
electsam Are elections for the executive and the legislature held on the same day?
census Does the constitution specify a census?
ombuds Does the constitution provide for an Ombudsman?
bank Does the constitution contain provisions for a central bank?
bankgoal What are the policy goals of the central bank?
medcom Does the constitution mention a special regulatory body/institution to oversee the media market?
jc Does the constitution contain provisions for a Judicial Council/Commission?
cc Does the constitution contain provisions for a counter corruption commission?
civil Does the constitution include provisions for the meritocratic recruitment of civil servants (e.g. exams or credential requirements)?
hr Does the constitution contain provisions for a human rights commission?
exinst Does the constitution contain provisions with regard to any additional central rights commission, central bank commission, or central election commission)?
intlaw Does the constitution contain provisions concerning the relationship between the constitution and international law?
custlaw Does the Constitution refer to 'customary' international law or the 'law of nations'?
custlaw2 What is the status of customary international law in the constitution?
intorgs Does the constitution contain provisions concerning international organizations?
headforn Who is the representative of the state for foreign affairs?
war_ who has the power to declare war?
treat Does the constitution mention international treaties?
treatini_ who has the power to initiate treaties? (asked only if treat is answered 1)
treatap_ who has the power to approve treaties? (asked only if treat is answered 1)
treatrvw Are treaties reviewable for their constitutionality?
treatst What is the status of treaties vis a vis ordinary legislation?
provwork Does the constitution mention a state duty to provide work/employment?
provhlth Does the constitution mention a state duty to provide health care?
cultrght Does the constitution refer to a state duty to protect or promote culture or cultural rights?
buildsoc Does the constitution refer to a duty of the people to take part in building society or to work for the development of the country?
taxes Does the constitution refer to a duty to pay taxes?
milserv Does the constitution refer to a duty of military service?
work Does the constitution refer to a duty to work?
prtyduty Does the constitution refer to a duty to join a political party?
tradeun Does the constitution refer to a duty to join trade unions?
jury Does the constitution require a jury or any form of citizen participation in decision making in criminal trials?
grjury Is there citizen involvement in the indicting process (such as a grand jury)?
vicright Is there a special mention of victims rights in the constitution?
excrim Does the constitution provide for the extradition of suspected or convicted criminals to other countries?
evidence Does the constitution regulate the collection of evidence?
prerel Does the constitution provide for the right/possibility of pre-trial release?
habcorp Does the constitution provide for the right to protection from unjustified restraint (habeas corpus)?
wolaw Does the constitution mention nulla poena sine lege or the principle that no person should be punished without law?
rghtapp Do defendants have the right to appeal judicial decisions?
prisonrg Does the constitution require that the names of those imprisoned be entered in a public registry?
cappun How does the constitution treat the use of capital punishment?
corppun How does the constitution treat the use of corporal punishment?
dueproc Does the constitution explicitly mention due process?
examwit Does the constitution provide for the right to examine evidence or confront all witnesses?
expost Does the constitution prohibit punishment by laws enacted ex post facto ?
falseimp Does the constitution provide for the right of some redress in the case of false imprisonment, arrest, or judicial error?
fairtri Does the constitution provide the right to a fair trial?
speedtri Does the constitution provide for the right to a speedy trial?
pubtri Does the constitution generally require public trials?
presinoc Is there a presumption of innocence in trials?
trilang Does the constitution specify the trial has to be in a language the accused understands or the right to an interpreter if the accused cannot understand the language?
juvenile Does the constitution give juveniles special rights/status in the criminal justice process?
doubjep Does the constitution provide for the prohibition of double jeopardy (i.e., being tried for the same crime twice)?
miranda Does the constitution give the accused a right to silence or protection from self incrimination?
couns Does the constitution provide the right to counsel if one is indicted or arrested?
counscos If counsel is provided, is it provided at the state's expense?
debtors Does the constitution forbid the detention of debtors?
bankrupt Does the constitution mention bankruptcy law?
nat Does the constitution refer to nationals, subjects, or citizens?
natcit Does the constitution provide for naturalized citizens?
citrev_ under what conditions can citizenship be revoked?
citren Do citizens have the right to renounce their citizenship?
citdep Does the constitution grant the government the right to deport citizens or residents?
resenex Does the constitution restrict entry or exit of the states borders?
rulelaw Does the constitution contain a general statement regarding rule of law, legality, or Rechtsstaat (the German equivalent)?
equal Does the constitution refer to equality before the law, the equal rights of men, or non-discrimination?
rightres_ does the constitution specifically restrict the rights of any of the following groups?
binding Are rights provisions binding on private parties as well as the state?
infoacc Does the constitution provide for an individual right to view government files or documents under at least some conditions?
infoaccw To which kinds of documents does the constitution direct that individuals should have access?
libel Does the constitution provide for the right of protection of one's reputation from libelous actions?
offrel Does the constitution contain provisions concerning a national or official religion or a national or official church?
offrelw What religion does the constitution name as national or official or grant special treatment to?
freerel Does the constitution provide for freedom of religion?
rellaw_ what is the status of religious law?
rellawv Is law contrary to religion void (repugnancy clause)?
seprel Does the constitution contain an explicit decree of separation of church and state?
reltax Are religious organizations granted tax free status?
exprop Can the government expropriate private property under at least some conditions?
exprcomp What is the specified level of compensation for expropriation of private property?
expcond_ under what conditions or for what purposes can the state expropriate private property?
explim_ what limits/conditions are placed on the ability of the government to expropriate private
socecon Does the constitution use the words (socio-) economic rights or similar?
remuner Does the constitution provide the right to just remuneration, fair or equal payment for work?
jointrde Does the constitution provide for the right to form or to join trade unions?
strike Does the constitution provide for a right to strike?
leisure Does the constitution provide for a right of rest and leisure?
standliv Does the constitution provide for a right to an adequate or reasonable standard of living?
transfer Does the constitution mention the right to transfer property freely?
testate Does the constitution provide for a right of testate, or the right to transfer property freely after death?
inherit Does the constitution provide for inheritance rights?
intprop_ does the constitution mention any of the following intellectual property rights?
busines Does the constitution provide a right to conduct/establish a business?
conright Does the constitution mention consumer rights or consumer protection?
socsec Does the constitution refer to the social security of the society or nation?
proprght Does the constitution provide for a right to own property?
freecomp Does the constitution provide the right to a free and/or competitive market?
scifree Does the constitution provide for a right to enjoy the benefits of scientific progress?
occupate Does the constitution provide for the right to choose ones occupation?
safework Does the constitution mention the right to safe/healthy working conditions?
childwrk Does the constitution place limits on child employment?
shelter Does the constitution provide for the right to shelter or housing?
marriage Does the constitution provide for the right to marry?
samesexm Does the constitution provide the right for same sex marriages?
fndfam Does the constitution provide the right to found a family?
matequal Does the constitution provide for matrimonial equality?
childpro Does the constitution guarantee the rights of children?
civmar Is there a constitutional provision for civil marriage?
selfdet Does the constitution provide for a people's right of self-determination?
healthr Does the constitution mention the right to health care?
healthf Does the constitution specify that healthcare should be provided by government free of charge?
life Does the constitution provide for a right to life?
slave Does the constitution prohibit slavery, servitude, or forced labor?
torture Does the constitution prohibit torture?
cruelty Does the constitution prohibit cruel, inhuman, or degrading treatment?
privacy Does the constitution provide for a right of privacy?
freemove Does the constitution provide for freedom of movement?
opinion Does the constitution provide for freedom of opinion, thought, and/or conscience?
express Does the constitution provide for freedom of expression or speech?
petition Does the constitution provide for a right of petition?
censor Does the constitution prohibit censorship?
press Does the constitution provide for freedom of the press?
intright_ does the constitution refer to any of the following international treaties or instruments?
assem Does the constitution provide for freedom of assembly?
assoc Does the constitution provide for freedom of association?
inalrght Does the constitution stipulate that the certain rights are inalienable or inviolable?
devlpers Does the constitution provide for an individual's right to self determination or the right to free development of personality?
nomil Is there a right to exemption from military service for conscientous objectors to war or other groups?
asylum Does the constitution contain provisions for the protection of stateless individuals, refugees from other states, or the right to asylum?
arms Does the constitution provide for the right to bear arms?
env Does the constitution refer to protection or preservation of the environment?
envref_ how does the constitution refer to the environment? (asked only if env is answered 1)
envpart_ which specific parts of the environment does the constitution refer?
resrce Does the constitution refer to ownership or possession of natural resources (such as minerals, oil, etc.)?
resrces_ which specific natural resources does the constitution refer to?
artists Does the constitution refer to artists or the arts?
science Does the constitution refer to science or the sciences?
telecom Is there a mention of telecommunications?
radio Does the constitution refer to radio?
tv Does the constitution refer to television?
govmed How does the constitution address the state operation of print or electronic media?
medmark_ does the constitution mention any of the following general principles about the operation of the media market?
military Is the military or armed forces mentioned in the constitution?
comchief Who is the commander in chief of the armed forces?
terror Is there special mention of terrorism and public security provisions regarding terrorism?
econplan Does the constitution mention the adoption of national economic plans?
ethincl Does the constitution contain provisions concerning national integration of ethnic communities?
opgroup Does the constitution provide for positive obligations to transfer wealth to, or provide opportunity for, particular groups?
lang Does the constitution specify either an official or national language?
langoffw What languages does the constitution list as official?
langnatw What languages does the constitution list as national? (Asked only if
langprot Does the constitution refer to the protection of different languages?
educate Does the constitution contain provisions concerning education?
edcomp Does the constitution stipulate that education be compulsory until at least some level?
edcompl To what level (or year of age) does the constitution make education compulsory?
edfree Does the constitution stipulate that education be free, at least up to some level?
edfreel To what level (or year of age) does the constitution stipulate that education should be free?
acfree Does the constitution guarantee academic freedom?
achighed Does the constitution guarantee equal access to higher education?
# Fig 1
library(foreign)
library(plyr)
library(ggplot2)
ccp <- read.dta("../Data/ccpcncv1_0/ccpcnc/ccpcncv1_0.dta")
ccp <- ccp[, -c(grep("article|comments", names(ccp)))] #discard variables we are not interested in
uds <- read.csv("../Data/uds_summary.csv")
uds <- ddply(uds, .(country), transform, cumMean = cumsum(mean))
ccp <- merge(ccp, subset(uds, year == 2006), by = c("cowcode"))
geocodes <- read.csv("geocoded_cowcodes.csv") #For making a map, we need latitude and longitude information for all countries in the dataset; this file contains that info
ccp <- merge(ccp, geocodes)
rm(geocodes)
map <- aes_string(x = "lon", y = "lat", color = "mean", size = "cumMean")
data <- subset(ccp, democ != "1. yes")
labelMap <- aes_string(x = "lon", y = "lat", label = expression(paste(country.x,
systyear)))
constitutionsMap <- ggplot() + geom_point(data = data, mapping = map) + borders() +
scale_color_gradient2() + scale_size(range = c(3, 9))
constitutionsMap + labs(shape = "Does the constitution\nmention democracy?",
color = "Mean UDS score \nin 2006 \n(blue= more democratic)", size = "Cumulative UDS score \nas of 2006\n(bigger = more democratic experience)",
title = "Fig. 1: Constitutional documents that do NOT mention 'democracy' or 'democratic' as of 2006") +
geom_text(data = data, mapping = labelMap)
ggsave("Fig. 1 Constitutional documents that do not mention democracy.png",
width = 16, height = 9)
#Correlations between mention of democracy and measure of democracy
cor(colwise(as.numeric)(ccp[, c("democ", "mean", "cumMean")]))
# note that since 'yes' = 1 and 'no' = 2 a positive value for the
# correlation between democ and the average or cumulative UDS score
# implies a negative correlation between being more democratic and
# mentioning democracy in the constitution
#Fig 2
library(reshape2)
liberalDemVars <- c("assem", "equal", "express", "freerel", "assoc")
data <- ccp[, c("country.x", "mean", "cumMean", "systyear", "evntyear", liberalDemVars)]
data <- melt(data, id.vars = c("country.x", "mean", "cumMean", "systyear", "evntyear"))
data$value <- as.numeric(as.factor(data$value))
data <- subset(data, value > 1)
length(unique(data[, "country.x"])) # Number of countries that are missing at least one liberal freedom in their constitution
liberal.democracy.differences <- qplot(data = data, x = variable, y = reorder(paste(country.x,
systyear), value, FUN = "sum"), fill = mean, geom = "tile")
liberal.democracy.differences + labs(y = "Constitution", x = "Missing liberal democracy principle",
fill = "Mean UDS score\nas of 2006") + scale_fill_gradient2() + theme_bw()
ggsave("Fig. 2 Countries missing liberal freedoms in their constitutions.png")
#Fig 3
source("auxiliary functions.R")
rights <- c("democ", names(ccp)[which(names(ccp) == "nat"):which(names(ccp) ==
"arms")])
rights <- rights[!grepl("_|name|age", rights)]
data <- ccp[, c("country.x", "mean", "cumMean", rights)]
data <- melt(data, id.vars = c("country.x", "mean", "cumMean"))
data <- data[grep("1. yes$", data$value), ]
data$value <- as.numeric(as.factor(data$value))
data <- dcast(data, country.x + mean + cumMean + variable ~ variable)
data <- ddply(data, .(variable), transform, variable = c(rep(NA, length(variable) -
1), round(length(variable)/183, 2)))
eventAttributes <- data.frame(country.x = rep(NA, length(names(data)) - 4),
mean = rep(0, length(names(data)) - 4), cumMean = rep(0, length(names(data)) -
4), variable = names(data)[5:length(names(data))])
plot.matrix(data, events.vars = c(5:length(names(data))), eventAttributes = eventAttributes,
color = "mean", label = "variable") + scale_color_gradient2() + labs(color = "Mean UDS score in 2006",
size = "Cumulative UDS score by 2006", title = "Rights in world constitutions")
ggsave("Fig. 3 Rights in world constitutions.png", width = 15, height = 8)
#Fig 4
source("auxiliary functions.R")
rights <- c("democ", names(ccp)[which(names(ccp) == "nat"):which(names(ccp) ==
"arms")])
rights <- rights[!grepl("_|name|age", rights)]
data <- ccp[, c("country.x", "mean", "cumMean", rights)]
data <- melt(data, id.vars = c("country.x", "mean", "cumMean"))
data <- ddply(data, .(variable, value), transform, meanUDS = mean(mean), meanCumUDS = mean(cumMean))
data <- ddply(data, .(variable, value), transform, n = length(mean))
data <- data[grep("1. yes$", data$value), ]
varQuestions <- read.csv("List-of-variables-ccp.csv")
data <- merge(data, varQuestions)
library(stringr)
chars.graph <- qplot(data = data, x = reorder(paste(str_wrap(Question, width = 50),
" (", variable, ") ", value, sep = ""), n), y = n/183, color = meanUDS) +
coord_flip() + geom_hline(yintercept = c(0.5, 0.8), color = "red") + scale_color_gradient2(midpoint = mean(ccp$mean),
mid = "grey", high = "blue", low = "red", breaks = c(min(data$meanUDS),
mean(ccp$mean), max(data$meanUDS)), labels = c("Less dem than avg",
"Avg level of dem in 2006", "More dem than avg"))
chars.graph + labs(x = "Right or provision", y = "Proportion of constitutions endorsing the right",
color = "Average UDS \nscore of countries \nendorsing the right")
ggsave("Fig. 4 Rights endorsed in constitutions.png", height = 25, width = 15)
#Fig 5
source("auxiliary functions.R")
rights <- names(ccp)[which(names(ccp) == "nat"):which(names(ccp) == "arms")]
duties <- names(ccp)[which(names(ccp) == "provwork"):which(names(ccp) == "tradeun")]
rights <- rights[!grepl("_|name|age", rights)]
plot_ccp_network(vars = rights, threshold = 0.85, title = "Similarities in rights provisions (85% or greater similarity)",
vertexattributes = c("mean", "cumMean", "systyear", "country.x"), label = expression(abbreviate(country.x))) +
scale_color_gradient2(mid = "grey", low = "red") + scale_size(range = c(3,
9))
# plot_ccp_network(vars=duties,threshold=0.9, title='Similarities in
# duties provisions (90% or greater
# similarity)',vertexattributes=c('mean','cumMean','systyear','country.x'),label=expression(abbreviate(country.x)))+scale_color_gradient2(mid='grey',low='red')+
# scale_size(range=c(3,9))
ggsave("Fig. 5 Similarities among constitutions 85.png", width = 15, height = 8)
#Calculations of similarities
source("auxiliary functions.R")
ccp$meanCut <- cut(ccp$mean, 3, labels = c("Dictatorship", "Hybrid", "Democracy"))
codes <- read.csv("../Data/extended codes.csv")
names(codes)[which(names(codes) == "country")] <- "country.codes"
names(codes)[which(names(codes) == "ccode")] <- "cowcode"
allProvisions <- names(ccp)[which(names(ccp) == "model"):which(names(ccp) ==
"achighed")]
data <- merge(ccp, codes, by = c("cowcode"))
calculate_similarities_3(data = data, n = 300, vars = rights)
## Dictatorship Dictatorship Hybrid Hybrid Democracy Democracy
## Dictatorship 0.0000 0.6298 0.5964 0.6056 0.6074 0.6033
## Dictatorship 0.6298 0.0000 0.6040 0.6001 0.6006 0.6070
## Hybrid 0.5964 0.6040 0.0000 0.6180 0.5850 0.5871
## Hybrid 0.6056 0.6001 0.6180 0.0000 0.5978 0.5856
## Democracy 0.6074 0.6006 0.5850 0.5978 0.0000 0.6022
## Democracy 0.6033 0.6070 0.5871 0.5856 0.6022 0.0000
calculate_similarities_3(data = data, n = 300, vars = liberalDemVars)
## Dictatorship Dictatorship Hybrid Hybrid Democracy Democracy
## Dictatorship 0.0000 0.7860 0.8693 0.8733 0.8273 0.8360
## Dictatorship 0.7860 0.0000 0.8627 0.8647 0.8113 0.8180
## Hybrid 0.8693 0.8627 0.0000 0.9693 0.8967 0.8953
## Hybrid 0.8733 0.8647 0.9693 0.0000 0.8993 0.9013
## Democracy 0.8273 0.8113 0.8967 0.8993 0.0000 0.8287
## Democracy 0.8360 0.8180 0.8953 0.9013 0.8287 0.0000
calculate_similarities_3(data = data, n = 100, vars = rights, subsetVar = "un_continent_name")
## Africa Africa Americas Americas Asia Asia Europe Europe
## Africa 0.0000 0.6630 0.6214 0.6425 0.6256 0.6284 0.5961 0.6083
## Africa 0.6630 0.0000 0.6203 0.6072 0.6248 0.6172 0.6041 0.5988
## Americas 0.6214 0.6203 0.0000 0.5919 0.5808 0.5892 0.5816 0.5909
## Americas 0.6425 0.6072 0.5919 0.0000 0.5942 0.5894 0.5822 0.5742
## Asia 0.6256 0.6248 0.5808 0.5942 0.0000 0.6086 0.5703 0.5795
## Asia 0.6284 0.6172 0.5892 0.5894 0.6086 0.0000 0.5664 0.5742
## Europe 0.5961 0.6041 0.5816 0.5822 0.5703 0.5664 0.0000 0.5911
## Europe 0.6083 0.5988 0.5909 0.5742 0.5795 0.5742 0.5911 0.0000
## Oceania 0.6695 0.6692 0.6016 0.6228 0.6523 0.6336 0.5769 0.5839
## Oceania 0.6542 0.6670 0.5962 0.6219 0.6394 0.6223 0.5694 0.5741
## Oceania Oceania
## Africa 0.6695 0.6542
## Africa 0.6692 0.6670
## Americas 0.6016 0.5962
## Americas 0.6228 0.6219
## Asia 0.6523 0.6394
## Asia 0.6336 0.6223
## Europe 0.5769 0.5694
## Europe 0.5839 0.5741
## Oceania 0.0000 0.7417
## Oceania 0.7417 0.0000
data[, allProvisions] <- colwise(as.factor)(data[, allProvisions])
calculate_similarities_3(data = data, n = 100, vars = allProvisions, subsetVar = "un_continent_name")
## Africa Africa Americas Americas Asia Asia Europe Europe
## Africa 0.0000 0.6787 0.6486 0.6521 0.6641 0.6638 0.6584 0.6563
## Africa 0.6787 0.0000 0.6555 0.6458 0.6679 0.6580 0.6660 0.6613
## Americas 0.6486 0.6555 0.0000 0.6428 0.6410 0.6409 0.6343 0.6254
## Americas 0.6521 0.6458 0.6428 0.0000 0.6401 0.6410 0.6352 0.6333
## Asia 0.6641 0.6679 0.6410 0.6401 0.0000 0.6627 0.6613 0.6513
## Asia 0.6638 0.6580 0.6409 0.6410 0.6627 0.0000 0.6535 0.6496
## Europe 0.6584 0.6660 0.6343 0.6352 0.6613 0.6535 0.0000 0.6734
## Europe 0.6563 0.6613 0.6254 0.6333 0.6513 0.6496 0.6734 0.0000
## Oceania 0.6499 0.6427 0.6473 0.6522 0.6385 0.6322 0.6065 0.6108
## Oceania 0.6308 0.6360 0.6530 0.6382 0.6337 0.6216 0.6106 0.6028
## Oceania Oceania
## Africa 0.6499 0.6308
## Africa 0.6427 0.6360
## Americas 0.6473 0.6530
## Americas 0.6522 0.6382
## Asia 0.6385 0.6337
## Asia 0.6322 0.6216
## Europe 0.6065 0.6106
## Europe 0.6108 0.6028
## Oceania 0.0000 0.6761
## Oceania 0.6761 0.0000
calculate_similarities_3(data = data, n = 300, vars = allProvisions)
## Dictatorship Dictatorship Hybrid Hybrid Democracy Democracy
## Dictatorship 0.0000 0.6537 0.6517 0.6520 0.6431 0.6434
## Dictatorship 0.6537 0.0000 0.6505 0.6548 0.6442 0.6416
## Hybrid 0.6517 0.6505 0.0000 0.6638 0.6489 0.6454
## Hybrid 0.6520 0.6548 0.6638 0.0000 0.6537 0.6507
## Democracy 0.6431 0.6442 0.6489 0.6537 0.0000 0.6547
## Democracy 0.6434 0.6416 0.6454 0.6507 0.6547 0.0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment