Problem A **** BA log returns, in percentages, **** > da=read.table("d-ba9706.txt") > ba=log(da[,2]+1)*100 > basicStats(ba) round.ans..digits...6. nobs 2516.000000 NAs 0.000000 Minimum -19.388819 Maximum 11.000173 1. Quartile -1.149835 3. Quartile 1.193351 Mean 0.026282 Median 0.000000 Sum 66.125665 SE Mean 0.042731 LCL Mean -0.057509 UCL Mean 0.110073 Variance 4.593997 Stdev 2.143361 Skewness -0.624541 Kurtosis 7.543017 > Box.test(ba,lag=10,type='Ljung') Box-Ljung test data: ba X-squared = 17.3332, df = 10, p-value = 0.06731 > Box.test(ba^2,lag=10,type='Ljung') Box-Ljung test data: ba^2 X-squared = 145.0247, df = 10, p-value < 2.2e-16 ****** Growth Rate of U.S. Quarterly GDP ************ > da=read.table("q-gdpun.txt") > gdp=da[,4] > x=diff(gdp) > m2=arima(x,order=c(3,0,0)) > m2 arima(x = x, order = c(3, 0, 0)) Coefficients: ar1 ar2 ar3 intercept 0.3111 0.1223 -0.1131 0.0085 s.e. 0.0659 0.0685 0.0657 0.0009 sigma^2 estimated as 8.7e-05: log likelihood = 738.99, aic = -1467.99 > p1=c(1,-m2$coef[1:3]) > mm=polyroot(p1) > mm [1] 1.609803+1.242145i -2.138323-0.000000i 1.609803-1.242145i > Mod(mm) [1] 2.033320 2.138323 2.033320 > k=2*pi/acos(1.6098/2.0333) > k [1] 9.560824 ****** Problems B & C ********** > nba=-ba > m1=gev(nba,block=63) > m1 $n.all [1] 2516 $n [1] 40 $data [1] 3.688185 6.715528 5.046206 11.907637 4.703920 3.744230 14.783897 ..... [36] 2.831717 2.480512 3.309154 4.706016 3.320524 $block [1] 63 $par.ests xi sigma mu 0.6198668 1.4191684 3.6360118 $par.ses xi sigma mu 0.2107701 0.2792803 0.2736889 > m2=gpd(nba,threshold=2.0) > m2 $n [1] 2516 $data [1] 2.495890 3.598994 2.076409 2.185714 2.226606 2.020271 2.307417 ...... [309] 2.984084 2.015169 4.706016 2.026393 2.131557 3.320524 2.149947 [316] 2.709374 $threshold [1] 2 $p.less.thresh [1] 0.8744038 $n.exceed [1] 316 $method [1] "ml" $par.ests xi beta 0.2146411 1.1285121 $par.ses xi beta 0.06297248 0.09431986 > riskmeasures(m2,c(0.95,0.99)) p quantile sfall [1,] 0.95 3.149277 4.900316 [2,] 0.99 5.792961 8.266527 > > sba=sort(ba) % sorting > length(ba) [1] 2516 > 2516*0.01 [1] 25.16 > sba[24:27] [1] -5.654919 -5.614716 -5.530132 -5.268373 > > m3=garchOxFit(formula.mean=~arma(0,0),formula.var=~garch(1,1),series=ba) ******************** ** SPECIFICATIONS ** ******************** Dependent variable : X Mean Equation : ARMA (0, 0) model. No regressor in the mean Variance Equation : GARCH (1, 1) model. No regressor in the variance The distribution is a Gauss distribution. Maximum Likelihood Estimation (Std.Errors based on Second derivatives) Coefficient Std.Error t-value t-prob Cst(M) 0.089082 0.036234 2.459 0.0140 Cst(V) 0.044535 0.016291 2.734 0.0063 ARCH(Alpha1) 0.058817 0.0089055 6.605 0.0000 GARCH(Beta1) 0.934182 0.010077 92.71 0.0000 No. Observations : 2516 No. Parameters : 4 Mean (Y) : 0.02628 Variance (Y) : 4.59217 Skewness (Y) : -0.62491 Kurtosis (Y) : 10.55140 Log Likelihood : -5313.728 Alpha[1]+Beta[1]: 0.99280 *************** ** FORECASTS ** *************** Number of Forecasts: 15 Horizon Mean Variance 1 0.08908 1.454 2 0.08908 1.488 .... 15 0.08908 1.909 --------------- > m4=garchOxFit(formula.mean=~arma(0,0),formula.var=~garch(1,1),series=ba,cond.dist="t") ******************** ** SPECIFICATIONS ** ******************** Dependent variable : X Mean Equation : ARMA (0, 0) model. No regressor in the mean Variance Equation : GARCH (1, 1) model. No regressor in the variance The distribution is a Student distribution, with 6.02138 degrees of freedom. Maximum Likelihood Estimation (Std.Errors based on Second derivatives) Coefficient Std.Error t-value t-prob Cst(M) 0.059900 0.034174 1.753 0.0798 Cst(V) 0.053963 0.025599 2.108 0.0351 ARCH(Alpha1) 0.045461 0.012919 3.519 0.0004 GARCH(Beta1) 0.941718 0.017135 54.96 0.0000 Student(DF) 6.021384 0.64644 9.315 0.0000 No. Observations : 2516 No. Parameters : 5 Mean (Y) : 0.02628 Variance (Y) : 4.59217 Skewness (Y) : -0.62491 Kurtosis (Y) : 10.55140 Log Likelihood : -5204.023 Alpha[1]+Beta[1]: 0.98718 *************** ** FORECASTS ** *************** Number of Forecasts: 15 Horizon Mean Variance 1 0.0599 1.674 2 0.0599 1.706 ..... 15 0.0599 2.093 --------------- > m5=garchOxFit(formula.mean=~arma(0,0),formula.var=~gjr(1,1),series=ba,cond.dist="t") ******************** ** SPECIFICATIONS ** ******************** Dependent variable : X Mean Equation : ARMA (0, 0) model. No regressor in the mean Variance Equation : GJR (1, 1) model. No regressor in the variance The distribution is a Student distribution, with 6.14234 degrees of freedom. Maximum Likelihood Estimation (Std.Errors based on Second derivatives) Coefficient Std.Error t-value t-prob Cst(M) 0.051306 0.034105 1.504 0.1326 Cst(V) 0.061139 0.026365 2.319 0.0205 ARCH(Alpha1) 0.027723 0.011760 2.357 0.0185 GARCH(Beta1) 0.938946 0.017489 53.69 0.0000 GJR(Gamma1) 0.037132 0.015838 2.344 0.0191 Student(DF) 6.142341 0.67201 9.140 0.0000 No. Observations : 2516 No. Parameters : 6 Mean (Y) : 0.02628 Variance (Y) : 4.59217 Skewness (Y) : -0.62491 Kurtosis (Y) : 10.55140 Log Likelihood : -5200.466 *************** ** FORECASTS ** *************** Number of Forecasts: 15 Horizon Mean Variance 1 0.05131 1.688 2 0.05131 1.724 ..... 15 0.05131 2.149 --------------- *********** ** TESTS ** *********** Statistic t-Test P-Value Skewness -0.40616 8.3222 8.6329e-017 Excess Kurtosis 4.8449 49.655 0.00000 Jarque-Bera 2529.9 .NaN 0.00000 --------------- Information Criterium (to be minimized) Akaike 4.138685 Shibata 4.138674 Schwarz 4.152589 Hannan-Quinn 4.143732 --------------- Q-Statistics on Standardized Residuals Q( 10) = 10.7315 [0.3788158] Q( 15) = 11.9655 [0.6816375] Q( 20) = 13.4701 [0.8563154] H0 : No serial correlation ==> Accept H0 when prob. is High [Q < Chisq(lag)] -------------- Q-Statistics on Squared Standardized Residuals --> P-values adjusted by 2 degree(s) of freedom Q( 10) = 13.0545 [0.1099896] Q( 15) = 16.6970 [0.2135289] Q( 20) = 20.0996 [0.3272395] H0 : No serial correlation ==> Accept H0 when prob. is High [Q < Chisq(lag)] -------------- **** FDX log returns, in percentages, ***** > da1=read.table("d-fdx9706.txt") > fdx=log(da1[,2]+1)*100 > mm1=garchOxFit(formula.mean=~arma(0,0),formula.var=~garch(1,1),series=fdx) ******************** ** SPECIFICATIONS ** ******************** Dependent variable : X Mean Equation : ARMA (0, 0) model. No regressor in the mean Variance Equation : GARCH (1, 1) model. No regressor in the variance The distribution is a Gauss distribution. Maximum Likelihood Estimation (Std.Errors based on Second derivatives) Coefficient Std.Error t-value t-prob Cst(M) 0.075075 0.036145 2.077 0.0379 Cst(V) 0.004411 0.0027352 1.613 0.1069 ARCH(Alpha1) 0.013437 0.0026088 5.151 0.0000 GARCH(Beta1) 0.985407 0.0028079 350.9 0.0000 No. Observations : 2516 No. Parameters : 4 Mean (Y) : 0.06366 Variance (Y) : 4.44261 Skewness (Y) : 0.08152 Kurtosis (Y) : 6.92232 Log Likelihood : -5273.391 Alpha[1]+Beta[1]: 0.99864 *************** ** FORECASTS ** *************** Number of Forecasts: 15 Horizon Mean Variance 1 0.07508 1.896 2 0.07508 1.898 ...... 15 0.07508 1.922 --------------- *********** ** TESTS ** *********** Statistic t-Test P-Value Skewness -0.15718 3.2205 0.0012797 Excess Kurtosis 4.7173 48.348 0.00000 Jarque-Bera 2343.3 .NaN 0.00000 --------------- Information Criterium (to be minimized) Akaike 4.195064 Shibata 4.195059 Schwarz 4.204334 Hannan-Quinn 4.198429 --------------- Q-Statistics on Standardized Residuals Q( 10) = 14.5459 [0.1495139] Q( 15) = 20.7975 [0.1434266] Q( 20) = 23.7219 [0.2547492] H0 : No serial correlation ==> Accept H0 when prob. is High [Q < Chisq(lag)] -------------- Q-Statistics on Squared Standardized Residuals --> P-values adjusted by 2 degree(s) of freedom Q( 10) = 6.21161 [0.6235420] Q( 15) = 7.40350 [0.8801783] Q( 20) = 9.89906 [0.9351512] H0 : No serial correlation ==> Accept H0 when prob. is High [Q < Chisq(lag)] -------------- > length(fdx) [1] 2516 > mm1$residuals[2516] [1] 0.544 > mm1$condvars[2516] [1] 1.9475 > cor(fdx,ba) [1] 0.2274864 > **** Problem D ****** **** FDX direction ***** > da=read.table("d-fdx9706.txt") > fdx=da[,2] > y=fdx[6:2516] > x2=fdx[4:2514] > x3=fdx[3:2513] > ydir=ifelse(y>0,1,0) > mm=glm(ydir~x2+x3,family=binomial) > summary(mm) Call: glm(formula = ydir ~ x2 + x3, family = binomial) Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -0.03074 0.04009 -0.767 0.44318 x2 -5.79652 1.91677 -3.024 0.00249 ** x3 -4.10553 1.90499 -2.155 0.03115 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Null deviance: 3480.0 on 2510 degrees of freedom Residual deviance: 3465.8 on 2508 degrees of freedom > fdxin=cbind(x2,x3) > m2=nnet(fdxin,ydir,skip=T,linout=F,size=2) # weights: 11 initial value 664.602945 iter 10 value 623.989720 final value 623.989523 converged > summary(m2) a 2-2-1 network with 11 weights options were - skip-layer connections b->h1 i1->h1 i2->h1 1.34 -1.13 -0.75 b->h2 i1->h2 i2->h2 3.10 0.12 0.07 b->o h1->o h2->o i1->o i2->o -0.71 1.06 -0.17 -5.61 -3.94 > pfit=predict(m2,fdxin) > > fit=mm$fitted.values > dif=fit-pfit > basicStats(dif) round.ans..digits...6. nobs 2511.000000 NAs 0.000000 Minimum -0.001046 Maximum 0.001156 1. Quartile -0.000127 3. Quartile 0.000052 Mean -0.000040 Median -0.000039 Sum -0.100122 SE Mean 0.000003 LCL Mean -0.000046 UCL Mean -0.000033 Variance 0.000000 Stdev 0.000165 Skewness 0.040515 Kurtosis 3.693464 >