'get the data import .\Yield_2022.xlsx range="FRED Graph" colhead=1 na="#N/A" @freq M @id @date(date) @smpl @all 'create a group object that includes all the variables of interest group zgr.add gs3m gs6m gs1 gs2 gs5 gs10 'store the maturities in months svector matsvec = @wsplit("3 6 12 24 60 120") 'plot all series freeze(mode=overwrite,chart_yields) zgr.line chart_yields.axis dual 'run the add-in zgr.hxprincomp(apply=2,type=3,pval=12,hval=24,nfactors=4,cycles,loadings) 'normalize the signs colplace(loadmat,-@columnextract(loadmat,3),3) grfactors(3) = -grfactors(3) 'interpolate the loadings for missing maturities (R connection is required) xopen(r) xon x <- c(3, 6, 12, 24, 60, 120) maturity <- seq(3,120,length.out=150) xoff xget(type=series,name=maturity) maturity group grloadings.add maturity for !i=1 to 3 series loading_!i vector yvec = @columnextract(loadmat,!i) 'natural cubic spline is not appropriate for irregulary spaced data xon xput yvec y_r <- spline(x,yvec,n=150,xmin=3,xmax=120,method=c("fmm")) xget(type=series,name=loading) y_r$y xoff loading_!i = loading grloadings.add loading_!i next xclose 'produce figure 4 in the paper stom(grloadings,grloadmat) freeze(mode=overwrite,chart_loadings) grloadmat.xyline chart_loadings.axis(b) range(minmax) chart_loadings.legend position(BOTCENTER) chart_loadings.legend columns(3) chart_loadings.setelem(2) legend(Level (factor 1)) chart_loadings.setelem(3) legend(Slope (factor 2)) chart_loadings.setelem(4) legend(Curvature (factor 3)) chart_loadings.options linepat smpl @all