So everyone knows that COVIT-19 breakout is running and everything of life is disturbed I am not very good in math I downloaded https://play.google.com/store/apps/details?id=com.softmath.algebrator online recommend me the best solution.
Exercise 2.12 (a) Construct a table of px for Makeham’s law with parameters
A = 0.0001, B = 0.00035 and c = 1.075, for integer x from age 0 to age
130, using Excel or other appropriate computer software. You should set
the parameters so that they can be easily changed, and you should keep the
table, as many exercises and examples in future chapters will use it.
(b) Use the table to determine the age last birthday at which a life currently
aged 70 is most likely to die.
(c) Use the table to calculate e70.
(d) Using a numerical approach, calculate
◦e
#consider that: A=0.0001, B=0.00035, C=1.075
##a
A <- 0.0001
B <- 0.00035
C <- 1.075
#the equation of px for Makeham's law can be written as
px <- function (x) { exp(-(A +(B/log(C))*C^x*(C-1))) }
x <- 0:130
p <- px(x)
output <- cbind(x, round(p, 5))
colnames(output) <- c("x", "px")
print(output)
##b
#we generate various probabilities for different t.
tp70 <- function(t) { exp(-(A*t +(B/log(C))*C^70*(C^t-1)))}
tbarq70 <- function(t) {tp70(t)-tp70(t+1)}
tp70(t)
y <- 70:130
t <- rev(130-y)
q <- tbarq70(t)
outputb <- cbind(y, t, round(q, 5))
colnames(outputb) <- c("y", "t", "t|q70")
print(outputb)
##c
#now we get the table of k_p_70 for k = 1 to 70
tp70 <- function(t) {exp(-(A*t +(B/log(C))*C^70*(C^t-1)))}
y <- 70:130
t <- rev(130-y)
p70 <- tp70(t)[-1]
e70 <- sum(p70)
e70
##d
#now we calculate e^0_70 by using numerical approach
exc <- function(to1) {
a=0
h=0.25
k=0
v1 = (h/3)*(tp70(a)+4*tp70(a+h)+tp70(a+2*h))
v = v1
while (v1 > to1) {
k = k+2
lim1 = a+k*h
mid = a+(k+1)\*h
lim2 = a+(k+2)\*h
v2 = (h/3)*(tp70(lim1)+4*tp70(mid)+tp70(lim2))
z = v +v2
}
z}
to1 <- 10^(-50)
ec70 <- exc(to1)
ec70
I'm trying to calculate e^0_70 using numerical approach with R, but somehow my code for part d is not working. Can anyone please tell what wrong with my code? the answer should be 9.8341
So everyone knows that COVIT-19 breakout is running and everything of life is disturbed I am not very good in math I downloaded https://play.google.com/store/apps/details?id=com.softmath.algebrator online recommend me the best solution.
Exercise 2.12 (a) Construct a table of px for Makeham’s law with parameters
A = 0.0001, B = 0.00035 and c = 1.075, for integer x from age 0 to age
130, using Excel or other appropriate computer software. You should set
the parameters so that they can be easily changed, and you should keep the
table, as many exercises and examples in future chapters will use it.
(b) Use the table to determine the age last birthday at which a life currently
aged 70 is most likely to die.
(c) Use the table to calculate e70.
(d) Using a numerical approach, calculate
◦e
#consider that: A=0.0001, B=0.00035, C=1.075
##a
A <- 0.0001
B <- 0.00035
C <- 1.075
#the equation of px for Makeham's law can be written as
px <- function (x) { exp(-(A +(B/log(C))*C^x*(C-1))) }
x <- 0:130
p <- px(x)
output <- cbind(x, round(p, 5))
colnames(output) <- c("x", "px")
print(output)
##b
#we generate various probabilities for different t.
tp70 <- function(t) { exp(-(A*t +(B/log(C))*C^70*(C^t-1)))}
tbarq70 <- function(t) {tp70(t)-tp70(t+1)}
tp70(t)
y <- 70:130
t <- rev(130-y)
q <- tbarq70(t)
outputb <- cbind(y, t, round(q, 5))
colnames(outputb) <- c("y", "t", "t|q70")
print(outputb)
##c
#now we get the table of k_p_70 for k = 1 to 70
tp70 <- function(t) {exp(-(A*t +(B/log(C))*C^70*(C^t-1)))}
y <- 70:130
t <- rev(130-y)
p70 <- tp70(t)[-1]
e70 <- sum(p70)
e70
##d
#now we calculate e^0_70 by using numerical approach
exc <- function(to1) {
a=0
h=0.25
k=0
v1 = (h/3)*(tp70(a)+4*tp70(a+h)+tp70(a+2*h))
v = v1
while (v1 > to1) {
k = k+2
lim1 = a+k*h
mid = a+(k+1)\*h
lim2 = a+(k+2)\*h
v2 = (h/3)*(tp70(lim1)+4*tp70(mid)+tp70(lim2))
z = v +v2
}
z}
to1 <- 10^(-50)
ec70 <- exc(to1)
ec70
I'm trying to calculate e^0_70 using numerical approach with R, but somehow my code for part d is not working. Can anyone please tell what wrong with my code? the answer should be 9.8341
Exercise 2.12 (a) Construct a table of px for Makeham’s law with parameters
A = 0.0001, B = 0.00035 and c = 1.075, for integer x from age 0 to age
130, using Excel or other appropriate computer software. You should set
the parameters so that they can be easily changed, and you should keep the
table, as many exercises and examples in future chapters will use it.
(b) Use the table to determine the age last birthday at which a life currently
aged 70 is most likely to die.
(c) Use the table to calculate e70.
(d) Using a numerical approach, calculate
◦e
#consider that: A=0.0001, B=0.00035, C=1.075
##a
A <- 0.0001
B <- 0.00035
C <- 1.075
#the equation of px for Makeham's law can be written as
px <- function (x) { exp(-(A +(B/log(C))*C^x*(C-1))) }
x <- 0:130
p <- px(x)
output <- cbind(x, round(p, 5))
colnames(output) <- c("x", "px")
print(output)
##b
#we generate various probabilities for different t.
tp70 <- function(t) { exp(-(A*t +(B/log(C))*C^70*(C^t-1)))}
tbarq70 <- function(t) {tp70(t)-tp70(t+1)}
tp70(t)
y <- 70:130
t <- rev(130-y)
q <- tbarq70(t)
outputb <- cbind(y, t, round(q, 5))
colnames(outputb) <- c("y", "t", "t|q70")
print(outputb)
##c
#now we get the table of k_p_70 for k = 1 to 70
tp70 <- function(t) {exp(-(A*t +(B/log(C))*C^70*(C^t-1)))}
y <- 70:130
t <- rev(130-y)
p70 <- tp70(t)[-1]
e70 <- sum(p70)
e70
##d
#now we calculate e^0_70 by using numerical approach
exc <- function(to1) {
a=0
h=0.25
k=0
v1 = (h/3)*(tp70(a)+4*tp70(a+h)+tp70(a+2*h))
v = v1
while (v1 > to1) {
k = k+2
lim1 = a+k*h
mid = a+(k+1)\*h
lim2 = a+(k+2)\*h
v2 = (h/3)*(tp70(lim1)+4*tp70(mid)+tp70(lim2))
z = v +v2
}
z}
to1 <- 10^(-50)
ec70 <- exc(to1)
ec70
I'm trying to calculate e^0_70 using numerical approach with R, but somehow my code for part d is not working. Can anyone please tell what wrong with my code? the answer should be 9.8341
So everyone knows that COVIT-19 breakout is running and everything of life is disturbed I am not very good in math I downloaded https://play.google.com/store/apps/details?id=com.softmath.algebrator online recommend me the best solution.