as.Date("2028-08-10")-as.Date("2023-10-10")
## Time difference of 1766 days
D = 0.125
I_t0 = 364.5
I_t1 = 374.2
j = 0.127/100
n = 1766 %/% 365 * 2
P = 98.45
inflation = function(I_t1, I_t0, P, D, j, n){
index = (I_t1/I_t0)/P
coupon = (D/2) * ((1 - (1 + j/2)^(-n))/(j/2))
redemption = 100 * (1 + (j/2))^(-n)
payment = coupon + redemption
issue = index * payment
inflation = sqrt(issue) - 1
return(inflation)
}
inflation(I_t1, I_t0, P, D, j, n)
## [1] 0.02112273
index = (I_t1 / I_t0)/P coupon = (D/2)(1 - (1 + j/2)^(-n))/(j/2) redemption = 100 (1 + j/2)^(-n) payment = coupon + redemption issue = index * payment infl = sqrt(issue) - 1 return(coupon)
library(readxl)
IHK_DATA <- read_excel("IHK.xlsx")
head(IHK_DATA)
## # A tibble: 6 × 2
## TIME IHK
## <dttm> <dbl>
## 1 2022-07-01 00:00:00 112.
## 2 2022-08-01 00:00:00 112.
## 3 2022-09-01 00:00:00 113.
## 4 2022-10-01 00:00:00 113.
## 5 2022-11-01 00:00:00 113.
## 6 2022-12-01 00:00:00 114.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
data_ihk <- IHK_DATA %>%
mutate(Tingkat_Inflasi = ((IHK_DATA$IHK - lag(IHK_DATA$IHK))/lag(IHK_DATA$IHK)))
data_ihk
## # A tibble: 14 × 3
## TIME IHK Tingkat_Inflasi
## <dttm> <dbl> <dbl>
## 1 2022-07-01 00:00:00 112. NA
## 2 2022-08-01 00:00:00 112. -0.00206
## 3 2022-09-01 00:00:00 113. 0.0117
## 4 2022-10-01 00:00:00 113. -0.00106
## 5 2022-11-01 00:00:00 113. 0.000887
## 6 2022-12-01 00:00:00 114. 0.00656
## 7 2023-01-01 00:00:00 114. 0.00343
## 8 2023-02-01 00:00:00 114. 0.00158
## 9 2023-03-01 00:00:00 114. 0.00175
## 10 2023-04-01 00:00:00 115. 0.00332
## 11 2023-05-01 00:00:00 115. 0.000872
## 12 2023-06-01 00:00:00 115 0.00139
## 13 2023-07-01 00:00:00 115. 0.00209
## 14 2023-08-01 00:00:00 115. -0.000174
f.12 = mean(data_ihk$Tingkat_Inflasi[2:nrow(data_ihk)])
f.12
## [1] 0.002326256
inf = (1 + f.12)^(12) - 1
inf
## [1] 0.02827502
i.2 = 0.063831
effective=function(nominal,convertible){
effective=(1+(nominal/convertible))^(convertible)-1
return(effective)
}
effective(i.2, 2)
## [1] 0.0648496
real = function(f, i){
real = (1 + i)/(1 + f) - 1
return(real)
}
r.return = real(inf, effective(0.063831,2))
r.return
## [1] 0.03556887
real.r = function(r, convert){
real.r = ((1+r)^(1/convert)-1)*convert
return(real.r)
}
r.return2 = real.r(r.return, 2)
r.return2
## [1] 0.03525809
d = 0.063750
n = 4.90*2
Issue=function(I_t1,I_t0,f,D,i2,n){
index=(I_t1/I_t0)/((1+f)^0.5)
coupon=((D*100)/2)*(1-(1+i2/2)^(-n))/(i2/2)
redemption=100*(1+i2/2)^(-n)
payment=coupon+redemption
Issue=index*payment
return(Issue)
}
Issue(IHK_DATA$IHK[9], IHK_DATA$IHK[3], inf, d, r.return2, n)
## [1] 112.626