[Returnanalytics-commits] r2743 - in pkg/FactorAnalytics: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 8 20:11:07 CEST 2013


Author: chenyian
Date: 2013-08-08 20:11:07 +0200 (Thu, 08 Aug 2013)
New Revision: 2743

Added:
   pkg/FactorAnalytics/R/dCornishFisher.R
   pkg/FactorAnalytics/R/pCornishFisher.R
   pkg/FactorAnalytics/R/qCornishFisher.R
Modified:
   pkg/FactorAnalytics/NAMESPACE
   pkg/FactorAnalytics/R/fitFundamentalFactorModel.R
   pkg/FactorAnalytics/man/CornishFisher.Rd
   pkg/FactorAnalytics/man/Stock.df.Rd
   pkg/FactorAnalytics/man/fitFundamentalFactorModel.Rd
Log:
debug rd files to pass R CMD check

Modified: pkg/FactorAnalytics/NAMESPACE
===================================================================
--- pkg/FactorAnalytics/NAMESPACE	2013-08-08 18:10:46 UTC (rev 2742)
+++ pkg/FactorAnalytics/NAMESPACE	2013-08-08 18:11:07 UTC (rev 2743)
@@ -1,4 +1,3 @@
-export(CornishFisher)
 export(dCornishFisher)
 export(factorModelCovariance)
 export(factorModelEsDecomposition)
@@ -10,6 +9,7 @@
 export(fitTimeSeriesFactorModel)
 export(pCornishFisher)
 export(qCornishFisher)
+export(rCornishFisher)
 S3method(plot,FundamentalFactorModel)
 S3method(plot,StatFactorModel)
 S3method(plot,TimeSeriesFactorModel)

Added: pkg/FactorAnalytics/R/dCornishFisher.R
===================================================================
--- pkg/FactorAnalytics/R/dCornishFisher.R	                        (rev 0)
+++ pkg/FactorAnalytics/R/dCornishFisher.R	2013-08-08 18:11:07 UTC (rev 2743)
@@ -0,0 +1,15 @@
+#'@name  CornishFisher
+#'@aliases CornishFisher
+#'@aliases rCornishFisher 
+#'@aliases dCornishFisher
+#'@aliases qCornishFisher
+#'@aliases pCornishFisher
+#' @export
+dCornishFisher <-
+function(x, n,skew, ekurt) {
+
+density <- dnorm(x) + 1/sqrt(n)*(skew/6*(x^3-3*x))*dnorm(x) +
+    1/n *( (skew)^2/72*(x^6 - 15*x^4 + 45*x^2 -15) + ekurt/24 *(x^4-6*x^2+3) )*dnorm(x)
+return(density)
+}
+

Modified: pkg/FactorAnalytics/R/fitFundamentalFactorModel.R
===================================================================
--- pkg/FactorAnalytics/R/fitFundamentalFactorModel.R	2013-08-08 18:10:46 UTC (rev 2742)
+++ pkg/FactorAnalytics/R/fitFundamentalFactorModel.R	2013-08-08 18:11:07 UTC (rev 2743)
@@ -83,7 +83,7 @@
 #' data(Stock.df)
 #' # there are 447 assets  
 #' exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP") 
-#' test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,
+#' test.fit <- fitFundamentalFactorModel(data=stock,exposure.names=exposure.names,
 #'                                        datevar = "DATE", returnsvar = "RETURN",
 #'                                        assetvar = "TICKER", wls = TRUE, 
 #'                                        regression = "classic", 
@@ -104,7 +104,7 @@
 #' # BARRA type Industry Factor Model
 #' exposure.names <- c("GICS.SECTOR")  
 #' # the rest keep the same
-#' test.fit2 <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,
+#' test.fit2 <- fitFundamentalFactorModel(data=stock,exposure.names=exposure.names,
 #'                                        datevar = "DATE", returnsvar = "RETURN",
 #'                                        assetvar = "TICKER", wls = TRUE, 
 #'                                        regression = "classic", 

Added: pkg/FactorAnalytics/R/pCornishFisher.R
===================================================================
--- pkg/FactorAnalytics/R/pCornishFisher.R	                        (rev 0)
+++ pkg/FactorAnalytics/R/pCornishFisher.R	2013-08-08 18:11:07 UTC (rev 2743)
@@ -0,0 +1,16 @@
+#'@name  CornishFisher
+#'@aliases CornishFisher
+#'@aliases rCornishFisher 
+#'@aliases dCornishFisher
+#'@aliases qCornishFisher
+#'@aliases pCornishFisher
+#' @export 
+
+pCornishFisher <-
+function(q,n,skew, ekurt) {
+zq = q 
+CDF = pnorm(zq)  +   1/sqrt(n) *(skew/6 * (1-zq^2))*dnorm(zq) + 
+     1/n *( (ekurt)/24*(3*zq-zq^3)+ (skew)^2/72*(10*zq^3 - 15*zq -zq^5))*dnorm(zq)
+return(CDF)
+}
+

Added: pkg/FactorAnalytics/R/qCornishFisher.R
===================================================================
--- pkg/FactorAnalytics/R/qCornishFisher.R	                        (rev 0)
+++ pkg/FactorAnalytics/R/qCornishFisher.R	2013-08-08 18:11:07 UTC (rev 2743)
@@ -0,0 +1,18 @@
+#'@name  CornishFisher
+#'@aliases CornishFisher
+#'@aliases rCornishFisher 
+#'@aliases dCornishFisher
+#'@aliases qCornishFisher
+#'@aliases pCornishFisher
+#' @export 
+
+qCornishFisher <-
+function(p,n,skew, ekurt) {
+zq = qnorm(p)
+q.cf = zq  + 1/sqrt(n)* (((zq^2 - 1) * skew)/6) + 1/n*((((zq^3 - 3 * zq) *
+      ekurt)/24) - ((((2 * zq^3) - 5 * zq) * skew^2)/36) )
+return(q.cf)
+  
+  
+}
+

Modified: pkg/FactorAnalytics/man/CornishFisher.Rd
===================================================================
--- pkg/FactorAnalytics/man/CornishFisher.Rd	2013-08-08 18:10:46 UTC (rev 2742)
+++ pkg/FactorAnalytics/man/CornishFisher.Rd	2013-08-08 18:11:07 UTC (rev 2743)
@@ -7,6 +7,12 @@
 \title{Functions for Cornish-Fisher density, CDF, random number simulation and
 quantile.}
 \usage{
+  dCornishFisher(x, n, skew, ekurt)
+
+  pCornishFisher(q, n, skew, ekurt)
+
+  qCornishFisher(p, n, skew, ekurt)
+
   rCornishFisher(n, sigma, skew, ekurt, seed = NULL)
 }
 \arguments{

Modified: pkg/FactorAnalytics/man/Stock.df.Rd
===================================================================
--- pkg/FactorAnalytics/man/Stock.df.Rd	2013-08-08 18:10:46 UTC (rev 2742)
+++ pkg/FactorAnalytics/man/Stock.df.Rd	2013-08-08 18:11:07 UTC (rev 2743)
@@ -1,6 +1,7 @@
 \docType{data}
 \name{Stock.df}
 \alias{Stock.df}
+\alias{stock}
 \title{constructed NYSE 447 assets from 1996-01-01 through 2003-12-31.}
 \description{
   constructed NYSE 447 assets from 1996-01-01 through

Modified: pkg/FactorAnalytics/man/fitFundamentalFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitFundamentalFactorModel.Rd	2013-08-08 18:10:46 UTC (rev 2742)
+++ pkg/FactorAnalytics/man/fitFundamentalFactorModel.Rd	2013-08-08 18:11:07 UTC (rev 2743)
@@ -106,7 +106,7 @@
 data(Stock.df)
 # there are 447 assets
 exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP")
-test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,
+test.fit <- fitFundamentalFactorModel(data=stock,exposure.names=exposure.names,
                                        datevar = "DATE", returnsvar = "RETURN",
                                        assetvar = "TICKER", wls = TRUE,
                                        regression = "classic",
@@ -127,7 +127,7 @@
 # BARRA type Industry Factor Model
 exposure.names <- c("GICS.SECTOR")
 # the rest keep the same
-test.fit2 <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,
+test.fit2 <- fitFundamentalFactorModel(data=stock,exposure.names=exposure.names,
                                        datevar = "DATE", returnsvar = "RETURN",
                                        assetvar = "TICKER", wls = TRUE,
                                        regression = "classic",



More information about the Returnanalytics-commits mailing list