# load data set
data(eurobonds)
# define countries, for which the estimation
# of the zero-coupon yield curves will be carried out
group <- c("GERMANY", "AUSTRIA", "ITALY")
# define data set
bonddata <- eurobonds
# set maturity range
matrange <- c(2,12)
# define the used method
method <- "Nelson/Siegel"
# the weighted squared price errors will be minimized
fit <- "prices"
weights <- "duration"
# naive start parameters
b <- matrix(rep(c(0,0,0, 1),3),nrow=3,byrow=TRUE)
rownames(b) <- group
colnames(b) <- c("beta0","beta1","beta2","tau1")
# perform estimation
x <- nelson_estim(group, bonddata, matrange,
method, fit, weights, startparam=b)
# prints the obtained parameters of the estimation
print(x)
# goodness of fit measures
summary(x)
# plots the zero-coupon yield curves for each country
plot(x,errors="none")
# plots all zero-coupon yield curves togther
plot(x,multiple=TRUE, errors="none")
# spread curve splot
plot(x,ctype="spread",errors="none")
# price error plot for all countries
plot(x,ctype="none")
Run the code above in your browser using DataLab