livestock

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)
live.z = returns.z[, c("feeder", "live", "pork", "hogs")]

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/")

live distributions:

rolling estimates

rollMomentslive.ls = rollingMoments.fun(live.z, startYear = 1992, startWeek = 41, 
    width = 52)

feeder

summary

plot of chunk feeder distribution summary

moments

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

mu95CI(live.z, "feeder")
##          muhat standard error lower bound upper bound
## [1,] 0.0005394      0.0006583  -0.0007772    0.001856

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

sd95CI(live.z, "feeder")
##        sdhat standard error lower bound upper bound
## [1,] 0.02044      0.0005952     0.01925     0.02163

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

skew95CI(returns.df, "feeder")
##      skewhat standard error lower bound upper bound
## [1,] -0.2466         0.1411     -0.5289     0.03557

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

kurt95CI(returns.df, "feeder")
##      kurthat standard error lower bound upper bound
## [1,]   1.204         0.4156      0.3727       2.035

rolling moments

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

time series overview
head(rollMomentslive.ls[["feeder"]][["mu"]])
##          muhat.lower muhat muhat.upper
## 1993(41)     0.11827  0.14      0.1617
## 1993(42)     0.10764  0.13      0.1524
## 1993(43)     0.11721  0.14      0.1628
## 1993(44)     0.11721  0.14      0.1628
## 1993(45)     0.11721  0.14      0.1628
## 1993(46)     0.09636  0.12      0.1436
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "feeder", statistic = "mu")

plot of chunk feeder rolling mu plot

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

time series overview
head(rollMomentslive.ls[["feeder"]][["sd"]])
##          sdhat.lower   sdhat sdhat.upper
## 1993(41)     0.07651 0.07837     0.08022
## 1993(42)     0.07866 0.08062     0.08258
## 1993(43)     0.08022 0.08218     0.08413
## 1993(44)     0.08029 0.08218     0.08406
## 1993(45)     0.08026 0.08218     0.08410
## 1993(46)     0.08340 0.08522     0.08704
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "feeder", statistic = "sd")

plot of chunk feeder rolling sd plot

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

time series overview
head(rollMomentslive.ls[["feeder"]][["skew"]])
##          skewhat.lower skewhat skewhat.upper
## 1993(41)       -0.5905 -0.1799        0.2307
## 1993(42)       -0.6394 -0.2497        0.1400
## 1993(43)       -0.6069 -0.2209        0.1651
## 1993(44)       -0.5974 -0.2209        0.1557
## 1993(45)       -0.6101 -0.2209        0.1683
## 1993(46)       -0.6041 -0.2393        0.1255
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "feeder", statistic = "skew")

plot of chunk feeder rolling skew plot

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

time series overview
head(rollMomentslive.ls[["feeder"]][["kurt"]])
##          kurthat.lower kurthat kurthat.upper
## 1993(41)        -1.183 -0.5619      0.059219
## 1993(42)        -1.161 -0.5367      0.087236
## 1993(43)        -1.204 -0.5971      0.009402
## 1993(44)        -1.208 -0.5971      0.014103
## 1993(45)        -1.211 -0.5971      0.017309
## 1993(46)        -1.295 -0.6888     -0.082323
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "feeder", statistic = "kurt")

plot of chunk feeder rolling kurt plot

live

summary

plot of chunk live distribution summary

moments

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

mu95CI(live.z, "live")
##          muhat standard error lower bound upper bound
## [1,] 7.261e-05      0.0006881   -0.001304    0.001449

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

sd95CI(live.z, "live")
##        sdhat standard error lower bound upper bound
## [1,] 0.02136        0.00081     0.01974     0.02298

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

skew95CI(returns.df, "live")
##      skewhat standard error lower bound upper bound
## [1,] -0.4091         0.3627      -1.135      0.3164

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

kurt95CI(returns.df, "live")
##      kurthat standard error lower bound upper bound
## [1,]   3.596          2.438      -1.279       8.472

rolling moments

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

time series overview
head(rollMomentslive.ls[["live"]][["mu"]])
##          muhat.lower muhat muhat.upper
## 1993(41)     0.09961  0.13      0.1604
## 1993(42)     0.08916  0.12      0.1508
## 1993(43)     0.10829  0.14      0.1717
## 1993(44)     0.11848  0.15      0.1815
## 1993(45)     0.10829  0.14      0.1717
## 1993(46)     0.09810  0.13      0.1619
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "live", statistic = "mu")

plot of chunk live rolling mu plot

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

time series overview
head(rollMomentslive.ls[["live"]][["sd"]])
##          sdhat.lower  sdhat sdhat.upper
## 1993(41)      0.1068 0.1096      0.1124
## 1993(42)      0.1086 0.1112      0.1138
## 1993(43)      0.1117 0.1143      0.1170
## 1993(44)      0.1111 0.1136      0.1162
## 1993(45)      0.1118 0.1143      0.1169
## 1993(46)      0.1124 0.1150      0.1176
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "live", statistic = "sd")

plot of chunk live rolling sd plot

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

time series overview
head(rollMomentslive.ls[["live"]][["skew"]])
##          skewhat.lower skewhat skewhat.upper
## 1993(41)       -0.7188 -0.2603        0.1982
## 1993(42)       -0.6830 -0.2624        0.1582
## 1993(43)       -0.6091 -0.2115        0.1861
## 1993(44)       -0.6578 -0.2421        0.1735
## 1993(45)       -0.6417 -0.2115        0.2187
## 1993(46)       -0.6118 -0.1811        0.2496
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "live", statistic = "skew")

plot of chunk live rolling skew plot

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

time series overview
head(rollMomentslive.ls[["live"]][["kurt"]])
##          kurthat.lower kurthat kurthat.upper
## 1993(41)        -1.103 -0.4243      0.253971
## 1993(42)        -1.159 -0.5022      0.154021
## 1993(43)        -1.122 -0.5655     -0.008972
## 1993(44)        -1.152 -0.5026      0.146580
## 1993(45)        -1.161 -0.5655      0.029911
## 1993(46)        -1.184 -0.6239     -0.063518
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "live", statistic = "kurt")

plot of chunk live rolling kurt plot

pork

summary

plot of chunk pork distribution summary

moments

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

mu95CI(live.z, "pork")
##          muhat standard error lower bound upper bound
## [1,] 0.0004979       0.001541   -0.002583    0.003579

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

sd95CI(live.z, "pork")
##        sdhat standard error lower bound upper bound
## [1,] 0.04783       0.001411     0.04501     0.05065

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

skew95CI(returns.df, "pork")
##      skewhat standard error lower bound upper bound
## [1,]  0.1826         0.1355    -0.08837      0.4536

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

kurt95CI(returns.df, "pork")
##      kurthat standard error lower bound upper bound
## [1,]    1.25         0.3439      0.5622       1.938

rolling moments

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

time series overview
head(rollMomentslive.ls[["pork"]][["mu"]])
##          muhat.lower muhat muhat.upper
## 1993(41)     0.05782  0.16      0.2622
## 1993(42)     0.13623  0.24      0.3438
## 1993(43)     0.02888  0.13      0.2311
## 1993(44)     0.04877  0.15      0.2512
## 1993(45)     0.14906  0.25      0.3509
## 1993(46)     0.02507  0.13      0.2349
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "pork", statistic = "mu")

plot of chunk pork rolling mu plot

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

time series overview
head(rollMomentslive.ls[["pork"]][["sd"]])
##          sdhat.lower  sdhat sdhat.upper
## 1993(41)      0.3567 0.3684      0.3801
## 1993(42)      0.3626 0.3741      0.3856
## 1993(43)      0.3526 0.3646      0.3766
## 1993(44)      0.3528 0.3650      0.3772
## 1993(45)      0.3521 0.3639      0.3757
## 1993(46)      0.3664 0.3783      0.3903
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "pork", statistic = "sd")

plot of chunk pork rolling sd plot

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

time series overview
head(rollMomentslive.ls[["pork"]][["skew"]])
##          skewhat.lower skewhat skewhat.upper
## 1993(41)       -0.3386  0.4033         1.145
## 1993(42)       -0.3718  0.3379         1.048
## 1993(43)       -0.3720  0.3944         1.161
## 1993(44)       -0.4415  0.3708         1.183
## 1993(45)       -0.4984  0.2975         1.094
## 1993(46)       -0.5083  0.2399         0.988
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "pork", statistic = "skew")

plot of chunk pork rolling skew plot

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

time series overview
head(rollMomentslive.ls[["pork"]][["kurt"]])
##          kurthat.lower kurthat kurthat.upper
## 1993(41)       -0.5314  0.8377         2.207
## 1993(42)       -0.5772  0.6168         1.811
## 1993(43)       -0.4728  0.9052         2.283
## 1993(44)       -0.4070  0.8763         2.160
## 1993(45)       -0.4144  0.8587         2.132
## 1993(46)       -0.5176  0.6533         1.824
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "pork", statistic = "kurt")

plot of chunk pork rolling kurt plot

hogs

summary

plot of chunk hogs distribution summary

moments

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

mu95CI(live.z, "hogs")
##          muhat standard error lower bound upper bound
## [1,] -0.001193       0.001169    -0.00353    0.001144

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

sd95CI(live.z, "hogs")
##        sdhat standard error lower bound upper bound
## [1,] 0.03628       0.001417     0.03345     0.03912

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

skew95CI(returns.df, "hogs")
##      skewhat standard error lower bound upper bound
## [1,] -0.6328         0.3559      -1.345     0.07902

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

kurt95CI(returns.df, "hogs")
##      kurthat standard error lower bound upper bound
## [1,]   3.955          2.266      -0.577       8.487

rolling moments

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

time series overview
head(rollMomentslive.ls[["hogs"]][["mu"]])
##          muhat.lower muhat muhat.upper
## 1993(41)      0.1526  0.20      0.2474
## 1993(42)      0.2017  0.25      0.2983
## 1993(43)      0.1713  0.22      0.2687
## 1993(44)      0.1404  0.19      0.2396
## 1993(45)      0.2017  0.25      0.2983
## 1993(46)      0.1502  0.20      0.2498
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "hogs", statistic = "mu")

plot of chunk hogs rolling mu plot

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

time series overview
head(rollMomentslive.ls[["hogs"]][["sd"]])
##          sdhat.lower  sdhat sdhat.upper
## 1993(41)      0.1656 0.1709      0.1761
## 1993(42)      0.1688 0.1740      0.1792
## 1993(43)      0.1705 0.1757      0.1808
## 1993(44)      0.1738 0.1789      0.1841
## 1993(45)      0.1691 0.1740      0.1789
## 1993(46)      0.1746 0.1796      0.1846
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "hogs", statistic = "sd")

plot of chunk hogs rolling sd plot

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

time series overview
head(rollMomentslive.ls[["hogs"]][["skew"]])
##          skewhat.lower skewhat skewhat.upper
## 1993(41)       -0.2464  0.5428         1.332
## 1993(42)       -0.2501  0.4634         1.177
## 1993(43)       -0.2224  0.5010         1.224
## 1993(44)       -0.1693  0.4926         1.154
## 1993(45)       -0.1939  0.5141         1.222
## 1993(46)       -0.2174  0.4692         1.156
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "hogs", statistic = "skew")

plot of chunk hogs rolling skew plot

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

time series overview
head(rollMomentslive.ls[["hogs"]][["kurt"]])
##          kurthat.lower kurthat kurthat.upper
## 1993(41)        -1.273  0.5890         2.451
## 1993(42)        -1.335  0.3500         2.035
## 1993(43)        -1.418  0.2907         1.999
## 1993(44)        -1.407  0.1721         1.752
## 1993(45)        -1.439  0.2242         1.888
## 1993(46)        -1.452  0.1158         1.684
plot
plotRollingMoments(data = rollMomentslive.ls, commo = "hogs", statistic = "kurt")

plot of chunk hogs rolling kurt plot