简体   繁体   中英

What is the reason of error using ycinterextra R package?

I am trying to interpolate yield curve using ycinterextra R package.

a <- c(1,3,5)
b <- c(1,2,3,4,5)
c <- c(0.05, 0.06, 0.07)
yc <- ycinter(yM = c, matsin = a, matsout = b, method = "HCSPL", typeres = 
"rates")

Running function ycinter returns:

Error in if (Sw_down != Sw_up) { : missing value where TRUE/FALSE needed

How to solve this problem?

The algorithm for this function assumes that matsin vector is a range of integer values. So you need to change your matsin and matsout vectors in the following way:

library(ycinterextra)

a <- 1:3
b <- seq(1,3,by=0.5)
c <- c(0.05, 0.06, 0.07)
yc <- ycinter(yM = c, matsin = a, matsout = b, method = "HCSPL", typeres =  "rates")

ycsummary(yc)
# Residuals: 
#   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
# 0       0       0       0       0       0 
# 
# Coefficients: 
#   NA 
# 
# Total sum of squares: 
#   2e-04 
# with 2 degrees of freedom 
# 
# Explained sum of squares: 
#   2e-04 
# with 0 degrees of freedom 
# 
# Residual sum of squares: 
#   0 
# with 2 degrees of freedom 
# 
# Multiple R-squared  * Adjusted R-squared 
# 1 * 1 
# 
# F-statistic: Inf on 2 and 0 degrees of freedom, p-value: NaN 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM