使用ycinterextra R包出错的原因是什么?

时间:2018-05-22 16:28:10

标签: r

我试图使用ycinterextra R包插入收益率曲线。

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")

运行函数ycinter返回:

  

if(Sw_down!= Sw_up){:缺失值为TRUE / FALSE时出错   需要

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

此函数的算法假定matsin向量是整数值的范围。因此,您需要以下列方式更改matsin和matsout向量:

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