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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Aug 3 01:14:30 CEST 2013


Author: chenyian
Date: 2013-08-03 01:14:29 +0200 (Sat, 03 Aug 2013)
New Revision: 2711

Modified:
   pkg/FactorAnalytics/R/factorModelEsDecomposition.R
   pkg/FactorAnalytics/R/fitFundamentalFactorModel.R
   pkg/FactorAnalytics/R/plot.FundamentalFactorModel.r
   pkg/FactorAnalytics/R/predict.FundamentalFactorModel.r
   pkg/FactorAnalytics/R/print.FundamentalFactorModel.r
   pkg/FactorAnalytics/R/summary.FundamentalFactorModel.r
   pkg/FactorAnalytics/man/factorModelEsDecomposition.Rd
   pkg/FactorAnalytics/man/fitFundamentalFactorModel.Rd
   pkg/FactorAnalytics/man/plot.FundamentalFactorModel.Rd
   pkg/FactorAnalytics/man/predict.FundamentalFactorModel.Rd
   pkg/FactorAnalytics/man/print.FundamentalFactorModel.Rd
   pkg/FactorAnalytics/man/summary.FundamentalFactorModel.Rd
Log:
debug examples for fitFundamentalFactorModel related function

Modified: pkg/FactorAnalytics/R/factorModelEsDecomposition.R
===================================================================
--- pkg/FactorAnalytics/R/factorModelEsDecomposition.R	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/R/factorModelEsDecomposition.R	2013-08-02 23:14:29 UTC (rev 2711)
@@ -60,7 +60,7 @@
 #' 
 #' # fundamental factor model
 #' # try to find factor contribution to ES for STI 
-#' data(stock)
+#' data(stock.df)
 #' fit.fund <- fitFundamentalFactorModel(exposure.names=c("BOOK2MARKET", "LOG.MARKETCAP")
 #'                                       , data=stock,returnsvar = "RETURN",datevar = "DATE",  
 #'                                      assetvar = "TICKER",

Modified: pkg/FactorAnalytics/R/fitFundamentalFactorModel.R
===================================================================
--- pkg/FactorAnalytics/R/fitFundamentalFactorModel.R	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/R/fitFundamentalFactorModel.R	2013-08-02 23:14:29 UTC (rev 2711)
@@ -64,7 +64,7 @@
 #' 
 #' \dontrun{
 #' # BARRA type factor model
-#' data(stock)
+#' data(stock.df)
 #' # there are 447 assets  
 #' exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP") 
 #' test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,

Modified: pkg/FactorAnalytics/R/plot.FundamentalFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/plot.FundamentalFactorModel.r	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/R/plot.FundamentalFactorModel.r	2013-08-02 23:14:29 UTC (rev 2711)
@@ -43,11 +43,8 @@
 #' 
 #' \dontrun{
 #' # BARRA type factor model
+#' data(stock.df)
 #' # there are 447 assets  
-#' data(stock)
-#' # BARRA type factor model
-#' data(stock)
-#' # there are 447 assets  
 #' exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP") 
 #' fit.fund <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,
 #'                                        datevar = "DATE", returnsvar = "RETURN",

Modified: pkg/FactorAnalytics/R/predict.FundamentalFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/predict.FundamentalFactorModel.r	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/R/predict.FundamentalFactorModel.r	2013-08-02 23:14:29 UTC (rev 2711)
@@ -13,7 +13,23 @@
 #' @method predict FundamentalFactorModel               
 #' @export
 #' @author Yi-An Chen
+#' @examples
+#' data(stock.df)
+#' fit.fund <- fitFundamentalFactorModel(exposure.names=c("BOOK2MARKET", "LOG.MARKETCAP")
+#'                                      , data=stock,returnsvar = "RETURN",datevar = "DATE",  
+#'                                      assetvar = "TICKER",
+#'                                      wls = TRUE, regression = "classic", 
+#'                                      covariance = "classic", full.resid.cov = FALSE)
+#' # If not specify anything, predict() will give fitted value
+#' predict(fit.fund)
 #' 
+#' # generate random data
+#' testdata <- data[,c("DATE","TICKER")]
+#' testdata$BOOK2MARKET <- rnorm(n=42465)
+#' testdata$LOG.MARKETCAP <- rnorm(n=42465)
+#' predict(fit.fund,testdata,new.assetvar="TICKER",new.datevar="DATE")
+#' 
+#' 
 predict.FundamentalFactorModel <- function(object,newdata,new.assetvar,new.datevar){
  
   # if there is no newdata provided

Modified: pkg/FactorAnalytics/R/print.FundamentalFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/print.FundamentalFactorModel.r	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/R/print.FundamentalFactorModel.r	2013-08-02 23:14:29 UTC (rev 2711)
@@ -9,7 +9,7 @@
 #' @author Yi-An Chen.
 #' @examples
 #' 
-#' data(stock)
+#' data(stock.df)
 #' # there are 447 assets  
 #' exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP") 
 #' test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,

Modified: pkg/FactorAnalytics/R/summary.FundamentalFactorModel.r
===================================================================
--- pkg/FactorAnalytics/R/summary.FundamentalFactorModel.r	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/R/summary.FundamentalFactorModel.r	2013-08-02 23:14:29 UTC (rev 2711)
@@ -9,7 +9,7 @@
 #' @author Yi-An Chen.
 #' @examples
 #' 
-#' data(stock)
+#' data(stock.df)
 #' # there are 447 assets  
 #' exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP") 
 #' test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,

Modified: pkg/FactorAnalytics/man/factorModelEsDecomposition.Rd
===================================================================
--- pkg/FactorAnalytics/man/factorModelEsDecomposition.Rd	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/man/factorModelEsDecomposition.Rd	2013-08-02 23:14:29 UTC (rev 2711)
@@ -74,7 +74,7 @@
 
 # fundamental factor model
 # try to find factor contribution to ES for STI
-data(stock)
+data(stock.df)
 fit.fund <- fitFundamentalFactorModel(exposure.names=c("BOOK2MARKET", "LOG.MARKETCAP")
                                       , data=stock,returnsvar = "RETURN",datevar = "DATE",
                                      assetvar = "TICKER",

Modified: pkg/FactorAnalytics/man/fitFundamentalFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitFundamentalFactorModel.Rd	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/man/fitFundamentalFactorModel.Rd	2013-08-02 23:14:29 UTC (rev 2711)
@@ -89,7 +89,7 @@
 \examples{
 \dontrun{
 # BARRA type factor model
-data(stock)
+data(stock.df)
 # there are 447 assets
 exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP")
 test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,

Modified: pkg/FactorAnalytics/man/plot.FundamentalFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/plot.FundamentalFactorModel.Rd	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/man/plot.FundamentalFactorModel.Rd	2013-08-02 23:14:29 UTC (rev 2711)
@@ -55,11 +55,8 @@
 \examples{
 \dontrun{
 # BARRA type factor model
+data(stock.df)
 # there are 447 assets
-data(stock)
-# BARRA type factor model
-data(stock)
-# there are 447 assets
 exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP")
 fit.fund <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,
                                        datevar = "DATE", returnsvar = "RETURN",

Modified: pkg/FactorAnalytics/man/predict.FundamentalFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/predict.FundamentalFactorModel.Rd	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/man/predict.FundamentalFactorModel.Rd	2013-08-02 23:14:29 UTC (rev 2711)
@@ -27,6 +27,22 @@
   asset variable and exact exposures names that are used in
   fit object by \code{fitFundamentalFactorModel}
 }
+\examples{
+data(stock.df)
+fit.fund <- fitFundamentalFactorModel(exposure.names=c("BOOK2MARKET", "LOG.MARKETCAP")
+                                     , data=stock,returnsvar = "RETURN",datevar = "DATE",
+                                     assetvar = "TICKER",
+                                     wls = TRUE, regression = "classic",
+                                     covariance = "classic", full.resid.cov = FALSE)
+# If not specify anything, predict() will give fitted value
+predict(fit.fund)
+
+# generate random data
+testdata <- data[,c("DATE","TICKER")]
+testdata$BOOK2MARKET <- rnorm(n=42465)
+testdata$LOG.MARKETCAP <- rnorm(n=42465)
+predict(fit.fund,testdata,new.assetvar="TICKER",new.datevar="DATE")
+}
 \author{
   Yi-An Chen
 }

Modified: pkg/FactorAnalytics/man/print.FundamentalFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/print.FundamentalFactorModel.Rd	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/man/print.FundamentalFactorModel.Rd	2013-08-02 23:14:29 UTC (rev 2711)
@@ -19,7 +19,7 @@
   fitFundamentalFactorModel.
 }
 \examples{
-data(stock)
+data(stock.df)
 # there are 447 assets
 exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP")
 test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,

Modified: pkg/FactorAnalytics/man/summary.FundamentalFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/summary.FundamentalFactorModel.Rd	2013-08-02 23:09:10 UTC (rev 2710)
+++ pkg/FactorAnalytics/man/summary.FundamentalFactorModel.Rd	2013-08-02 23:14:29 UTC (rev 2711)
@@ -19,7 +19,7 @@
   fitFundamentalFactorModel.
 }
 \examples{
-data(stock)
+data(stock.df)
 # there are 447 assets
 exposure.names <- c("BOOK2MARKET", "LOG.MARKETCAP")
 test.fit <- fitFundamentalFactorModel(data=data,exposure.names=exposure.names,



More information about the Returnanalytics-commits mailing list