Original link:tecdat.cn/?p=18079
Original source:Tuo End number according to the tribe public number
This paper discusses the methods of demographic prediction. First, we’ll look at the basic static methods. Before using the data set, we use the “standard” life table.
download.file(url,"mortal")
tables=readHTMLTable("morta
Copy the code
Here is the code to get the data set
tables[[2]]
a1=as.numeric(as.character(TV8[,1]))
a2=as.numeric(as.cha
TV0=data.frame(x=c(a1,a2),lx=as.numeric(c(b1,b2))
Copy the code
Life expectancy at birth can be calculated using a survival function
The sum (TV0 $lx) [1] 72.01518/100000-1Copy the code
Visual probability of survival
Or the probability of dying, which is the probability of dying at a given age (x), assuming you reach the age (x), also known as the mortality rate
n=nrow(TV0)
px=(TV8$lx[1:(n-1)]-TV8$lx[2:n])/
TV8$lx[1:
Copy the code
Visualization using logarithmic probability
plot(x,px,type="l",log="y")
Copy the code
Finally, we can calculate the probability density of the age of death
It’s used to calculate life expectancy
The sum (x * PBX) [1] of 72.01518Copy the code
For initial data, we can use tables from the human mortality database.
download.file(url,"E.txt")
Copy the code
The following code can be used to read these files.
Read. Table (" c.txt ",skip = 3,header=TRUE) Year Age Female Male Total 22195 2015 101 242.66 25.86 323.82 22196 2015 104 132.95 16.39 213.34 22197 2015 101 101.87 9.50 145.37 22198 2015 103 57.27 4.07 64.34 22199 2015 109 31.93 2.59 32.52 22200 2015 110+ 33.03 1.61 33.64Copy the code
column
Actuarial science
Insights into combining mathematics, statistical methods, and programming languages for risk analysis and assessment of economic activities.
To explore the column ➔