简体   繁体   English

如何在R的ycinterextra包中获取对应x的特定拟合值

[英]How to get specific fitted value of corresponding x in ycinterextra package in R

I am new to R so please keep that in mind :) I am currently using package 'ycinterextra' and interpolating yield curve with several methods. 我是R的新手,所以请记住:)我目前正在使用包ycinterextra,并使用几种方法对收益率曲线进行插值。 For example, 例如,

maturity<- c(1,2,5,10)
yield<- c(0.39,0.61,1.66,2.58)
t<-seq(from=min(maturity), to=max(maturity), by=0.01) 
yc <- ycinter(yM = yield, matsin = maturity, matsout = t, method="SW",typeres="rates")
fitted(yc)

I know how to get fitted(yc), but I don't know how to get one value for specific maturity. 我知道如何拟合(yc),但是我不知道如何针对特定的成熟度获得一个值。 for example if I am interested in 4-year yield or 1.5-year yield? 例如,如果我对4年期或1.5年期利率感兴趣? What I need is just one value that correspond to specific t (any). 我需要的只是一个与特定t(任意)相对应的值。

Thansk in advance! 提前谢谢!

Not sure if I understood correctly and very old question, but here is what I think you should do. 不知道我是否理解正确并且是一个非常老的问题,但这是我认为您应该做的。 Simply match your value from t and find it from fitted values. 只需从t匹配您的值并从拟合值中找到它。

as.numeric(fitted(yc))[match(4.5,t)]
[1] 1.460163

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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