[Uwgarp-commits] r61 - in pkg/GARPFRM: . R sandbox sandbox/project_plan

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 5 01:25:59 CET 2014


Author: tfillebeen
Date: 2014-02-05 01:25:59 +0100 (Wed, 05 Feb 2014)
New Revision: 61

Added:
   pkg/GARPFRM/R/garch11.R
Modified:
   pkg/GARPFRM/NAMESPACE
   pkg/GARPFRM/sandbox/project_plan/project_plan.pdf
   pkg/GARPFRM/sandbox/project_plan/project_plan.tex
   pkg/GARPFRM/sandbox/test_EWMA_GARCH.R
Log:
Proj Outline amendment + start on VaR + garch11 w/ fcstGarch11 method

Modified: pkg/GARPFRM/NAMESPACE
===================================================================
--- pkg/GARPFRM/NAMESPACE	2014-02-04 21:31:39 UTC (rev 60)
+++ pkg/GARPFRM/NAMESPACE	2014-02-05 00:25:59 UTC (rev 61)
@@ -1,3 +1,4 @@
+S3method(fGarch11,DCCfit)
 S3method(getAlphas,capm_mlm)
 S3method(getAlphas,capm_uv)
 S3method(getBetas,capm_mlm)
@@ -9,9 +10,11 @@
 export(CAPM)
 export(EWMA)
 export(chartSML)
+export(fGarch11)
+export(garch11)
 export(getAlphas)
 export(getBetas)
 export(getStatistics)
 export(hypTest)
-export(plot.capm_mv)
+export(plot.capm_mlm)
 export(plot.capm_uv)

Added: pkg/GARPFRM/R/garch11.R
===================================================================
--- pkg/GARPFRM/R/garch11.R	                        (rev 0)
+++ pkg/GARPFRM/R/garch11.R	2014-02-05 00:25:59 UTC (rev 61)
@@ -0,0 +1,37 @@
+#' GARCH(1,1)
+#' 
+#' Description of GARCH(1,1)
+#' 
+#' @param object GARCH(1,1)
+#' @export
+# UV N~GARCH(1,1) for each series
+garch11 <- function(object){
+garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0,0)), 
+                          variance.model = list(garchOrder = c(1,1), model = "sGARCH"), 
+                          distribution.model = "norm")
+
+# DCC specification: GARCH(1,1) for conditional cor
+dcc.garch11.spec = dccspec(uspec = multispec( replicate(2, garch11.spec) ), 
+                           dccOrder = c(1,1), distribution = "mvnorm")
+dcc.garch11.spec
+
+dcc.fit = dccfit(dcc.garch11.spec, data = object)
+return(dcc.fit)
+}
+
+#' Forecast GARCH(1,1)
+#' 
+#' Description of forecast GARCH(1,1)
+#' 
+#' @param object a garch11 object created by \code{\link{GARCH(1,1)}}
+#' @export
+fGarch11 <- function(object,window){
+  UseMethod("fGarch11")
+}
+
+#' @method fGarch11 Dccfit
+#' @S3method fGarch11 DCCfit
+fGarch11.DCCfit <- function(object,window = 100){
+  result = dccforecast(garch11, n.ahead=window)
+  return(result)
+}
\ No newline at end of file

Modified: pkg/GARPFRM/sandbox/project_plan/project_plan.pdf
===================================================================
(Binary files differ)

Modified: pkg/GARPFRM/sandbox/project_plan/project_plan.tex
===================================================================
--- pkg/GARPFRM/sandbox/project_plan/project_plan.tex	2014-02-04 21:31:39 UTC (rev 60)
+++ pkg/GARPFRM/sandbox/project_plan/project_plan.tex	2014-02-05 00:25:59 UTC (rev 61)
@@ -55,7 +55,7 @@
 \end{itemize}
 
 \section{Standard Capital Asset Pricing Model}
-We should have a \verb"CAPM" function that implements basic univariate and multivariate models. Objects created by the \verb"CAPM" function will be assigned a class of \verb"capm_uv" and \verb"capm_mv" for univariate and multivariate models, respectively. We also need functionality to do hypothesis testing.
+We should have a \verb"CAPM" function that implements basic univariate and multivariate models. Objects created by the \verb"CAPM" function will be assigned a class of \verb"capm_uv" and \verb"capm_mlm" for univariate and multi-linear models, respectively. We also need functionality to do hypothesis testing.
 
 At a minimum, the following functions will be included as "getter" methods for \verb"capm_uv" and \verb"capm_mv" objects:
 \begin{itemize}
@@ -104,21 +104,20 @@
 
 
 \section{Estimating Volatilities and Correlation}
-The book covers estimating volatility using EWMA model. and GARCH(1, 1) model. We should implement our own EWMA function, but should use the rugarch or fGarch package for the GARCH models.
+Estimating volatility using EWMA model and GARCH(1,1) model. Objects created by the \verb"garch11" function and \verb"EWMA" function.
 
 Additional features
 \begin{itemize}
 \item \verb"EWMA"
 \item \verb"garch11"
-\item \verb"fVol"
-\item \verb"fCor"
+\item \verb"fcstGarch11"
 \item Shiny app
 \item demo
 \item vignette
 \end{itemize}
 
 \section{Quantifying Volatility in VaR Models}
-Still need to read this section in more detail.
+VaR applying historical, and monter carlo approach ex-ante estimation of mean and standard deviation.
 
 
 \end{document}
\ No newline at end of file

Modified: pkg/GARPFRM/sandbox/test_EWMA_GARCH.R
===================================================================
--- pkg/GARPFRM/sandbox/test_EWMA_GARCH.R	2014-02-04 21:31:39 UTC (rev 60)
+++ pkg/GARPFRM/sandbox/test_EWMA_GARCH.R	2014-02-05 00:25:59 UTC (rev 61)
@@ -116,58 +116,44 @@
 par(mfrow=c(1,1))
 
 # Dynamic Conditional Cor
-# UV N~GARCH(1,1) for each series
-garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0,0)), 
-                          variance.model = list(garchOrder = c(1,1), 
-                                                model = "sGARCH"), 
-                          distribution.model = "norm")
+# Joint is the conditonal corr param w/ cov targeting
+garch11 <- garch11(temp)
 
-# DCC specification: GARCH(1,1) for conditional cor
-dcc.garch11.spec = dccspec(uspec = multispec( replicate(2, garch11.spec) ), 
-                           dccOrder = c(1,1), distribution = "mvnorm")
-dcc.garch11.spec
+class(garch11)
+slotNames(garch11)
+names(garch11 at mfit)
+names(garch11 at model)
 
-dcc.fit = dccfit(dcc.garch11.spec, data = temp)
-class(dcc.fit)
-slotNames(dcc.fit)
-names(dcc.fit at mfit)
-names(dcc.fit at model)
-
 # many extractor functions - see help on DCCfit object
-# coef, likelihood, rshape, rskew, fitted, sigma, 
-# residuals, plot, infocriteria, rcor, rcov
-# show, nisurface
-
+# coef, likelihood, rshape, rskew, fitted, sigma, residuals, plot, infocriteria, rcor, rcov show, nisurface
 # show dcc fit
-dcc.fit
+garch11
 
-# plot method
-plot(dcc.fit)
-# Make a plot selection (or 0 to exit): 
-# Where 1:   Conditional Mean (vs Realized Returns)
-# Where 2:   Conditional Sigma (vs Realized Absolute Returns)
-# Where 3:   Conditional Covariance
-# Where 4:   Conditional Correlation
-# Where 5:   EW Portfolio Plot with conditional density VaR limits
-
 # conditional sd of each series
-plot(dcc.fit, which=2)
+plot(garch11, which=2)
 
+# conditional covar of each series
+plot(garch11, which=3)
+
 # conditional cor
-plot(dcc.fit, which=4)
+plot(garch11, which=4)
 
-# extracting cor series
-ts.plot(rcor(dcc.fit)[1,2,])
+# plot mutiple time series: extracting cor series
+ts.plot(rcor(garch11)[1,2,])
 
-# Forecasting conditional vol and cor
-dcc.fcst = dccforecast(dcc.fit, n.ahead=100)
-class(dcc.fcst)
-slotNames(dcc.fcst)
-class(dcc.fcst at mforecast)
-names(dcc.fcst at mforecast)
+# Forecasting conditional vol and cor, default wd = 100
+fcstGarch11 = fGarch11(garch11)
 
+class(fcstGarch11)
+slotNames(fcstGarch11)
+class(fcstGarch11 at mforecast)
+names(fcstGarch11 at mforecast)
+
 # many method functions - see help on DCCforecast class
 # rshape, rskew, fitted, sigma, plot, rcor, rcov, show
 
-# show forecasts
-dcc.fcst
\ No newline at end of file
+# Show forecasts
+fcstGarch11
+
+# plot(garch11, which=3)
+plot(fcstGarch11, which=3)
\ No newline at end of file



More information about the Uwgarp-commits mailing list