简体   繁体   中英

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. 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. for example if I am interested in 4-year yield or 1.5-year yield? What I need is just one value that correspond to specific t (any).

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.

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

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