1

I plot data in a 3D form using wireframe from the lattice package to show the volatility term structure. Here is the data:

library(lattice) 

con <- textConnection ("  X1M    X2M    X3M    X6M    X9M   X12M   X18M   X24M VSTOXX Euro.Stoxx.50
2006-04-14 14.850 15.076 15.462 15.950 16.396 16.700 17.146 17.968 15.068      3793.830
2006-04-21 16.468 15.028 15.476 15.900 16.342 16.858 17.402 18.030 14.930      3824.030
2006-04-28 14.576 15.070 14.560 15.552 15.996 16.262 16.850 17.630 14.810      3865.136
2006-05-05 14.806 14.990 14.770 15.584 16.132 16.378 16.868 17.668 14.906      3848.302
2006-05-12 15.944 14.968 14.734 15.260 15.840 15.582 16.496 17.338 15.028      3844.066
2006-05-19 27.708 18.316 17.466 17.250 17.412 17.478 17.796 17.646 19.204      3655.658
2006-05-26 23.756 20.862 19.650 19.922 19.348 19.256 19.362 19.330 22.732      3613.942
2006-06-02 23.172 21.504 20.720 21.046 20.332 20.188 20.054 20.404 22.078      3638.574
2006-06-09 24.972 22.898 22.366 22.416 21.448 21.204 20.788 21.146 23.168      3535.830
2006-06-16 28.138 24.660 23.888 23.330 22.604 22.010 21.850 22.248 25.150      3451.960
2006-06-23 21.114 20.606 20.256 19.898 19.820 19.954 20.350 21.168 21.194      3525.386
2006-06-30 20.722 20.188 19.884 19.566 19.360 19.438 19.808 20.088 20.508      3555.864
2006-07-07 18.348 18.380 18.574 18.702 18.552 19.038 19.374 19.806 18.370      3653.206
2006-07-14 21.944 19.834 19.922 19.660 19.606 19.740 20.096 20.332 19.960      3597.120
2006-07-21 24.876 21.276 21.160 20.654 20.536 20.746 21.008 21.330 21.224      3544.618
2006-07-28 18.506 18.696 18.642 19.106 19.332 19.806 20.248 20.644 18.606      3659.466
2006-08-04 18.718 18.934 18.914 19.282 19.292 19.714 20.080 20.470 18.878      3682.964
2006-08-11 20.586 19.798 19.534 19.666 19.504 19.736 20.154 20.570 19.878      3676.808
2006-08-18 19.258 17.696 18.112 18.452 18.628 19.080 19.698 20.068 17.566      3773.618
")
Dat<- read.table(con, header = TRUE)

I would like to show two following things in a 3D plot (separately) :

1.) I can simply control levels for which I have different colours by

data2<-Dat[,c(8,7,6,5,4,3,2,1)]

wireframe(as.matrix(data2),
          aspect = c(61/87, 0.4), drape = TRUE,
          scales = list(arrows = F, cex= 0.5, font = 1),
          xlab='Date', ylab='Maturity', zlab='Value',
col.regions=c("#FF3030","#551A8B","#43CD80"),
         at=c(0,18,25,30))

but how can I have different colours for the periods whith flat/steep/inverse term structure ?

2.) The data set actually represents 9 weeks before and after the 2006-06-16 (or any other date,not necessarilly 9 weeks time span ) and I would like to highlight this specific date either by different colour in a 3D plot or some arrow / text/...

Thanks,

Alexander

Alexander
  • 41
  • 1
  • Can you explain what "flat... term structure" means? Something about the local gradient, perhaps? (BTW, you can write `Dat[,8:1]` . No need to write out the collection of indices) – Carl Witthoft Mar 23 '12 at 11:36
  • @Carl Witthoft Discussion about the slope of the Implied Volatility (IV) Term Structure (TS) can get very complicated, but in this case I wouldnt go too far as the graph should provide a rough idea about the TS. It would be sufficient to say that IV has a steep TS if X1M > X9M > X24M; inverse if X24M < X9M < X1M, flat if X1M/X9M resp. X1M/X24M dont differ by more than 10% and the rest is a volatility skew. Once I see how can I imply these conditions onto a graph it would be easy to change these conditions. – Alexander Mar 23 '12 at 15:59
  • Well, it's not too hard to select subsets of your data along with their indices with something like `intersect(which(X1M>X9M,arr.ind=TRUE),which(X1M> X24M,arr.ind=TRUE))` (the actual code would have to access the indices subset of the returned array) .Then perhaps you can overplot with that subset? – Carl Witthoft Mar 23 '12 at 16:35
  • @Carl Witthoft Subsetting is not a problem, however overplotting is :-) – Alexander Mar 23 '12 at 18:31

0 Answers0