softs

get started

load libraries

options(digits = 4, width = 70)
library(boot)
library(tseries)
library(zoo)
library(PerformanceAnalytics)
library(multicore)

load data

returns.df = read.csv(file = "~/Documents/annual/returnsCME.csv", sep = ";", 
    header = TRUE, stringsAsFactors = FALSE)
returns.df[is.na(returns.df)] = 0
returns.z = zooreg(data = returns.df[, -1], start = c(1992, 41), end = c(2011, 
    12), frequency = 52)
soft.z = returns.z[, c("cocoa", "coffee", "cotton", "sugar", "lumber", 
    "orange")]

load functions

wget.and.source <- function(url) {
    fname <- tempfile()
    download.file(url, fname, method = "wget")
    source(fname)
    unlink(fname)
}
wget.and.source("https://gist.github.com/bautheac/b2e8269868a881b66a69/raw/")

soft distributions:

rolling estimates

rollMomentssoft.ls = rollingMoments.fun(soft.z, startYear = 1992, startWeek = 41, 
    width = 52)

cocoa

summary

plot of chunk cocoa distribution summary

moments

mean (\( \widehat{\mu} \)) and 95% confidence interval:

mu95CI(soft.z, "cocoa")
##          muhat standard error lower bound upper bound
## [1,] 0.0002386       0.001368   -0.002496    0.002974

standard deviation (\( \widehat{\sigma} \)) and 95% confidence interval:

sd95CI(soft.z, "cocoa")
##        sdhat standard error lower bound upper bound
## [1,] 0.04246       0.001332      0.0398     0.04512

coeffciient of skweness (\( \widehat{\gamma}_{1} \)) and 95% confidence interval:

skew95CI(returns.df, "cocoa")
##       skewhat standard error lower bound upper bound
## [1,] -0.09246         0.1971     -0.4867      0.3018

coefficient of kurtosis (\( \widehat{\beta}_{2} \)) and 95% confidence interval:

kurt95CI(returns.df, "cocoa")
##      kurthat standard error lower bound upper bound
## [1,]   1.885          0.712      0.4609       3.309

rolling moments

rolling \( \widehat{\mu} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["cocoa"]][["mu"]])
##          muhat.lower      muhat muhat.upper
## 1993(41)    -0.04733  2.000e-02    0.087326
## 1993(42)    -0.08962 -2.000e-02    0.049616
## 1993(43)    -0.04916  2.000e-02    0.089164
## 1993(44)    -0.06894  6.875e-18    0.068942
## 1993(45)    -0.04848  2.000e-02    0.088481
## 1993(46)    -0.13580 -7.000e-02   -0.004198
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "cocoa", statistic = "mu")

plot of chunk cocoa rolling mu plot

rolling \( \widehat{\sigma} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["cocoa"]][["sd"]])
##          sdhat.lower  sdhat sdhat.upper
## 1993(41)      0.2360 0.2427      0.2495
## 1993(42)      0.2439 0.2510      0.2581
## 1993(43)      0.2423 0.2494      0.2564
## 1993(44)      0.2412 0.2486      0.2559
## 1993(45)      0.2394 0.2469      0.2544
## 1993(46)      0.2300 0.2373      0.2445
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "cocoa", statistic = "sd")

plot of chunk cocoa rolling sd plot

rolling \( \widehat{\gamma}_{1} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["cocoa"]][["skew"]])
##          skewhat.lower  skewhat skewhat.upper
## 1993(41)       -0.5853  0.05985        0.7050
## 1993(42)       -0.6189 -0.02943        0.5601
## 1993(43)       -0.6496 -0.08444        0.4807
## 1993(44)       -0.6220 -0.05511        0.5118
## 1993(45)       -0.6838 -0.07743        0.5289
## 1993(46)       -0.7543 -0.12004        0.5142
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "cocoa", statistic = "skew")

plot of chunk cocoa rolling skew plot

rolling \( \widehat{\beta}_{2} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["cocoa"]][["kurt"]])
##          kurthat.lower kurthat kurthat.upper
## 1993(41)       -0.8693  0.2326         1.335
## 1993(42)       -0.9542  0.1447         1.244
## 1993(43)       -0.8022  0.2217         1.246
## 1993(44)       -0.8531  0.2582         1.369
## 1993(45)       -0.7295  0.3379         1.405
## 1993(46)       -0.7598  0.4753         1.710
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "cocoa", statistic = "kurt")

plot of chunk cocoa rolling kurt plot

coffee

summary

plot of chunk coffee distribution summary

moments

mean (\( \widehat{\mu} \)) and 95% confidence interval:

mu95CI(soft.z, "coffee")
##         muhat standard error lower bound upper bound
## [1,] 0.000249       0.001711   -0.003173    0.003671

standard deviation (\( \widehat{\sigma} \)) and 95% confidence interval:

sd95CI(soft.z, "coffee")
##        sdhat standard error lower bound upper bound
## [1,] 0.05312        0.00234     0.04844      0.0578

coeffciient of skweness (\( \widehat{\gamma}_{1} \)) and 95% confidence interval:

skew95CI(returns.df, "coffee")
##      skewhat standard error lower bound upper bound
## [1,]  0.7412         0.4273     -0.1134       1.596

coefficient of kurtosis (\( \widehat{\beta}_{2} \)) and 95% confidence interval:

kurt95CI(returns.df, "coffee")
##      kurthat standard error lower bound upper bound
## [1,]   5.448           2.68     0.08747       10.81

rolling moments

rolling \( \widehat{\mu} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["coffee"]][["mu"]])
##          muhat.lower muhat muhat.upper
## 1993(41)     0.01238  0.13      0.2476
## 1993(42)    -0.06501  0.05      0.1650
## 1993(43)    -0.06501  0.05      0.1650
## 1993(44)    -0.07478  0.04      0.1548
## 1993(45)    -0.09424  0.02      0.1342
## 1993(46)    -0.07354  0.04      0.1535
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "coffee", statistic = "mu")

plot of chunk coffee rolling mu plot

rolling \( \widehat{\sigma} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["coffee"]][["sd"]])
##          sdhat.lower  sdhat sdhat.upper
## 1993(41)      0.4133 0.4241      0.4348
## 1993(42)      0.4040 0.4147      0.4253
## 1993(43)      0.4036 0.4147      0.4257
## 1993(44)      0.4032 0.4138      0.4245
## 1993(45)      0.4010 0.4119      0.4227
## 1993(46)      0.3987 0.4094      0.4201
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "coffee", statistic = "sd")

plot of chunk coffee rolling sd plot

rolling \( \widehat{\gamma}_{1} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["coffee"]][["skew"]])
##          skewhat.lower skewhat skewhat.upper
## 1993(41)       -0.3088  0.2141        0.7370
## 1993(42)       -0.3315  0.2403        0.8122
## 1993(43)       -0.3205  0.2403        0.8012
## 1993(44)       -0.3165  0.2483        0.8131
## 1993(45)       -0.3229  0.2622        0.8473
## 1993(46)       -0.3265  0.2632        0.8530
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "coffee", statistic = "skew")

plot of chunk coffee rolling skew plot

rolling \( \widehat{\beta}_{2} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["coffee"]][["kurt"]])
##          kurthat.lower  kurthat kurthat.upper
## 1993(41)        -1.298 -0.35545        0.5874
## 1993(42)        -1.224 -0.19326        0.8379
## 1993(43)        -1.240 -0.19326        0.8532
## 1993(44)        -1.267 -0.17008        0.9272
## 1993(45)        -1.267 -0.11900        1.0290
## 1993(46)        -1.250 -0.07559        1.0989
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "coffee", statistic = "kurt")

plot of chunk coffee rolling kurt plot

cotton

summary

plot of chunk cotton distribution summary

moments

mean (\( \widehat{\mu} \)) and 95% confidence interval:

mu95CI(soft.z, "cotton")
##           muhat standard error lower bound upper bound
## [1,] -0.0001037       0.001208   -0.002519    0.002312

standard deviation (\( \widehat{\sigma} \)) and 95% confidence interval:

sd95CI(soft.z, "cotton")
##       sdhat standard error lower bound upper bound
## [1,] 0.0375       0.001154     0.03519     0.03981

coeffciient of skweness (\( \widehat{\gamma}_{1} \)) and 95% confidence interval:

skew95CI(returns.df, "cotton")
##      skewhat standard error lower bound upper bound
## [1,]  0.1496         0.1624     -0.1751      0.4743

coefficient of kurtosis (\( \widehat{\beta}_{2} \)) and 95% confidence interval

kurt95CI(returns.df, "cotton")
##      kurthat standard error lower bound upper bound
## [1,]    1.68          0.381      0.9178       2.442

rolling moments

rolling \( \widehat{\mu} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["cotton"]][["mu"]])
##          muhat.lower muhat muhat.upper
## 1993(41)   -0.033572  0.02    0.073572
## 1993(42)    0.005313  0.06    0.114687
## 1993(43)   -0.035301  0.02    0.075301
## 1993(44)   -0.045376  0.01    0.065376
## 1993(45)   -0.025081  0.03    0.085081
## 1993(46)   -0.101527 -0.05    0.001527
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "cotton", statistic = "mu")

plot of chunk cotton rolling mu plot

rolling \( \widehat{\sigma} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["cotton"]][["sd"]])
##          sdhat.lower  sdhat sdhat.upper
## 1993(41)      0.1875 0.1932      0.1988
## 1993(42)      0.1918 0.1972      0.2025
## 1993(43)      0.1941 0.1994      0.2047
## 1993(44)      0.1945 0.1997      0.2048
## 1993(45)      0.1933 0.1986      0.2039
## 1993(46)      0.1811 0.1858      0.1905
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "cotton", statistic = "sd")

plot of chunk cotton rolling sd plot

rolling \( \widehat{\gamma}_{1} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["cotton"]][["skew"]])
##          skewhat.lower   skewhat skewhat.upper
## 1993(41)       -0.6425 -0.016715        0.6090
## 1993(42)       -0.6441 -0.040745        0.5627
## 1993(43)       -0.5368  0.015927        0.5687
## 1993(44)       -0.5426  0.035858        0.6143
## 1993(45)       -0.5628  0.001933        0.5667
## 1993(46)       -0.6796 -0.205279        0.2690
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "cotton", statistic = "skew")

plot of chunk cotton rolling skew plot

rolling \( \widehat{\beta}_{2} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["cotton"]][["kurt"]])
##          kurthat.lower  kurthat kurthat.upper
## 1993(41)       -0.8038  0.18962        1.1831
## 1993(42)       -0.8569  0.02530        0.9075
## 1993(43)       -0.9507 -0.07785        0.7951
## 1993(44)       -1.0100 -0.09253        0.8250
## 1993(45)       -0.8758 -0.03683        0.8021
## 1993(46)       -1.0236 -0.25558        0.5124
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "cotton", statistic = "kurt")

plot of chunk cotton rolling kurt plot

sugar

summary

plot of chunk sugar distribution summary

moments

mean (\( \widehat{\mu} \)) and 95% confidence interval:

mu95CI(soft.z, "sugar")
##          muhat standard error lower bound upper bound
## [1,] 0.0009959       0.001404   -0.001811    0.003803

standard deviation (\( \widehat{\sigma} \)) and 95% confidence interval:

sd95CI(soft.z, "sugar")
##        sdhat standard error lower bound upper bound
## [1,] 0.04358       0.001256     0.04107     0.04609

coeffciient of skweness (\( \widehat{\gamma}_{1} \)) and 95% confidence interval:

skew95CI(returns.df, "sugar")
##      skewhat standard error lower bound upper bound
## [1,] -0.3441         0.1193     -0.5828     -0.1055

coefficient of kurtosis (\( \widehat{\beta}_{2} \)) and 95% confidence interval:

kurt95CI(returns.df, "sugar")
##      kurthat standard error lower bound upper bound
## [1,]    1.24         0.2986      0.6427       1.837

rolling moments

rolling \( \widehat{\mu} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["sugar"]][["mu"]])
##          muhat.lower muhat muhat.upper
## 1993(41)   -0.025714  0.07      0.1657
## 1993(42)   -0.005361  0.09      0.1854
## 1993(43)   -0.035273  0.06      0.1553
## 1993(44)   -0.025139  0.07      0.1651
## 1993(45)   -0.025139  0.07      0.1651
## 1993(46)   -0.015168  0.08      0.1752
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "sugar", statistic = "mu")

plot of chunk sugar rolling mu plot

rolling \( \widehat{\sigma} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["sugar"]][["sd"]])
##          sdhat.lower  sdhat sdhat.upper
## 1993(41)      0.3329 0.3451      0.3573
## 1993(42)      0.3323 0.3438      0.3554
## 1993(43)      0.3310 0.3435      0.3561
## 1993(44)      0.3304 0.3430      0.3556
## 1993(45)      0.3310 0.3430      0.3551
## 1993(46)      0.3310 0.3431      0.3553
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "sugar", statistic = "sd")

plot of chunk sugar rolling sd plot

rolling \( \widehat{\gamma}_{1} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["sugar"]][["skew"]])
##          skewhat.lower   skewhat skewhat.upper
## 1993(41)        -1.052 -0.012435        1.0267
## 1993(42)        -1.030 -0.031652        0.9662
## 1993(43)        -1.007  0.003537        1.0136
## 1993(44)        -1.070 -0.007208        1.0557
## 1993(45)        -1.057 -0.007208        1.0429
## 1993(46)        -1.085 -0.019325        1.0465
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "sugar", statistic = "skew")

plot of chunk sugar rolling skew plot

rolling \( \widehat{\beta}_{2} \) and 95% confidence interval:

time series overview
head(rollMomentssoft.ls[["sugar"]][["kurt"]])
##          kurthat.lower kurthat kurthat.upper
## 1993(41)       -0.3697   1.328         3.026
## 1993(42)       -0.2890   1.390         3.069
## 1993(43)       -0.3223   1.405         3.132
## 1993(44)       -0.1612   1.429         3.020
## 1993(45)       -0.2539   1.429         3.112
## 1993(46)       -0.3172   1.424         3.165
plot
plotRollingMoments(data = rollMomentssoft.ls, commo = "sugar", statistic = "kurt")

plot of chunk sugar rolling kurt plot

lumber

summary

## Error: objet 'grains.z' introuvable

moments

mean (\( \widehat{\mu} \)) and 95% confidence interval:

mu95CI(grains.z, "lumber")
## Error: objet 'grains.z' introuvable

standard deviation (\( \widehat{\sigma} \)) and 95% confidence interval:

sd95CI(grains.z, "lumber")
## Error: objet 'grains.z' introuvable

coeffciient ofskweness (\( \widehat{\gamma}_{1} \)) and 95% confidence interval:

skew95CI(returns.df, "lumber")
##      skewhat standard error lower bound upper bound
## [1,]  0.1972        0.07729     0.04267      0.3518

coefficient of kurtosis (\( \widehat{\beta}_{2} \)) and 95% confidence interval:

kurt95CI(returns.df, "lumber")
##       kurthat standard error lower bound upper bound
## [1,] -0.01287         0.1534     -0.3197       0.294

rolling moments

rolling \( \widehat{\mu} \) and 95% confidence interval:

time series overview
head(rollMomentsGrains.ls[["lumber"]][["mu"]])
## Error: objet 'rollMomentsGrains.ls' introuvable
plot
plotRollingMoments(data = rollMomentsGrains.ls, commo = "lumber", statistic = "mu")
## Error: objet 'rollMomentsGrains.ls' introuvable

rolling \( \widehat{\sigma} \) and 95% confidence interval:

time series overview
head(rollMomentsGrains.ls[["lumber"]][["sd"]])
## Error: objet 'rollMomentsGrains.ls' introuvable
plot
plotRollingMoments(data = rollMomentsGrains.ls, commo = "lumber", statistic = "sd")
## Error: objet 'rollMomentsGrains.ls' introuvable

rolling \( \widehat{\gamma}_{1} \) and 95% confidence interval:

time series overview
head(rollMomentsGrains.ls[["lumber"]][["skew"]])
## Error: objet 'rollMomentsGrains.ls' introuvable
plot
plotRollingMoments(data = rollMomentsGrains.ls, commo = "lumber", statistic = "skew")
## Error: objet 'rollMomentsGrains.ls' introuvable

rolling \( \widehat{\beta}_{2} \) and 95% confidence interval:

time series overview
head(rollMomentsGrains.ls[["lumber"]][["kurt"]])
## Error: objet 'rollMomentsGrains.ls' introuvable
plot
plotRollingMoments(data = rollMomentsGrains.ls, commo = "lumber", statistic = "kurt")
## Error: objet 'rollMomentsGrains.ls' introuvable

orange

summary

## Error: objet 'grains.z' introuvable

moments

mean (\( \widehat{\mu} \)) and 95% confidence interval:

mu95CI(grains.z, "orange")
## Error: objet 'grains.z' introuvable

standard deviation (\( \widehat{\sigma} \)) and 95% confidence interval:

sd95CI(grains.z, "orange")
## Error: objet 'grains.z' introuvable

coeffciient ofskweness (\( \widehat{\gamma}_{1} \)) and 95% confidence interval:

skew95CI(returns.df, "orange")
##      skewhat standard error lower bound upper bound
## [1,]  0.3865         0.2101    -0.03365      0.8066

coefficient of kurtosis (\( \widehat{\beta}_{2} \)) and 95% confidence interval:

kurt95CI(returns.df, "orange")
##      kurthat standard error lower bound upper bound
## [1,]   2.586         0.8756       0.835       4.337

rolling moments

rolling \( \widehat{\mu} \) and 95% confidence interval:

time series overview
head(rollMomentsGrains.ls[["orange"]][["mu"]])
## Error: objet 'rollMomentsGrains.ls' introuvable
plot
plotRollingMoments(data = rollMomentsGrains.ls, commo = "orange", statistic = "mu")
## Error: objet 'rollMomentsGrains.ls' introuvable

rolling \( \widehat{\sigma} \) and 95% confidence interval:

time series overview
head(rollMomentsGrains.ls[["orange"]][["sd"]])
## Error: objet 'rollMomentsGrains.ls' introuvable
plot
plotRollingMoments(data = rollMomentsGrains.ls, commo = "orange", statistic = "sd")
## Error: objet 'rollMomentsGrains.ls' introuvable

rolling \( \widehat{\gamma}_{1} \) and 95% confidence interval:

time series overview
head(rollMomentsGrains.ls[["orange"]][["skew"]])
## Error: objet 'rollMomentsGrains.ls' introuvable
plot
plotRollingMoments(data = rollMomentsGrains.ls, commo = "orange", statistic = "skew")
## Error: objet 'rollMomentsGrains.ls' introuvable

rolling \( \widehat{\beta}_{2} \) and 95% confidence interval:

time series overview
head(rollMomentsGrains.ls[["orange"]][["kurt"]])
## Error: objet 'rollMomentsGrains.ls' introuvable
plot
plotRollingMoments(data = rollMomentsGrains.ls, commo = "orange", statistic = "kurt")
## Error: objet 'rollMomentsGrains.ls' introuvable