[tech-spec] VIX script again, a bit less bare-bones

  • From: Steve Wisdom <swisdom@xxxxxxxxx>
  • To: tech-spec@xxxxxxxxxxxxx
  • Date: Tue, 26 Oct 2004 17:12:13 -0400

--
info<- function(M) {str(M); rbind(head(M),tail(M))} 
VIX <-  read.table('http://dailyspeculations.com/VIX.txt')
VIXE<-  VIX[!VIX$Year%%4,] 
info(VIX); info(VIXE)
round(matrix(with(VIX ,by(Chg,Month,mean))),2) #All years
round(matrix(with(VIXE,by(Chg,Month,mean))),2) #Election only
R.version.string

> VIX <-  read.table('http://dailyspeculations.com/VIX.txt')
> VIXE<-  VIX[!VIX$Year%%4,] 
> info(VIX); info(VIXE)
`data.frame':   176 obs. of  4 variables:
 $ Year : int  1990 1990 1990 1990 1990 1990 1990 1990 1990 1990 ...
 $ Month: int  2 3 4 5 6 7 8 9 10 11 ...
 $ VIX  : num  22.0 19.7 19.5 17.4 15.5 ...
 $ Chg  : num  -3.37 -2.26 -0.21 -2.15 -1.87 5.61 8.79 -0.79 0.93 -7.88 ...
          Year Month   VIX   Chg
2/28/1990 1990     2 21.99 -3.37
3/30/1990 1990     3 19.73 -2.26
4/30/1990 1990     4 19.52 -0.21
5/31/1990 1990     5 17.37 -2.15
6/29/1990 1990     6 15.50 -1.87
7/31/1990 1990     7 21.11  5.61
4/30/2004 2004     4 17.19  0.45
5/31/2004 2004     5 15.50 -1.69
6/30/2004 2004     6 14.34 -1.16
7/30/2004 2004     7 15.32  0.98
8/31/2004 2004     8 15.29 -0.03
9/30/2004 2004     9 13.34 -1.95
`data.frame':   45 obs. of  4 variables:
 $ Year : int  1992 1992 1992 1992 1992 1992 1992 1992 1992 1992 ...
 $ Month: int  1 2 3 4 5 6 7 8 9 10 ...
 $ VIX  : num  17.4 16.7 16.2 15.5 13.9 ...
 $ Chg  : num  -1.91 -0.72 -0.5 -0.65 -1.67 -0.51 -0.18 0.41 0.7 1.87 ...
          Year Month   VIX   Chg
1/31/1992 1992     1 17.40 -1.91
2/28/1992 1992     2 16.68 -0.72
3/31/1992 1992     3 16.18 -0.50
4/30/1992 1992     4 15.53 -0.65
5/29/1992 1992     5 13.86 -1.67
6/30/1992 1992     6 13.35 -0.51
4/30/2004 2004     4 17.19  0.45
5/31/2004 2004     5 15.50 -1.69
6/30/2004 2004     6 14.34 -1.16
7/30/2004 2004     7 15.32  0.98
8/31/2004 2004     8 15.29 -0.03
9/30/2004 2004     9 13.34 -1.95
> round(matrix(with(VIX ,by(Chg,Month,mean))),2) #All years
       [,1]
 [1,] -1.21
 [2,]  0.41
 [3,]  0.13
 [4,] -1.22
 [5,] -1.04
 [6,] -0.66
 [7,]  1.70
 [8,]  1.78
 [9,]  1.44
[10,] -0.78
[11,] -1.47
[12,] -0.11
> round(matrix(with(VIXE,by(Chg,Month,mean))),2) #Election only
       [,1]
 [1,] -0.82
 [2,]  0.03
 [3,]  1.07
 [4,] -0.29
 [5,] -1.42
 [6,] -2.04
 [7,]  1.95
 [8,] -1.49
 [9,]  0.60
[10,]  2.03
[11,]  0.64
[12,]  0.18
> R.version.string
[1] "R version 2.0.0, 2004-10-04"
>

Other related posts: