# Reading the data via internet.
sk <- read.delim("http://minato.sip21c.org/demography-special/deaths.txt")
# Comparing CDRs between Sweden and Kazakhstan
# Sweden's CDR
sum(sk$DSW)/sum(sk$NSW)
# Kazakhstan's CDR
sum(sk$DK)/sum(sk$NK)
# You can see CDR in Sweden is higher than CDR in Kazakhstan
#
# Comparing Age-Specific Death Rates (ASDR)
ASDRSW <- sk$DSW/sk$NSW
ASDRK <- sk$DK/sk$NK
print(cbind(ASDRSW, ASDRK)) # print the all ASDRs in two countries
library(pyramid)
pyramid(data.frame(ASDRSW, ASDRK, sk$AG), Laxis=0:4/20, Cadj=0,
Llab="ASDR in Sweden", Rlab="ASDR in Kazakhstan")
#
# Standardization
# Using the age structure of standard population as weight,
# the weighed average of ASDR gives Age-standardized mortality rate (direct method)
# Let the mean of two groups standard population for each age group
STP <- (sk$NSW+sk$NK)/2 # Standard population
sum(ASDRSW*STP)/sum(STP) # Directly age-standardized mortality rate for Sweden
sum(ASDRK*STP)/sum(STP) # Directly age-standardized mortality rate for Kazakhstan
# You can see the former is much lower than the latter.
#
# Indirect adjustment method, using SMR (Standardized Mortality Ratio)
# It requires age-specific death rate in standard population, but the data
# needed for the target population is total number of death and age-specific population.
STD <- (sk$DSW+sk$DK)/2
ASDRST <- STD/STP # Age-Specific Death Rate in Standard population
SMRSW <- sum(sk$DSW)/sum(sk$NSW*ASDRST) # SMR for Sweden
SMRSW*sum(STD)/sum(STP) # SMR x (CDR in standard population) gives indirect ASDR
SMRK <- sum(sk$DK)/sum(sk$NK*ASDRST) # SMR for Kazakhstan
SMRK*sum(STD)/sum(STP) # Indirect ASDR in Kazakhstan
# Table 6.1 is not necessary to enter.