Cleanup and added need file
This commit is contained in:
parent
be73496390
commit
353e531d0d
42
Causes.r
42
Causes.r
@ -1,42 +0,0 @@
|
||||
library(tidyverse)
|
||||
library(factoextra)
|
||||
library(fixest)
|
||||
library(corrplot)
|
||||
################################Other work
|
||||
DF1999 <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_Single_Age_1999-2020.csv") %>% select(Year,Sex,Age=`Single-Year Ages Code`,Mortality_Rate=`Crude Rate`) %>% mutate(Mortality_Rate=parse_number(Mortality_Rate)) %>% filter(!is.na(Mortality_Rate)) %>% mutate(Mortality_Rate=as.numeric(Mortality_Rate))
|
||||
DF2018 <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_Single_Age_2018-2023.csv") %>% select(Year,Sex,Age=`Single-Year Ages Code`,Mortality_Rate=`Crude Rate`) %>% filter(!is.na(Mortality_Rate))%>% mutate(Mortality_Rate=parse_number(Mortality_Rate)) %>% filter(!is.na(Mortality_Rate)) %>% mutate(Mortality_Rate=as.numeric(Mortality_Rate))
|
||||
|
||||
OLDER1 <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_10_Year_Age_Groups_1999-2020.csv")%>% rename(Age=`Ten-Year Age Groups Code`,Mortality_Rate=`Crude Rate`) %>% filter(Age=='85+')%>% mutate(Age=85,Year=as.numeric(Year),Mortality_Rate=parse_number(Mortality_Rate)) %>% select(Year,Sex,Age,Mortality_Rate) %>% mutate(Mortality_Rate=as.numeric(Mortality_Rate),Age=as.numeric(Age))
|
||||
OLDER2 <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_10_Year_Age_Groups_2018-2023.csv")%>% rename(Age=`Ten-Year Age Groups Code`,Mortality_Rate=`Crude Rate`) %>% filter(Age=='85+')%>% mutate(Age=85,Year=as.numeric(Year),Mortality_Rate=parse_number(Mortality_Rate)) %>% select(Year,Sex,Age,Mortality_Rate)%>% mutate(Mortality_Rate=as.numeric(Mortality_Rate),Age=as.numeric(Age))
|
||||
|
||||
#NOTE should add 85+ for 2018-2023
|
||||
DF <- rbind(DF1999,DF2018,OLDER1,OLDER2) %>% unique %>% group_by(Year,Sex,Age) %>% arrange(Year,Sex,Age) %>% mutate(Age=as.numeric(Age)) %>% ungroup
|
||||
|
||||
US_CAUSES <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_Cause_of_Death_1999-2020.csv") %>% select(Year,ICD=`ICD Sub-Chapter Code`,Death_Rate=`Crude Rate`) %>% filter(!is.na(Death_Rate)) %>% mutate(Death_Rate=ifelse(Death_Rate=='Suppressed' |Death_Rate=='Unreliable',NA,Death_Rate)) %>% rbind(read_csv("Data/Raw_Data/Mortality_Rates_New/US_Cause_of_Death_2018-2023.csv") %>% select(Year,ICD=`ICD Sub-Chapter Code`,Death_Rate=`Crude Rate`) %>% filter(!is.na(Death_Rate)) %>% mutate(Death_Rate=ifelse(Death_Rate=='Suppressed' |Death_Rate=='Unreliable',NA,Death_Rate))) %>% mutate(Death_Rate=parse_number(Death_Rate)) %>% arrange(Year,ICD) %>% group_by(ICD) %>% filter(max(is.na(Death_Rate))==0,min(Death_Rate)!=max(Death_Rate)) %>% ungroup %>% unique
|
||||
US_CAUSES <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_Cause_of_Death_1999-2020.csv") %>% select(Year,ICD=`ICD Sub-Chapter Code`,Death_Rate=`Crude Rate`) %>% filter(!is.na(Death_Rate)) %>% mutate(Death_Rate=ifelse(Death_Rate=='Suppressed' |Death_Rate=='Unreliable',NA,Death_Rate)) %>% rbind(read_csv("Data/Raw_Data/Mortality_Rates_New/US_Cause_of_Death_2018-2023.csv") %>% select(Year,ICD=`ICD Sub-Chapter Code`,Death_Rate=`Crude Rate`) %>% filter(!is.na(Death_Rate)) %>% mutate(Death_Rate=ifelse(Death_Rate=='Suppressed' |Death_Rate=='Unreliable',NA,Death_Rate))) %>% mutate(Death_Rate=parse_number(Death_Rate)) %>% arrange(Year,ICD) %>% group_by(ICD) %>% filter(max(is.na(Death_Rate))==0,min(Death_Rate)!=max(Death_Rate)) %>% ungroup %>% unique
|
||||
BIND <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_Cause_of_Death_1999-2020.csv") %>% select(ICD=`ICD Sub-Chapter Code`,NAME=`ICD Sub-Chapter`) %>% unique
|
||||
US_CAUSES <- US_CAUSES %>% left_join(BIND) %>% select(-ICD) %>% rename(ICD=NAME)
|
||||
|
||||
#hist(US_CAUSES$Death_Rate,breaks=150)
|
||||
US_CAUSES
|
||||
CAUSE_SUMMARY <- US_CAUSES %>% group_by(ICD) %>% summarize(Rate=mean(Death_Rate)) %>% summarize(ICD,Rate, Rank=rank(desc(Rate))) %>% arrange(Rank) %>% ungroup %>% filter(Rank<=40)
|
||||
CAUSE_SUMMARY %>% print(n=100)
|
||||
|
||||
ICD_WIDE <- US_CAUSES %>% inner_join(CAUSE_SUMMARY %>% print(n=40) %>% select(ICD_RANK=Rank,ICD)) %>% select(-ICD) %>% unique %>% pivot_wider(values_from=Death_Rate,names_from=ICD_RANK,names_prefix="ICD_")
|
||||
ICD_WIDE <- ICD_WIDE %>% select(c("Year",sort(colnames(ICD_WIDE[,-1]))))
|
||||
####
|
||||
US_AGE_ADJ <- rbind(read_csv("Data/Raw_Data/Mortality_Rates_New/US_Age_Adjusted_1979-1998.csv") %>% select(Year,Sex,US_Adj_Death_Rate=`Crude Rate`),read_csv("Data/Raw_Data/Mortality_Rates_New/US_Age_Adjusted_1999-2020.csv") %>% select(Year,Sex,US_Adj_Death_Rate=`Crude Rate`),read_csv("Data/Raw_Data/Mortality_Rates_New/US_Age_Adjusted_2018-2023.csv") %>% select(Year,Sex,US_Adj_Death_Rate=`Crude Rate`)) %>% unique
|
||||
####
|
||||
REG_DATA <- DF %>% left_join(US_AGE_ADJ) %>% left_join(ICD_WIDE)
|
||||
#REG_DATA <- DF %>% left_join(ICD_WIDE)
|
||||
|
||||
TEST <- REG_DATA %>% pivot_wider(values_from=Mortality_Rate,names_from=Age,names_prefix="Age_")
|
||||
TEST[,4:129] <- TEST[,4:129]/t(TEST[,3])
|
||||
REG_DATA %>% pivot_wider(values_from=Mortality_Rate,names_from=Age,names_prefix="Age_") %>% group_by(Sex)
|
||||
REG_DATA
|
||||
MOD <- feols(Age_.[0:85]~US_Adj_Death_Rate+Sex*Year,TEST %>% filter(Sex=="Male"))
|
||||
summary(MOD[[1]])
|
||||
acf(resid(MOD[[43]]))
|
||||
predict(MOD[[2]],TEST[1,])
|
||||
|
||||
|
||||
@ -0,0 +1,204 @@
|
||||
"Notes","Year","Year Code","Sex","Sex Code","Ten-Year Age Groups","Ten-Year Age Groups Code",Deaths,Population,Crude Rate,Crude Rate Standard Error,% of Total Deaths
|
||||
,"2018","2018","Female","F","< 1 year","1",9399,1879703,500.0,5.2,0.0%
|
||||
,"2018","2018","Female","F","1-4 years","1-4",1587,7798370,20.4,0.5,0.0%
|
||||
,"2018","2018","Female","F","5-14 years","5-14",2369,20100339,11.8,0.2,0.0%
|
||||
,"2018","2018","Female","F","15-24 years","15-24",8146,20994345,38.8,0.4,0.0%
|
||||
,"2018","2018","Female","F","25-34 years","25-34",17980,22487065,80.0,0.6,0.1%
|
||||
,"2018","2018","Female","F","35-44 years","35-44",29004,20690288,140.2,0.8,0.2%
|
||||
,"2018","2018","Female","F","45-54 years","45-54",63807,21090497,302.5,1.2,0.3%
|
||||
,"2018","2018","Female","F","55-64 years","55-64",146563,21873773,670.0,1.8,0.8%
|
||||
,"2018","2018","Female","F","65-74 years","65-74",230867,16246231,1421.0,3.0,1.2%
|
||||
,"2018","2018","Female","F","75-84 years","75-84",328017,8659334,3788.0,6.6,1.7%
|
||||
,"2018","2018","Female","F","85+ years","85+",542962,4218810,12870.0,17.5,2.9%
|
||||
,"2018","2018","Female","F","Not Stated","NS",35,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2018","2018","Male","M","< 1 year","1",12068,1968505,613.1,5.6,0.1%
|
||||
,"2018","2018","Male","M","1-4 years","1-4",2243,8163697,27.5,0.6,0.0%
|
||||
,"2018","2018","Male","M","5-14 years","5-14",3081,20974830,14.7,0.3,0.0%
|
||||
,"2018","2018","Male","M","15-24 years","15-24",22008,21976455,100.1,0.7,0.1%
|
||||
,"2018","2018","Male","M","25-34 years","25-34",40864,23210709,176.1,0.9,0.2%
|
||||
,"2018","2018","Male","M","35-44 years","35-44",51376,20587600,249.5,1.1,0.3%
|
||||
,"2018","2018","Male","M","45-54 years","45-54",101030,20541202,491.8,1.5,0.5%
|
||||
,"2018","2018","Male","M","55-64 years","55-64",228273,20398863,1119.0,2.3,1.2%
|
||||
,"2018","2018","Male","M","65-74 years","65-74",312911,14246085,2196.5,3.9,1.7%
|
||||
,"2018","2018","Male","M","75-84 years","75-84",347188,6735040,5155.0,8.7,1.8%
|
||||
,"2018","2018","Male","M","85+ years","85+",337318,2325693,14504.0,25.0,1.8%
|
||||
,"2018","2018","Male","M","Not Stated","NS",109,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2019","2019","Female","F","< 1 year","1",9247,1847935,500.4,5.2,0.0%
|
||||
,"2019","2019","Female","F","1-4 years","1-4",1635,7719541,21.2,0.5,0.0%
|
||||
,"2019","2019","Female","F","5-14 years","5-14",2311,20053140,11.5,0.2,0.0%
|
||||
,"2019","2019","Female","F","15-24 years","15-24",8023,20877151,38.4,0.4,0.0%
|
||||
,"2019","2019","Female","F","25-34 years","25-34",17827,22581141,78.9,0.6,0.1%
|
||||
,"2019","2019","Female","F","35-44 years","35-44",29550,20867064,141.6,0.8,0.2%
|
||||
,"2019","2019","Female","F","45-54 years","45-54",61546,20702936,297.3,1.2,0.3%
|
||||
,"2019","2019","Female","F","55-64 years","55-64",147012,21949318,669.8,1.7,0.8%
|
||||
,"2019","2019","Female","F","65-74 years","65-74",235312,16783854,1402.0,2.9,1.2%
|
||||
,"2019","2019","Female","F","75-84 years","75-84",332927,8971649,3710.9,6.4,1.8%
|
||||
,"2019","2019","Female","F","85+ years","85+",535581,4228470,12666.1,17.3,2.8%
|
||||
,"2019","2019","Female","F","Not Stated","NS",44,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2019","2019","Male","M","< 1 year","1",11674,1935117,603.3,5.6,0.1%
|
||||
,"2019","2019","Male","M","1-4 years","1-4",2041,8074090,25.3,0.6,0.0%
|
||||
,"2019","2019","Male","M","5-14 years","5-14",3186,20941023,15.2,0.3,0.0%
|
||||
,"2019","2019","Male","M","15-24 years","15-24",21748,21810359,99.7,0.7,0.1%
|
||||
,"2019","2019","Male","M","25-34 years","25-34",41351,23359180,177.0,0.9,0.2%
|
||||
,"2019","2019","Male","M","35-44 years","35-44",53436,20792080,257.0,1.1,0.3%
|
||||
,"2019","2019","Male","M","45-54 years","45-54",98847,20171966,490.0,1.6,0.5%
|
||||
,"2019","2019","Male","M","55-64 years","55-64",227925,20499219,1111.9,2.3,1.2%
|
||||
,"2019","2019","Male","M","65-74 years","65-74",320247,14699579,2178.6,3.8,1.7%
|
||||
,"2019","2019","Male","M","75-84 years","75-84",355100,6998223,5074.1,8.5,1.9%
|
||||
,"2019","2019","Male","M","85+ years","85+",338165,2376488,14229.6,24.5,1.8%
|
||||
,"2019","2019","Male","M","Not Stated","NS",103,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2020","2020","Female","F","< 1 year","1",8723,1826869,477.5,5.1,0.0%
|
||||
,"2020","2020","Female","F","1-4 years","1-4",1503,7613266,19.7,0.5,0.0%
|
||||
,"2020","2020","Female","F","5-14 years","5-14",2261,20050413,11.3,0.2,0.0%
|
||||
,"2020","2020","Female","F","15-24 years","15-24",9332,20828241,44.8,0.5,0.0%
|
||||
,"2020","2020","Female","F","25-34 years","25-34",21654,22625267,95.7,0.7,0.1%
|
||||
,"2020","2020","Female","F","35-44 years","35-44",35996,21090324,170.7,0.9,0.2%
|
||||
,"2020","2020","Female","F","45-54 years","45-54",71298,20441441,348.8,1.3,0.4%
|
||||
,"2020","2020","Female","F","55-64 years","55-64",169422,21914243,773.1,1.9,0.9%
|
||||
,"2020","2020","Female","F","65-74 years","65-74",282508,17365858,1626.8,3.1,1.5%
|
||||
,"2020","2020","Female","F","75-84 years","75-84",393226,9228272,4261.1,6.8,2.1%
|
||||
,"2020","2020","Female","F","85+ years","85+",617885,4243727,14560.0,18.5,3.3%
|
||||
,"2020","2020","Female","F","Not Stated","NS",37,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2020","2020","Male","M","< 1 year","1",10859,1908141,569.1,5.5,0.1%
|
||||
,"2020","2020","Male","M","1-4 years","1-4",2026,7953016,25.5,0.6,0.0%
|
||||
,"2020","2020","Male","M","5-14 years","5-14",3362,20941721,16.1,0.3,0.0%
|
||||
,"2020","2020","Male","M","15-24 years","15-24",26484,21727443,121.9,0.7,0.1%
|
||||
,"2020","2020","Male","M","25-34 years","25-34",51832,23444379,221.1,1.0,0.3%
|
||||
,"2020","2020","Male","M","35-44 years","35-44",68494,21045868,325.5,1.2,0.4%
|
||||
,"2020","2020","Male","M","45-54 years","45-54",119844,19924692,601.5,1.7,0.6%
|
||||
,"2020","2020","Male","M","55-64 years","55-64",271127,20489434,1323.3,2.5,1.4%
|
||||
,"2020","2020","Male","M","65-74 years","65-74",391999,15183540,2581.7,4.1,2.1%
|
||||
,"2020","2020","Male","M","75-84 years","75-84",428858,7223275,5937.2,9.1,2.3%
|
||||
,"2020","2020","Male","M","85+ years","85+",394920,2414693,16354.9,26.0,2.1%
|
||||
,"2020","2020","Male","M","Not Stated","NS",79,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2021","2021","Female","F","< 1 year","1",9011,1742991,517.0,5.4,0.0%
|
||||
,"2021","2021","Female","F","1-4 years","1-4",1711,7459995,22.9,0.6,0.0%
|
||||
,"2021","2021","Female","F","5-14 years","5-14",2481,20374951,12.2,0.2,0.0%
|
||||
,"2021","2021","Female","F","15-24 years","15-24",10396,21092449,49.3,0.5,0.1%
|
||||
,"2021","2021","Female","F","25-34 years","25-34",24364,22441743,108.6,0.7,0.1%
|
||||
,"2021","2021","Female","F","35-44 years","35-44",43350,21546241,201.2,1.0,0.2%
|
||||
,"2021","2021","Female","F","45-54 years","45-54",80263,20376477,393.9,1.4,0.4%
|
||||
,"2021","2021","Female","F","55-64 years","55-64",185210,21839746,848.0,2.0,1.0%
|
||||
,"2021","2021","Female","F","65-74 years","65-74",305325,17797036,1715.6,3.1,1.6%
|
||||
,"2021","2021","Female","F","75-84 years","75-84",397264,9037561,4395.7,7.0,2.1%
|
||||
,"2021","2021","Female","F","85+ years","85+",566725,3799813,14914.5,19.8,3.0%
|
||||
,"2021","2021","Female","F","Not Stated","NS",23,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2021","2021","Male","M","< 1 year","1",10909,1821502,598.9,5.7,0.1%
|
||||
,"2021","2021","Male","M","1-4 years","1-4",2105,7802850,27.0,0.6,0.0%
|
||||
,"2021","2021","Male","M","5-14 years","5-14",3494,21364381,16.4,0.3,0.0%
|
||||
,"2021","2021","Male","M","15-24 years","15-24",27911,21996214,126.9,0.8,0.1%
|
||||
,"2021","2021","Male","M","25-34 years","25-34",57910,23053362,251.2,1.0,0.3%
|
||||
,"2021","2021","Male","M","35-44 years","35-44",81589,21857613,373.3,1.3,0.4%
|
||||
,"2021","2021","Male","M","45-54 years","45-54",135774,20311959,668.4,1.8,0.7%
|
||||
,"2021","2021","Male","M","55-64 years","55-64",292961,20963318,1397.5,2.6,1.5%
|
||||
,"2021","2021","Male","M","65-74 years","65-74",418941,15869086,2640.0,4.1,2.2%
|
||||
,"2021","2021","Male","M","75-84 years","75-84",432389,7168514,6031.8,9.2,2.3%
|
||||
,"2021","2021","Male","M","85+ years","85+",374055,2175943,17190.5,28.1,2.0%
|
||||
,"2021","2021","Male","M","Not Stated","NS",70,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2022","2022","Female","F","< 1 year","1",9182,1800246,510.0,5.3,0.0%
|
||||
,"2022","2022","Female","F","1-4 years","1-4",1803,7263012,24.8,0.6,0.0%
|
||||
,"2022","2022","Female","F","5-14 years","5-14",2652,19965235,13.3,0.3,0.0%
|
||||
,"2022","2022","Female","F","15-24 years","15-24",9595,21657540,44.3,0.5,0.1%
|
||||
,"2022","2022","Female","F","25-34 years","25-34",21858,22311738,98.0,0.7,0.1%
|
||||
,"2022","2022","Female","F","35-44 years","35-44",38119,21575176,176.7,0.9,0.2%
|
||||
,"2022","2022","Female","F","45-54 years","45-54",68437,20152015,339.6,1.3,0.4%
|
||||
,"2022","2022","Female","F","55-64 years","55-64",163263,21413534,762.4,1.9,0.9%
|
||||
,"2022","2022","Female","F","65-74 years","65-74",283596,17877767,1586.3,3.0,1.5%
|
||||
,"2022","2022","Female","F","75-84 years","75-84",397396,9785700,4061.0,6.4,2.1%
|
||||
,"2022","2022","Female","F","85+ years","85+",564690,4202041,13438.5,17.9,3.0%
|
||||
,"2022","2022","Female","F","Not Stated","NS",16,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2022","2022","Male","M","< 1 year","1",11371,1882867,603.9,5.7,0.1%
|
||||
,"2022","2022","Male","M","1-4 years","1-4",2353,7592228,31.0,0.6,0.0%
|
||||
,"2022","2022","Male","M","5-14 years","5-14",3587,20933799,17.1,0.3,0.0%
|
||||
,"2022","2022","Male","M","15-24 years","15-24",25637,22684031,113.0,0.7,0.1%
|
||||
,"2022","2022","Male","M","25-34 years","25-34",52511,23189562,226.4,1.0,0.3%
|
||||
,"2022","2022","Male","M","35-44 years","35-44",73486,22120189,332.2,1.2,0.4%
|
||||
,"2022","2022","Male","M","45-54 years","45-54",114847,20279630,566.3,1.7,0.6%
|
||||
,"2022","2022","Male","M","55-64 years","55-64",254278,20671903,1230.1,2.4,1.3%
|
||||
,"2022","2022","Male","M","65-74 years","65-74",384985,15910672,2419.7,3.9,2.0%
|
||||
,"2022","2022","Male","M","75-84 years","75-84",427507,7734845,5527.0,8.5,2.3%
|
||||
,"2022","2022","Male","M","85+ years","85+",368601,2283827,16139.6,26.6,1.9%
|
||||
,"2022","2022","Male","M","Not Stated","NS",87,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2023 ","2023","Female","F","< 1 year","1",9038,1784146,506.6,5.3,0.0%
|
||||
,"2023 ","2023","Female","F","1-4 years","1-4",1730,7267615,23.8,0.6,0.0%
|
||||
,"2023 ","2023","Female","F","5-14 years","5-14",2487,20014683,12.4,0.2,0.0%
|
||||
,"2023 ","2023","Female","F","15-24 years","15-24",9043,21463206,42.1,0.4,0.0%
|
||||
,"2023 ","2023","Female","F","25-34 years","25-34",19616,22483329,87.2,0.6,0.1%
|
||||
,"2023 ","2023","Female","F","35-44 years","35-44",35522,22028457,161.3,0.9,0.2%
|
||||
,"2023 ","2023","Female","F","45-54 years","45-54",61893,20306672,304.8,1.2,0.3%
|
||||
,"2023 ","2023","Female","F","55-64 years","55-64",146890,21350566,688.0,1.8,0.8%
|
||||
,"2023 ","2023","Female","F","65-74 years","65-74",266363,18350204,1451.6,2.8,1.4%
|
||||
,"2023 ","2023","Female","F","75-84 years","75-84",386472,10205598,3786.9,6.1,2.0%
|
||||
,"2023 ","2023","Female","F","85+ years","85+",534800,3911019,13674.2,18.7,2.8%
|
||||
,"2023 ","2023","Female","F","Not Stated","NS",25,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
,"2023 ","2023","Male","M","< 1 year","1",11107,1864508,595.7,5.7,0.1%
|
||||
,"2023 ","2023","Male","M","1-4 years","1-4",2329,7594891,30.7,0.6,0.0%
|
||||
,"2023 ","2023","Male","M","5-14 years","5-14",3518,20972638,16.8,0.3,0.0%
|
||||
,"2023 ","2023","Male","M","15-24 years","15-24",24668,22423446,110.0,0.7,0.1%
|
||||
,"2023 ","2023","Male","M","25-34 years","25-34",47833,23059187,207.4,0.9,0.3%
|
||||
,"2023 ","2023","Male","M","35-44 years","35-44",69814,22362236,312.2,1.2,0.4%
|
||||
,"2023 ","2023","Male","M","45-54 years","45-54",104880,20187109,519.5,1.6,0.6%
|
||||
,"2023 ","2023","Male","M","55-64 years","55-64",229644,20503845,1120.0,2.3,1.2%
|
||||
,"2023 ","2023","Male","M","65-74 years","65-74",361317,16335080,2211.9,3.7,1.9%
|
||||
,"2023 ","2023","Male","M","75-84 years","75-84",411716,8162499,5044.0,7.9,2.2%
|
||||
,"2023 ","2023","Male","M","85+ years","85+",350204,2283961,15333.2,25.9,1.9%
|
||||
,"2023 ","2023","Male","M","Not Stated","NS",55,Not Applicable,Not Applicable,Not Applicable,0.0%
|
||||
"---"
|
||||
"Dataset: Underlying Cause of Death, 2018-2023, Single Race"
|
||||
"Query Parameters:"
|
||||
"Title: US_10_Year_Age_Groups_2018-2023.csv"
|
||||
"Group By: Year; Sex; Ten-Year Age Groups"
|
||||
"Show Totals: False"
|
||||
"Show Zero Values: True"
|
||||
"Show Suppressed: True"
|
||||
"Calculate Rates Per: 100,000"
|
||||
"Rate Options: Default intercensal populations for years 2001-2009 (except Infant Age Groups)"
|
||||
"---"
|
||||
"Help: See http://wonder.cdc.gov/wonder/help/ucd-expanded.html for more information."
|
||||
"---"
|
||||
"Query Date: Nov 21, 2025 9:19:00 PM"
|
||||
"---"
|
||||
"Suggested Citation: Centers for Disease Control and Prevention, National Center for Health Statistics. National Vital Statistics"
|
||||
"System, Mortality 2018-2023 on CDC WONDER Online Database, released in 2024. Data are from the Multiple Cause of Death Files,"
|
||||
"2018-2023, as compiled from data provided by the 57 vital statistics jurisdictions through the Vital Statistics Cooperative"
|
||||
"Program. Accessed at http://wonder.cdc.gov/ucd-icd10-expanded.html on Nov 21, 2025 9:19:00 PM"
|
||||
"---"
|
||||
Caveats:
|
||||
"1. Death rates are flagged as Unreliable when the rate is calculated with a numerator of 20 or less. More information:"
|
||||
"http://wonder.cdc.gov/wonder/help/ucd-expanded.html#Unreliable."
|
||||
"2. Deaths of persons with Age ""Not Stated"" are included in ""All"" counts and rates, but are not distributed among age groups,"
|
||||
"so are not included in age-specific counts, age-specific rates or in any age-adjusted rates. More information:"
|
||||
"http://wonder.cdc.gov/wonder/help/ucd-expanded.html#Not Stated."
|
||||
"3. The method used to calculate standard errors is documented here: More information:"
|
||||
"http://wonder.cdc.gov/wonder/help/ucd-expanded.html#Standard-Errors."
|
||||
"4. The population figures for years 2023 are single-race estimates of the July 1 resident population, from the Vintage 2023"
|
||||
"postcensal series released by the Census Bureau on June 27, 2024. The 2023 series is based on the Modified Blended Base produced"
|
||||
"by the US Census Bureau in lieu of the April 1, 2020 decennial population count. The Modified Blended Base consists of the blend"
|
||||
"of Vintage 2020 postcensal population estimates for April 1, 2020, 2020 Demographic Analysis Estimates, and 2020 Census data"
|
||||
"from the internal Census Edited File (CEF). The population figures for years 2022 are single-race estimates of the July 1"
|
||||
"resident population, from the Vintage 2022 postcensal series released by the Census Bureau on June 22, 2023. The 2022 series is"
|
||||
"based on the Modified Blended Base produced by the US Census Bureau in lieu of the April 1, 2020 decennial population count. The"
|
||||
"Modified Blended Base consists of the blend of Vintage 2020 postcensal population estimates for April 1, 2020, 2020 Demographic"
|
||||
"Analysis Estimates, and 2020 Census data from the internal Census Edited File (CEF). The population figures for years 2021 are"
|
||||
"single-race estimates of the July 1 resident population, based on the Blended Base produced by the US Census Bureau in lieu of"
|
||||
"the April 1, 2020 decennial population count, from the Vintage 2021 postcensal series released by the Census Bureau on June 30,"
|
||||
"2022. The population figures for year 2020 are single-race estimates of the July 1 resident population, from the Vintage 2020"
|
||||
"postcensal series based on April 2010 Census, released by the Census Bureau on July 27, 2021. The population figures for year"
|
||||
"2019 are single-race estimates of the July 1 resident population, from the Vintage 2019 postcensal series based on April 2010"
|
||||
"Census, released by the Census Bureau on June 25, 2020. The population figures for year 2018 are single-race estimates of the"
|
||||
"July 1 resident population, from the Vintage 2018 postcensal series based on April 2010 Census, released by the Census Bureau on"
|
||||
"June 20, 2019. More information: http://wonder.cdc.gov/wonder/help/ucd-expanded.html#Population Data."
|
||||
"5. The population figures used in the calculation of death rates for the age group 'under 1 year' are the estimates of the"
|
||||
"resident population that is under one year of age. More information: http://wonder.cdc.gov/wonder/help/ucd-expanded.html#Age"
|
||||
"Group."
|
||||
"6. Connecticut population estimates for 2022 and later years are reported for 9 planning regions as county equivalent areas,"
|
||||
"instead of the former 8 legacy counties in the Vintage 2022 postcensal series released by the Census Bureau on June 22, 2023,"
|
||||
"and in the Vintage 2023 postcensal series released by the Census Bureau on June 27, 2024. Populations estimates for the former"
|
||||
"counties are not available for 2022 and later years. More information:"
|
||||
"http://wonder.cdc.gov/wonder/help/ucd-expanded.html#Connecticut-2022."
|
||||
"7. After the creation of the final 2023 dataset, North Carolina updated the cause of death information for over 900 death"
|
||||
"certificates to include a cause of death code indicating drug overdose (ICD-10 underlying cause-of-death codes: X40-X44,"
|
||||
"X60-X64, X85, and Y10-Y14). Jurisdictions can continue to update death certificates after the closing of the mortality file. As"
|
||||
"a result, users should consider that the actual death count for drug overdose deaths for North Carolina in 2023 is over 4,400"
|
||||
"deaths, with a crude rate of approximately 41.0 per 100,000 population, and an age-adjusted rate of approximately 42.1 per"
|
||||
"100,000 population. These deaths will not be updated on the final mortality datasets."
|
||||
|
Can't render this file because it has a wrong number of fields in line 146.
|
30
START_HERE_Causes.r
Normal file
30
START_HERE_Causes.r
Normal file
@ -0,0 +1,30 @@
|
||||
library(tidyverse)
|
||||
library(fixest)
|
||||
####SPLIT OUT THE DATA MANAGEMENT PULL IN ARIMA
|
||||
################################Create the data need to model the age-sex specific death rates
|
||||
DF1999 <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_Single_Age_1999-2020.csv") %>% select(Year,Sex,Age=`Single-Year Ages Code`,Mortality_Rate=`Crude Rate`) %>% mutate(Mortality_Rate=parse_number(Mortality_Rate)) %>% filter(!is.na(Mortality_Rate)) %>% mutate(Mortality_Rate=as.numeric(Mortality_Rate))
|
||||
DF2018 <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_Single_Age_2018-2023.csv") %>% select(Year,Sex,Age=`Single-Year Ages Code`,Mortality_Rate=`Crude Rate`) %>% filter(!is.na(Mortality_Rate))%>% mutate(Mortality_Rate=parse_number(Mortality_Rate)) %>% filter(!is.na(Mortality_Rate)) %>% mutate(Mortality_Rate=as.numeric(Mortality_Rate))
|
||||
|
||||
OLDER1 <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_10_Year_Age_Groups_1999-2020.csv")%>% rename(Age=`Ten-Year Age Groups Code`,Mortality_Rate=`Crude Rate`) %>% filter(Age=='85+')%>% mutate(Age=85,Year=as.numeric(Year),Mortality_Rate=parse_number(Mortality_Rate)) %>% select(Year,Sex,Age,Mortality_Rate) %>% mutate(Mortality_Rate=as.numeric(Mortality_Rate),Age=as.numeric(Age))
|
||||
OLDER2 <- read_csv("Data/Raw_Data/Mortality_Rates_New/US_10_Year_Age_Groups_2018-2023.csv")%>% rename(Age=`Ten-Year Age Groups Code`,Mortality_Rate=`Crude Rate`) %>% filter(Age=='85+')%>% mutate(Age=85,Year=as.numeric(Year),Mortality_Rate=parse_number(Mortality_Rate)) %>% select(Year,Sex,Age,Mortality_Rate)%>% mutate(Mortality_Rate=as.numeric(Mortality_Rate),Age=as.numeric(Age))
|
||||
DF <- rbind(DF1999,DF2018,OLDER1,OLDER2) %>% unique %>% group_by(Year,Sex,Age) %>% arrange(Year,Sex,Age) %>% mutate(Age=as.numeric(Age)) %>% ungroup
|
||||
#hist(US_CAUSES$Death_Rate,breaks=150)
|
||||
#Overall US death rates
|
||||
US_AGE_ADJ <- rbind(read_csv("Data/Raw_Data/Mortality_Rates_New/US_Age_Adjusted_1979-1998.csv") %>% select(Year,Sex,US_Adj_Death_Rate=`Crude Rate`),read_csv("Data/Raw_Data/Mortality_Rates_New/US_Age_Adjusted_1999-2020.csv") %>% select(Year,Sex,US_Adj_Death_Rate=`Crude Rate`),read_csv("Data/Raw_Data/Mortality_Rates_New/US_Age_Adjusted_2018-2023.csv") %>% select(Year,Sex,US_Adj_Death_Rate=`Crude Rate`)) %>% unique
|
||||
REG_DATA <- DF %>% left_join(US_AGE_ADJ) %>% pivot_wider(values_from=Mortality_Rate,names_from=Age,names_prefix="Age_")
|
||||
#####################Model all ages and sex
|
||||
MOD <- feols(Age_.[0:85]~US_Adj_Death_Rate+Sex*Year,REG_DATA)
|
||||
|
||||
###Simulate each age-sex death rate over time with the models
|
||||
#########When project far into the future some death rate values become negative. Make bounds to limit the forecast to a reasonable range. In this case I select half of the historic minimum, or double the historic maximum as upper an lower bounds in the study period.
|
||||
BOUNDS <- DF %>% group_by(Age) %>% summarize(MAX_RATE=2*max(Mortality_Rate),MIN_RATE=min(Mortality_Rate)/2)
|
||||
MAX_BOUND <- BOUNDS %>% pull(MAX_RATE)
|
||||
MIN_BOUND <- BOUNDS %>% pull(MIN_RATE)
|
||||
#Create a proxy data set to simulate with
|
||||
C_VAL <- REG_DATA %>% mutate(Year=Year+(2025-1999)) %>% select(Year,Sex,US_Adj_Death_Rate)
|
||||
###Mostly Working: Pass in a data frame, with year, sex, and US age adjusted mortality rate. The years should go from the simulation start 2025, to the end roughly 2045. WHAT IS MISSING is to pass the arima results of the US age adjusted mortality rates as applied in Lincoln to replace the age adjusted mortality term. Once that is done, a new simulation will give the age specific mortality rates based on the forecasted Lincoln average rates.
|
||||
RES <- do.call(rbind,lapply(1:86,function(x){return(predict(MOD[[x]],C_VAL))}))#For each data frame containing each year and sex combination of the forecast, predict the data for each age 0-85. Bind these by row to create a result with ages by row, and year by column
|
||||
RES <- ifelse(TEMP<MIN_BOUND,MIN_BOUND,TEMP) #Make sure the values are not too low to be reasonable estimates
|
||||
RES <- ifelse(TEMP>MAX_BOUND,MAX_BOUND,TEMP)#Make sure the values are not too high to be reasonable estimates
|
||||
RES <- RES/10^5 #Chance of death per person
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user