par(mfrow=c(2,1)) plot(mk.maturity, mk.zero2[54,],xlab="Maturity",ylab="Rate") title(paste("Yield Curve:",positions(mk.zero2[54,]))) plot(mk.maturity, mk.fwd2[54,],xlab="Maturity",ylab="Rate") title(paste("Forward Rate Curve:",positions(mk.fwd2[54,]))) par(mfrow=c(1,1)) disc.rate=bond.discount(mk.zero2[54,1:48],mk.maturity[1:48],input="spot", compounding=2) spot.rate=bond.spot(disc.rate, mk.maturity[1:48], input="discount",compounding=2) args(term.struct) disc.rate=term.struct(mk.zero2[54,],mk.maturity,method="quadratic", input="spot",na.rm="T") class(disc.rate) disc.rate names(disc.rate) spot.rate=bond.spot(disc.rate$fitted, disc.rate$maturity, input="discount", compounding=0) plot(mk.maturity[1:48], mk.zero2[54,1:48], xlab="Maturity", ylab="Rate", main="Yield Curve") lines(disc.rate$maturity, spot.rate) fwd.rate=bond.forward(disc.rate$fitted,disc.rate$maturity, input="discount", compounding=0) plot(disc.rate$maturity, fwd.rate, type="l", xlab="Maturity", ylab="Rate", main="Forward Rate") points(mk.maturity[1:48], mk.fwd2[54,1:48]) fnz.fit=term.struct(mk.zero2[54,], mk.maturity, method="smooth", input="spot", na.rm=T) class(fnz.fit) names(fnz.fit) fnz.spot=predict(fnz.fit, fnz.fit$maturity) fnz.forward=bond.forward(fnz.spot, fnz.fit$maturity, input="spot", compounding=0) plot(mk.maturity[1:48], mk.fwd2[54,1:48], xlab="Maturity", ylab="Rate", main="Forward Rate") lines(fnz.fit$maturity, fnz.forward) ns.maturity=seq(1/12, 10, length=50) ns05= term.struct.nsx(ns.maturity, 0.5) ns15= term.struct.nsx(ns.maturity, 1.5) par(mfrow=c(2,1)) tsplot(ns05[,2:3], main="tau=0.5") tsplot(ns15[,2:3], main="tau=1.5") par(mfrow=c(1,1)) ns.fit= term.struct(mk.zero2[54,], mk.maturity, method="ns", input="spot", na.rm=T) ns.fit nss.fit= term.struct(mk.zero2[54,], mk.maturity, method="nss", input="spot", na.rm=T) nss.fit