In this RMarkdown document, I present a disaggregated analysis of the military spendings over time, focused on four dimensions: i. the evolution of the correlation between exposures over time, ii. the evolution of military spendings by items, iii. the evolution of new/dropped products over time.
I only use two files of interest: “supply-code-descriptions-2.csv” and “county-supply-code-procurement.csv”.
#### DATABASES ######
psc_descriptions <- read_csv("C:/Users/Jairo/Dropbox/jairo-working-folder/supply-code-descriptions-2.csv")
county_supply_code_procurement <- read_csv("C:/Users/Jairo/Dropbox/jairo-working-folder/county-supply-code-procurement.csv", show_col_types = FALSE)
county_supply_code_procurement <- county_supply_code_procurement %>% mutate(join = paste(year, county_fips, sep = "_"))
supply_codes <- unique(county_supply_code_procurement["supply_code"])
county_fips <- read_dta("C:/Users/Jairo/Dropbox/jairo-working-folder/county_fips_names.dta")
county_fips <- county_fips %>% select(countyname, statename, countyfipsfull)
county_system_code_procurement <- read_csv("C:/Users/Jairo/Dropbox/jairo-working-folder/county-system-code-procurement.csv", show_col_types = FALSE)
county_system_code_procurement <- county_system_code_procurement %>% mutate(join = paste(year, county_fips, sep = "_"))
system_codes <- unique(county_system_code_procurement["system_code"])
system_codes_names_research <- read_csv("C:/Users/Jairo/Dropbox/jairo-working-folder/weapons-system-names-research.csv", show_col_types = FALSE)
system_codes_names <- read_csv("C:/Users/Jairo/Dropbox/jairo-working-folder/weapons-system-names.csv", show_col_types = FALSE)
system_codes_names_research['type'] <- 'R'
system_codes_names['type'] <- 'NR'
system_codes_names <- system_codes_names %>% filter(!system_code %in% system_codes_names_research$system_code)
system_codes_names <- rbind(system_codes_names,system_codes_names_research)
county_pop <- read_csv("C:/Users/Jairo/Dropbox/jairo-working-folder/county-population.csv", show_col_types = FALSE)
county_pop <- county_pop %>% unite(join, c("year", "county_fips"))
county_patents <- read_csv("C:/Users/Jairo/Dropbox/jairo-working-folder/county-patent-metrics.csv", show_col_types = FALSE)
county_patents <- county_patents %>% mutate(join = paste(year, county_fips, sep = "_")) %>% select(join,year,county_fips,n_patents)
centroids <- tigris::counties(resolution = "20m") %>% st_centroid()
##
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|== | 4%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======= | 11%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========= | 14%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 22%
|
|================ | 23%
|
|================ | 24%
|
|================= | 24%
|
|================= | 25%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 29%
|
|===================== | 30%
|
|===================== | 31%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================= | 34%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 35%
|
|========================= | 36%
|
|========================== | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 42%
|
|============================== | 43%
|
|============================== | 44%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 49%
|
|=================================== | 50%
|
|=================================== | 51%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|===================================== | 54%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 59%
|
|========================================== | 60%
|
|========================================== | 61%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 62%
|
|============================================ | 63%
|
|============================================ | 64%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 69%
|
|================================================= | 70%
|
|================================================= | 71%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|=================================================== | 74%
|
|==================================================== | 74%
|
|==================================================== | 75%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 76%
|
|====================================================== | 77%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 79%
|
|======================================================== | 80%
|
|======================================================== | 81%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|========================================================== | 84%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 85%
|
|============================================================ | 86%
|
|============================================================= | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|=============================================================== | 91%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================= | 94%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 96%
|
|==================================================================== | 97%
|
|==================================================================== | 98%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 99%
|
|======================================================================| 100%
centroids <- centroids %>% as_tibble() %>%
mutate(long = map_dbl(geometry, first),
lat = map_dbl(geometry, 2)) %>%
rename("county_fips" = "GEOID")
map_data <- read_csv("C:/Users/Jairo/Dropbox/jairo-working-folder/map_data_format.csv", show_col_types = FALSE)
In the following graph, I present the evolution of correlation of exposures over time between certain year t and t-1. I start defining a vector of exposures per year, with stacked values of the distribution of military spendings for each county and item. Then, I regress this vector for certain year t over the vector for t-1, saving the coefficients and standard deviations from 1967 through 2003.
## `summarise()` has grouped output by 'county_fips'. You can override using the
## `.groups` argument.
## countyfipsfull 1977 1978 difference countyname
## 1 48439 5956796.876 12577345.0 6620548.1 Tarrant
## 2 28059 1147401.424 7074665.3 5927263.9 Jackson
## 3 9011 1514274.219 6497531.1 4983256.8 New London
## 4 6085 6759606.802 10083452.2 3323845.4 Santa Clara
## 5 9001 1950125.949 3436509.7 1486383.8 Fairfield
## 6 51700 2965701.344 4438188.9 1472487.6 Newport News City
## 7 27053 1430290.210 2356093.9 925803.7 Hennepin
## 8 13067 1147427.044 1926415.2 778988.1 Cobb
## 9 6097 58615.441 692592.8 633977.4 Sonoma
## 10 34005 566465.055 1150289.2 583824.2 Burlington
## 11 29101 0.000 428468.7 428468.7 Johnson
## 12 42101 945417.917 1307679.0 362261.1 Philadelphia
## 13 48375 43482.264 374631.4 331149.2 Potter
## 14 42045 792822.200 1096297.2 303475.0 Delaware
## 15 24031 1173389.154 1464787.1 291398.0 Montgomery
## 16 19057 77967.461 366530.0 288562.6 Des Moines
## 17 48113 3109325.614 3387254.7 277929.1 Dallas
## 18 6029 245922.670 519127.2 273204.6 Kern
## 19 18089 9125.169 280799.0 271673.8 Lake
## 20 6111 549679.355 785905.5 236226.2 Ventura
## statename
## 1 Texas
## 2 Mississippi
## 3 Connecticut
## 4 California
## 5 Connecticut
## 6 Virginia
## 7 Minnesota
## 8 Georgia
## 9 California
## 10 New Jersey
## 11 Missouri
## 12 Pennsylvania
## 13 Texas
## 14 Pennsylvania
## 15 Maryland
## 16 Iowa
## 17 Texas
## 18 California
## 19 Indiana
## 20 California
## countyfipsfull 1977 1978 difference countyname
## 2994 55029 381604.6 1.233854e+04 -369266.0 Door
## 2995 27003 376083.4 5.851880e+03 -370231.5 Anoka
## 2996 53033 6189085.2 5.806501e+06 -382583.8 King
## 2997 34007 880196.7 4.894870e+05 -390709.7 Camden
## 2998 24025 576909.7 1.714105e+05 -405499.2 Harford
## 2999 49003 520758.1 6.731051e+04 -453447.6 Box Elder
## 3000 6059 5058136.4 4.525463e+06 -532673.1 Orange
## 3001 36061 3379254.7 2.819551e+06 -559703.8 New York
## 3002 39061 1714122.7 1.143894e+06 -570228.9 Hamilton
## 3003 51153 1088154.0 5.086970e+05 -579457.0 Prince William
## 3004 42133 1474506.9 8.617856e+05 -612721.4 York
## 3005 26121 1009439.3 3.854187e+05 -624020.6 Muskegon
## 3006 25009 3955716.0 3.231059e+06 -724656.9 Essex
## 3007 16019 745381.6 4.959221e+02 -744885.6 Bonneville
## 3008 29510 10926273.5 1.015940e+07 -766877.8 St Louis City
## 3009 25017 5440321.7 4.650650e+06 -789671.8 Middlesex
## 3010 47031 1718661.8 5.985898e+05 -1120072.0 Coffee
## 3011 36059 8851572.1 7.095665e+06 -1755907.5 Nassau
## 3012 9003 9255001.1 6.484066e+06 -2770935.3 Hartford
## 3013 6037 24040649.0 1.854508e+07 -5495564.5 Los Angeles
## statename
## 2994 Wisconsin
## 2995 Minnesota
## 2996 Washington
## 2997 New Jersey
## 2998 Maryland
## 2999 Utah
## 3000 California
## 3001 New York
## 3002 Ohio
## 3003 Virginia
## 3004 Pennsylvania
## 3005 Michigan
## 3006 Massachusetts
## 3007 Idaho
## 3008 Missouri
## 3009 Massachusetts
## 3010 Tennessee
## 3011 New York
## 3012 Connecticut
## 3013 California
## countyfipsfull 1983 1984 difference countyname
## 1 29189 4866807.17 19341201.8 14474394.6 St Louis
## 2 39061 2916371.07 6665435.3 3749064.2 Hamilton
## 3 24005 1517446.28 4968867.6 3451421.3 Baltimore
## 4 36005 1393211.72 4429334.3 3036122.6 Bronx
## 5 6085 11217829.69 14095931.8 2878102.1 Santa Clara
## 6 48085 1144373.50 3787300.0 2642926.5 Collin
## 7 25017 8246565.85 10472394.7 2225828.8 Middlesex
## 8 12095 2208990.17 3721694.7 1512704.6 Orange
## 9 13067 4773186.13 6252731.9 1479545.7 Cobb
## 10 26125 619639.28 1986779.5 1367140.2 Oakland
## 11 26099 1199508.00 2464296.2 1264788.2 Macomb
## 12 6059 9091081.20 10337495.8 1246414.6 Orange
## 13 9003 4064063.77 5310013.6 1245949.8 Hartford
## 14 20173 4351414.51 5514731.5 1163317.0 Sedgwick
## 15 42101 1563382.16 2589362.9 1025980.7 Philadelphia
## 16 36103 2192836.07 3191430.8 998594.7 Suffolk
## 17 51700 2154523.67 3112001.2 957477.5 Newport News City
## 18 48121 291610.85 1174507.2 882896.3 Denton
## 19 48355 97192.35 839711.8 742519.4 Nueces
## 20 48039 355023.84 1066430.2 711406.3 Brazoria
## statename
## 1 Missouri
## 2 Ohio
## 3 Maryland
## 4 New York
## 5 California
## 6 Texas
## 7 Massachusetts
## 8 Florida
## 9 Georgia
## 10 Michigan
## 11 Michigan
## 12 California
## 13 Connecticut
## 14 Kansas
## 15 Pennsylvania
## 16 New York
## 17 Virginia
## 18 Texas
## 19 Texas
## 20 Texas
## countyfipsfull 1983 1984 difference countyname
## 2994 36059 10013591.1 9.520594e+06 -492997.3 Nassau
## 2995 25009 5318321.6 4.824067e+06 -494254.8 Essex
## 2996 53035 685786.6 1.885252e+05 -497261.4 Kitsap
## 2997 42045 1230116.3 7.266116e+05 -503504.7 Delaware
## 2998 51013 1700784.3 1.174744e+06 -526040.5 Arlington
## 2999 24031 3254006.2 2.719042e+06 -534964.3 Montgomery
## 3000 9013 866086.2 2.022973e+04 -845856.5 Tolland
## 3001 6065 963964.8 1.166316e+05 -847333.1 Riverside
## 3002 48273 1074891.4 1.621964e+05 -912694.9 Kleberg
## 3003 6073 6363841.8 5.354679e+06 -1009162.5 San Diego
## 3004 12099 3103036.1 1.839067e+06 -1263968.8 Palm Beach
## 3005 53033 8301157.1 6.817660e+06 -1483497.1 King
## 3006 6037 36561989.7 3.488109e+07 -1680902.3 Los Angeles
## 3007 9011 4247487.6 2.294315e+06 -1953172.9 New London
## 3008 39003 2199594.0 1.323836e+05 -2067210.5 Allen
## 3009 48439 10236476.2 8.012726e+06 -2223750.5 Tarrant
## 3010 24510 2546017.1 0.000000e+00 -2546017.1 Baltimore City
## 3011 36061 2691869.3 3.660926e+02 -2691503.2 New York
## 3012 48113 3366232.4 1.591830e+05 -3207049.3 Dallas
## 3013 29510 13816213.1 0.000000e+00 -13816213.1 St Louis City
## statename
## 2994 New York
## 2995 Massachusetts
## 2996 Washington
## 2997 Pennsylvania
## 2998 Virginia
## 2999 Maryland
## 3000 Connecticut
## 3001 California
## 3002 Texas
## 3003 California
## 3004 Florida
## 3005 Washington
## 3006 California
## 3007 Connecticut
## 3008 Ohio
## 3009 Texas
## 3010 Maryland
## 3011 New York
## 3012 Texas
## 3013 Missouri
## `summarise()` has grouped output by 'county_fips', 'year'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'year'. You can override using the
## `.groups` argument.
## supply_code 1977 1978 difference
## 1 19 9494006.24 21153174.3 11659168.0
## 2 15 25411354.45 26931475.5 1520121.1
## 3 J0 6099972.79 7547382.2 1447409.4
## 4 14 11889476.32 13304533.3 1415057.0
## 5 K0 3625168.82 4967667.1 1342498.2
## 6 R4 112700.32 1073988.6 961288.3
## 7 Y2 1412505.31 2327580.4 915075.1
## 8 13 5549285.69 6305514.0 756228.3
## 9 AR 1453899.50 2207499.8 753600.3
## 10 10 1491753.80 2057798.8 566045.0
## 11 V1 1591823.21 1993245.6 401422.4
## 12 34 206667.79 565363.0 358695.3
## 13 59 2699175.52 3047111.7 347936.2
## 14 M1 3172877.27 3409059.4 236182.2
## 15 25 1451610.74 1672832.4 221221.6
## 16 Z2 360220.00 528708.5 168488.4
## 17 M2 96854.04 261561.2 164707.2
## 18 S2 1080694.17 1220337.2 139643.0
## 19 99 309324.87 441477.7 132152.9
## 20 65 710328.45 834966.1 124637.7
## psc_description
## 1 SHIPS, SMALL CRAFT, PONTOON, DOCKS
## 2 AIRCRAFT/AIRFRAME STRUCTURE COMPTS
## 3 MAINT, REPAIR, REBUILD OF EQUIPMENT
## 4 GUIDED MISSLES
## 5 MODIFICATION OF EQUIPMENT
## 6 PROFESSIONAL SERVICES
## 7 CONSTRUCT NONBUILDING FACILITIES
## 8 AMMUNITION AND EXPLOSIVES
## 9 SPACE R&D
## 10 WEAPONS
## 11 TRANSPORTATION OF THINGS
## 12 METALWORKING MACHINERY
## 13 ELECTRICAL/ELECTRONIC EQPT COMPNTS
## 14 OPERATE GOVT OWNED BUILDINGS
## 15 VEHICULAR EQUIPMENT COMPONENTS
## 16 MAINT, ALTER, REPAIR NONBUILDINGS
## 17 OPERATE GOV OWNED NONBUILDING FACIL
## 18 HOUSEKEEPING SERVICES
## 19 MISCELLANEOUS
## 20 MEDICAL/DENTAL/VETERINARY EQPT/SUPP
## supply_code 1977 1978 difference
## 95 AP 148440.9 5792.37 -142648.6
## 96 16 2190412.1 2047118.62 -143293.5
## 97 Z9 974761.9 815593.41 -159168.5
## 98 12 2210451.6 2010241.86 -200209.8
## 99 AT 250128.7 43347.55 -206781.1
## 100 26 419002.0 211004.91 -207997.1
## 101 89 4439482.4 4214309.90 -225172.5
## 102 38 609208.6 358999.96 -250208.6
## 103 66 2864624.2 2595306.89 -269317.3
## 104 S1 3329580.8 3038839.74 -290741.1
## 105 W0 1733679.7 1372382.95 -361296.7
## 106 58 13281365.7 12901197.96 -380167.7
## 107 AC 26879584.4 26413363.96 -466220.4
## 108 49 1861760.8 1382511.66 -479249.2
## 109 18 2369290.2 1825913.58 -543376.6
## 110 61 1713311.4 1139775.67 -573535.7
## 111 44 2257414.0 1424093.73 -833320.3
## 112 23 4361314.2 2672968.29 -1688345.9
## 113 28 14108972.0 10260333.68 -3848638.3
## 114 Y1 11626473.3 6345774.94 -5280698.4
## psc_description
## 95 NATURAL RESOURCES R&D
## 96 AIRCRAFT COMPONENTS/ACCESSORIES
## 97 <NA>
## 98 FIRE CONTROL EQPT.
## 99 TRANSPORTATION (OTHER) R&D
## 100 TIRES AND TUBES
## 101 SUBSISTENCE
## 102 CONSTRUCT/MINE/EXCAVATE/HIGHWY EQPT
## 103 INSTRUMENTS AND LABORATORY EQPT
## 104 UTILITIES
## 105 LEASE OR RENTAL OF EQUIPMENT
## 106 COMM/DETECT/COHERENT RADIATION
## 107 DEFENSE SYSTEMS R&D
## 108 MAINT/REPAIR SHOP EQPT
## 109 SPACE VEHICLES
## 110 ELECTRIC WIRE, POWER DISTRIB EQPT
## 111 FURNACE/STEAM/DRYING; NUCL REACTOR
## 112 MOTOR VEHICLES, CYCLES, TRAILERS
## 113 ENGINES AND TURBINES AND COMPONENT
## 114 CONSTRUCTION OF BUILDINGS
## supply_code 1977 1978 difference
## 1 R4 112700.323 1073988.634 852.95967
## 2 AG 28827.336 92856.445 222.11247
## 3 34 206667.789 565363.042 173.56128
## 4 M2 96854.042 261561.193 170.05707
## 5 19 9494006.243 21153174.287 122.80557
## 6 Y2 1412505.310 2327580.399 64.78383
## 7 AR 1453899.503 2207499.817 51.83304
## 8 24 77638.665 115450.654 48.70252
## 9 Z2 360220.004 528708.451 46.77376
## 10 99 309324.875 441477.746 42.72300
## 11 51 29890.587 42149.407 41.01231
## 12 10 1491753.797 2057798.802 37.94493
## 13 11 126740.359 173989.293 37.28010
## 14 K0 3625168.825 4967667.071 37.03271
## 15 95 130071.024 172501.527 32.62103
## 16 T0 239743.858 313343.390 30.69924
## 17 V8 6789.433 8867.086 30.60127
## 18 V9 107738.486 136636.444 26.82232
## 19 V1 1591823.212 1993245.620 25.21778
## 20 80 10115.829 12560.714 24.16891
## psc_description
## 1 PROFESSIONAL SERVICES
## 2 ENERGY R&D
## 3 METALWORKING MACHINERY
## 4 OPERATE GOV OWNED NONBUILDING FACIL
## 5 SHIPS, SMALL CRAFT, PONTOON, DOCKS
## 6 CONSTRUCT NONBUILDING FACILITIES
## 7 SPACE R&D
## 8 TRACTORS
## 9 MAINT, ALTER, REPAIR NONBUILDINGS
## 10 MISCELLANEOUS
## 11 HAND TOOLS
## 12 WEAPONS
## 13 NUCLEAR ORDNANCE
## 14 MODIFICATION OF EQUIPMENT
## 15 METAL BARS, SHEETS, SHAPES
## 16 PHOTOGR, MAPPING, PRINTING, PUBLISH
## 17 <NA>
## 18 OTHER TRANSPORT, TRAVEL, RELOCAT SV
## 19 TRANSPORTATION OF THINGS
## 20 BRUSHES, PAINTS, SEALERS, ADHESIVES
## supply_code 1977 1978 difference
## 95 81 3.071386e+05 198515.6140 -35.36611
## 96 44 2.257414e+06 1424093.7337 -36.91482
## 97 23 4.361314e+06 2672968.2878 -38.71186
## 98 38 6.092086e+05 358999.9576 -41.07109
## 99 77 8.219911e+03 4566.4503 -44.44648
## 100 AS 2.318656e+03 1281.4626 -44.73252
## 101 Y1 1.162647e+07 6345774.9442 -45.41961
## 102 26 4.190020e+05 211004.9150 -49.64107
## 103 46 4.486150e+04 22376.0030 -50.12204
## 104 73 1.000950e+05 43660.9775 -56.38048
## 105 56 1.661746e+05 64144.5420 -61.39931
## 106 22 1.861330e+04 6078.0207 -67.34581
## 107 88 8.753672e+02 281.6837 -67.82108
## 108 87 3.817882e+04 11243.5448 -70.55031
## 109 AT 2.501287e+05 43347.5548 -82.66990
## 110 L5 6.123727e+04 8006.1656 -86.92599
## 111 Y9 1.102109e+04 1392.5491 -87.36468
## 112 K5 8.749402e+03 773.6384 -91.15781
## 113 AP 1.484409e+05 5792.3696 -96.09786
## 114 S7 2.476649e+02 0.0000 -100.00000
## psc_description
## 95 CONTAINERS/PACKAGING/PACKING SUPPL
## 96 FURNACE/STEAM/DRYING; NUCL REACTOR
## 97 MOTOR VEHICLES, CYCLES, TRAILERS
## 98 CONSTRUCT/MINE/EXCAVATE/HIGHWY EQPT
## 99 MUSICAL INST/PHONOGRAPH/HOME RADIO
## 100 TRANSPORTATION (MODAL) R&D
## 101 CONSTRUCTION OF BUILDINGS
## 102 TIRES AND TUBES
## 103 WATER PURIFICATION/SEWAGE TREATMENT
## 104 FOOD PREPARATION/SERVING EQPT
## 105 CONSTRUCTION AND BUILDING MATERIAL
## 106 RAILWAY EQUIPMENT
## 107 LIVE ANIMALS
## 108 AGRICULTURAL SUPPLIES
## 109 TRANSPORTATION (OTHER) R&D
## 110 <NA>
## 111 <NA>
## 112 <NA>
## 113 NATURAL RESOURCES R&D
## 114 <NA>
## supply_code 1983 1984 difference
## 1 14 16756013.5 24437402.3 7681388.9
## 2 AC 34318027.1 37533913.8 3215886.7
## 3 28 15120386.2 18013969.2 2893583.0
## 4 13 6494584.8 9310050.7 2815465.9
## 5 58 23717596.2 26214846.6 2497250.4
## 6 23 6679890.5 8489946.1 1810055.6
## 7 M1 5006896.9 6405136.0 1398239.0
## 8 69 1764556.0 2912886.6 1148330.6
## 9 12 4267379.4 5266588.0 999208.6
## 10 91 13810619.6 14694652.6 884033.0
## 11 K0 3943083.4 4682939.3 739855.9
## 12 AZ 2503447.2 2992224.1 488777.0
## 13 44 2201520.0 2662818.0 461298.0
## 14 AD 4244818.2 4668382.8 423564.6
## 15 61 1608837.2 1887857.3 279020.1
## 16 49 1795000.6 2052073.5 257072.9
## 17 54 277598.5 485672.9 208074.4
## 18 89 2819862.3 3014122.4 194260.1
## 19 66 3659912.2 3853373.5 193461.3
## 20 67 337710.5 505215.2 167504.8
## psc_description
## 1 GUIDED MISSLES
## 2 DEFENSE SYSTEMS R&D
## 3 ENGINES AND TURBINES AND COMPONENT
## 4 AMMUNITION AND EXPLOSIVES
## 5 COMM/DETECT/COHERENT RADIATION
## 6 MOTOR VEHICLES, CYCLES, TRAILERS
## 7 OPERATE GOVT OWNED BUILDINGS
## 8 TRAINING AIDS AND DEVICES
## 9 FIRE CONTROL EQPT.
## 10 FUELS, LUBRICANTS, OILS, WAXES
## 11 MODIFICATION OF EQUIPMENT
## 12 OTHER RESEARCH/DEVELOPMENT
## 13 FURNACE/STEAM/DRYING; NUCL REACTOR
## 14 DEFENSE (OTHER) R&D
## 15 ELECTRIC WIRE, POWER DISTRIB EQPT
## 16 MAINT/REPAIR SHOP EQPT
## 17 PREFAB STRUCTURES/SCAFFOLDING
## 18 SUBSISTENCE
## 19 INSTRUMENTS AND LABORATORY EQPT
## 20 PHOTOGRAPHIC EQPT
## supply_code 1983 1984 difference
## 95 20 640461.6 523201.1 -117260.5
## 96 36 394864.6 242517.7 -152346.9
## 97 U0 1171337.7 970409.3 -200928.4
## 98 J0 10600449.1 10337244.3 -263204.9
## 99 84 2059704.4 1759236.8 -300467.6
## 100 L0 1742670.6 1382549.9 -360120.8
## 101 59 4929099.9 4494302.0 -434797.9
## 102 99 1089725.1 623393.4 -466331.6
## 103 Y2 3801701.9 3322985.0 -478716.8
## 104 S1 4459214.3 3927125.0 -532089.3
## 105 16 7042966.7 6476740.7 -566226.0
## 106 18 3051028.5 2484550.8 -566477.6
## 107 AR 4812153.5 4224100.8 -588052.8
## 108 R4 6820965.3 6203451.3 -617514.0
## 109 25 3389053.5 2757451.7 -631601.8
## 110 10 3828871.4 3143828.8 -685042.6
## 111 W0 2869551.5 2116754.8 -752796.6
## 112 15 51578051.3 50338136.5 -1239914.8
## 113 19 13432977.4 12143052.0 -1289925.4
## 114 V1 4615848.0 2741206.6 -1874641.4
## psc_description
## 95 SHIP AND MARINE EQUIPMENT
## 96 SPECIAL INDUSTRY MACHINERY
## 97 EDUCATION AND TRAINING SERVICES
## 98 MAINT, REPAIR, REBUILD OF EQUIPMENT
## 99 CLOTHING/INDIVIDUAL EQPT, INSIGNIA
## 100 TECHNICAL REPRESENTATIVE SERVICES
## 101 ELECTRICAL/ELECTRONIC EQPT COMPNTS
## 102 MISCELLANEOUS
## 103 CONSTRUCT NONBUILDING FACILITIES
## 104 UTILITIES
## 105 AIRCRAFT COMPONENTS/ACCESSORIES
## 106 SPACE VEHICLES
## 107 SPACE R&D
## 108 PROFESSIONAL SERVICES
## 109 VEHICULAR EQUIPMENT COMPONENTS
## 110 WEAPONS
## 111 LEASE OR RENTAL OF EQUIPMENT
## 112 AIRCRAFT/AIRFRAME STRUCTURE COMPTS
## 113 SHIPS, SMALL CRAFT, PONTOON, DOCKS
## 114 TRANSPORTATION OF THINGS
## supply_code 1983 1984 difference
## 1 22 3.280206e+03 73701.660 2146.86054
## 2 AS 3.152845e+03 16743.132 431.04841
## 3 P1 1.219810e+04 40947.580 235.68806
## 4 88 4.704575e+02 1394.638 196.44304
## 5 46 3.117236e+04 83613.554 168.22982
## 6 54 2.775985e+05 485672.869 74.95515
## 7 69 1.764556e+06 2912886.636 65.07760
## 8 67 3.377105e+05 505215.240 49.60010
## 9 81 3.311995e+05 490509.276 48.10087
## 10 14 1.675601e+07 24437402.325 45.84258
## 11 78 1.140534e+04 16573.783 45.31594
## 12 13 6.494585e+06 9310050.741 43.35098
## 13 93 5.549579e+04 79335.003 42.95680
## 14 32 2.723975e+03 3855.179 41.52771
## 15 31 1.845909e+05 260286.848 41.00743
## 16 71 2.686936e+05 377922.108 40.65170
## 17 AN 2.151082e+05 296158.940 37.67904
## 18 41 2.724339e+05 365649.290 34.21580
## 19 X1 4.847012e+04 64125.973 32.30002
## 20 80 1.063598e+04 13894.085 30.63289
## psc_description
## 1 RAILWAY EQUIPMENT
## 2 TRANSPORTATION (MODAL) R&D
## 3 DISPOSAL OF EXCESS/SURPLUS PROPERTY
## 4 LIVE ANIMALS
## 5 WATER PURIFICATION/SEWAGE TREATMENT
## 6 PREFAB STRUCTURES/SCAFFOLDING
## 7 TRAINING AIDS AND DEVICES
## 8 PHOTOGRAPHIC EQPT
## 9 CONTAINERS/PACKAGING/PACKING SUPPL
## 10 GUIDED MISSLES
## 11 RECREATIONAL/ATHLETIC EQPT
## 12 AMMUNITION AND EXPLOSIVES
## 13 NONMETALLIC FABRICATED MATERIALS
## 14 WOODWORKING MACHINERY AND EQPT
## 15 BEARINGS
## 16 FURNITURE
## 17 MEDICAL R&D
## 18 REFRIG, AIR CONDIT/CIRCULAT EQPT
## 19 LEASE/RENTAL OF BUILDINGS
## 20 BRUSHES, PAINTS, SEALERS, ADHESIVES
## supply_code 1983 1984 difference
## 95 95 164758.885 122177.797 -25.84449
## 96 W0 2869551.451 2116754.802 -26.23395
## 97 11 123283.251 84604.744 -31.37369
## 98 Q9 6318.686 4193.877 -33.62738
## 99 AG 151055.837 94230.239 -37.61894
## 100 V9 5182.830 3225.101 -37.77335
## 101 36 394864.573 242517.660 -38.58207
## 102 37 9648.277 5854.991 -39.31568
## 103 52 12842.709 7663.040 -40.33159
## 104 V1 4615848.000 2741206.646 -40.61315
## 105 99 1089725.061 623393.413 -42.79351
## 106 24 117731.333 35035.310 -70.24130
## 107 AT 14165.708 3207.668 -77.35610
## 108 K5 0.000 0.000 NaN
## 109 L5 0.000 0.000 NaN
## 110 N6 0.000 0.000 NaN
## 111 S7 0.000 0.000 NaN
## 112 V8 0.000 0.000 NaN
## 113 Y9 0.000 0.000 NaN
## 114 Z9 0.000 0.000 NaN
## psc_description
## 95 METAL BARS, SHEETS, SHAPES
## 96 LEASE OR RENTAL OF EQUIPMENT
## 97 NUCLEAR ORDNANCE
## 98 OTHER MEDICAL SERVICES
## 99 ENERGY R&D
## 100 OTHER TRANSPORT, TRAVEL, RELOCAT SV
## 101 SPECIAL INDUSTRY MACHINERY
## 102 AGRICULTURAL MACHINERY AND EQPT
## 103 MEASURING TOOLS
## 104 TRANSPORTATION OF THINGS
## 105 MISCELLANEOUS
## 106 TRACTORS
## 107 TRANSPORTATION (OTHER) R&D
## 108 <NA>
## 109 <NA>
## 110 <NA>
## 111 <NA>
## 112 <NA>
## 113 <NA>
## 114 <NA>
In the following plots, I present the evolution of military spendings per items, using a logarithmic transformation. For visualization and analysis purposes, graphs per clusters of items are displayed.
To define the clusters, we follow a procedure: after transforming military spending time series to logarithmic values and excluding certain items (items with no description and items exhibiting strange behavior - NONMETALLIC CRUDE MATERIALS, SALVAGE OF MARINE VESSELS -), the dynamic time-warping algorithm (DTW) is used to calculate a measure of alignment between each pair of time series, so the values over time per time are used as covariates. These alignment scores are used to define a distance matrix that can be used to define clusters of items. A Ward Hierarchical Clustering is used to define 18 clusters of items:
## `summarise()` has grouped output by 'county_fips', 'year'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'year'. You can override using the
## `.groups` argument.
The resulting 18 clusters can be reclassified into 9 after visual inspection and heuristic classification. The evolution of items per cluster and a brief description of what they are about is presented as follows:
In the following graph, I present the evolution of the average number of items that are new or are dropped for each county, so we compare the items in certain year t with the items in t-1 to obtain a measure of innovation over time.
## `summarise()` has grouped output by 'county_fips', 'year'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'county_fips'. You can override using the
## `.groups` argument.
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
## Warning in RColorBrewer::brewer.pal(N, "Set2"): minimal value for n is 3, returning requested palette with 3 different levels
I am going to define clusters of counties using the total number of items over time as covariates. In particular, I define groups of counties according to 4 levels of exposure, defined using again Ward Hierarchical Clustering.
Four clusters of counties are defined, each one represented here by a number:
1: Lowest exposure (lowest # of items) in average. 2: Semi-low exposure in average. 3: Semi-high exposure in average. 4: Highest exposure (largest # of items) in average.
As can be observed in the next table, the average number of items is stable over time, so the analysis is not biased by changes in trend.
## `summarise()` has grouped output by 'county_fips'. You can override using the
## `.groups` argument.
## V1 V2 V3 V4
## cluster 1.0000000 2.000000 3.000000 4.00000
## 1966 0.3267760 1.602459 5.436170 24.59880
## 1967 0.2939891 1.509836 5.111702 24.74850
## 1968 0.1934426 1.415574 4.750000 24.17565
## 1969 0.2021858 1.440164 4.444149 23.74451
## 1970 0.1464481 1.256557 4.095745 22.48503
## 1971 0.1661202 1.263115 4.183511 22.74052
## 1972 0.1879781 1.333607 4.507979 23.47305
## 1973 0.1836066 1.347541 4.542553 23.37525
## 1974 0.1912568 1.313934 4.585106 23.87824
## 1975 0.1748634 1.184426 4.462766 23.73253
## 1976 0.2174863 1.183607 4.188830 23.44711
## 1977 0.1934426 1.243443 4.534574 24.41517
## 1978 0.1934426 1.418033 4.933511 25.87226
## 1979 0.1879781 1.337705 4.936170 26.13174
## 1980 0.2076503 1.405738 4.946809 27.06786
## 1981 0.1825137 1.447541 5.271277 27.73852
## 1982 0.2065574 1.522131 5.566489 27.85230
## 1983 0.3071038 1.781148 6.138298 29.67864
## 1984 0.3573770 1.913934 6.420213 29.19361
## 1985 0.3967213 1.961475 6.651596 30.32136
## 1986 0.3868852 1.924590 6.648936 30.19960
## 1987 0.3836066 1.963115 6.433511 30.21956
## 1988 0.3016393 1.790984 5.930851 30.34531
## 1989 0.2207650 1.625410 5.348404 28.47106
## 1990 0.2316940 1.513115 5.090426 28.15569
## 1991 0.2415301 1.572951 5.055851 28.52096
## 1992 0.2076503 1.433607 4.760638 27.81238
## 1993 0.2087432 1.334426 4.500000 26.53693
## 1994 0.2251366 1.441803 4.773936 26.46906
## 1995 0.2469945 1.524590 4.763298 26.79641
## 1996 0.2469945 1.498361 4.917553 27.71457
## 1997 0.2306011 1.432787 4.561170 26.79042
## 1998 0.2448087 1.371311 4.401596 26.38922
## 1999 0.2448087 1.375410 4.404255 27.07784
## 2000 0.4076503 1.424590 4.723404 27.67066
## 2001 0.6513661 1.565574 5.191489 29.49501
## 2002 0.7136612 1.738525 5.593085 31.27345
## 2003 0.7245902 1.704918 5.611702 30.47705
For each of these 4 groups, we repeat the analysis presented above.
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `summarise()` has grouped output by 'year'. You can override using the
## `.groups` argument.
## `summarise()` has grouped output by 'county_fips', 'year'. You can override
## using the `.groups` argument.
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `growth_77_80_83_86 = log(...)`.
## Caused by warning in `log()`:
## ! Se han producido NaNs
## `summarise()` has grouped output by 'county_fips', 'year'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'county_fips', 'year'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'year'. You can override using the
## `.groups` argument.
## Selecting by total_spending
##
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
## 23 5 10 6 10 13 4 1 26 17 10 10 20 11 7 9 4 3 1 3 5 2