[Returnanalytics-commits] r2356 - in pkg/FactorAnalytics: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jun 18 20:52:55 CEST 2013
Author: braverock
Date: 2013-06-18 20:52:55 +0200 (Tue, 18 Jun 2013)
New Revision: 2356
Added:
pkg/FactorAnalytics/R/FactorAnalytics-package.R
Modified:
pkg/FactorAnalytics/man/fitMacroeconomicFactorModel.Rd
Log:
- roxygenize fitMacroeconomicFactorModel
- add roxygen comment file for data sets, etc.
Added: pkg/FactorAnalytics/R/FactorAnalytics-package.R
===================================================================
--- pkg/FactorAnalytics/R/FactorAnalytics-package.R (rev 0)
+++ pkg/FactorAnalytics/R/FactorAnalytics-package.R 2013-06-18 18:52:55 UTC (rev 2356)
@@ -0,0 +1,132 @@
+
+
+#' Functions for Cornish-Fisher density, CDF, random number simulation and
+#' quantile.
+#'
+#' \code{dCornishFisher} Computes Cornish-Fisher density from two term
+#' Edgeworth expansion given mean, standard deviation, skewness and excess
+#' kurtosis. \code{pCornishFisher} Computes Cornish-Fisher CDF from two term
+#' Edgeworth expansion given mean, standard deviation, skewness and excess
+#' kurtosis. \code{qCornishFisher} Computes Cornish-Fisher quantiles from two
+#' term Edgeworth expansion given mean, standard deviation, skewness and excess
+#' kurtosis. \code{rCornishFisher} simulate observations based on
+#' Cornish-Fisher quantile expansion given mean, standard deviation, skewness
+#' and excess kurtosis.
+#'
+#' CDF(q) = Pr(sqrt(n)*(x_bar-mu)/sigma < q)
+#'
+#' @aliases rCornishFisher dCornishFisher pCornishFisher qCornishFisher
+#' @param n scalar, number of simulated values in rCornishFisher. Sample length
+#' in density,distribution,quantile function.
+#' @param sigma scalar, standard deviation.
+#' @param skew scalar, skewness.
+#' @param ekurt scalar, excess kurtosis.
+#' @param seed set seed here. Default is \code{NULL}.
+#' @param x,q vector of standardized quantiles. See detail.
+#' @param p vector of probabilities.
+#' @return n simulated values from Cornish-Fisher distribution.
+#' @author Eric Zivot and Yi-An Chen.
+#' @references A.DasGupta, "Asymptotic Theory of Statistics and Probability",
+#' Springer Science+Business Media,LLC 2008 Thomas A.Severini, "Likelihood
+#' Methods in Statistics", Oxford University Press, 2000
+#' @examples
+#'
+#' # generate 1000 observation from Cornish-Fisher distribution
+#' rc <- rCornishFisher(1000,1,0,5)
+#' hist(rc,breaks=100,freq=FALSE,main="simulation of Cornish Fisher Distribution",
+#' xlim=c(-10,10))
+#' lines(seq(-10,10,0.1),dnorm(seq(-10,10,0.1),mean=0,sd=1),col=2)
+#' # compare with standard normal curve
+#'
+#' # example from A.dasGupta p.188 exponential example
+#' # x is iid exp(1) distribution, sample size = 5
+#' # then x_bar is Gamma(shape=5,scale=1/5) distribution
+#' q <- c(0,0.4,1,2)
+#' # exact cdf
+#' pgamma(q/sqrt(5)+1,shape=5,scale=1/5)
+#' # use CLT
+#' pnorm(q)
+#' # use edgeworth expansion
+#' pCornishFisher(q,n=5,skew=2,ekurt=6)
+#'
+#' @name CornishFisher
+NULL
+
+
+
+
+
+#' Hypothetical Alternative Asset Manager and Benchmark Data
+#'
+#' a data.frame format from managers dataset from package PerformanceAnalytics,
+#' containing columns of monthly returns for six hypothetical asset managers
+#' (HAM1 through HAM6), the EDHEC Long-Short Equity hedge fund index, the S\&P
+#' 500 total returns. Monthly returns for all series end in December 2006 and
+#' begin at different periods starting from January 1997.
+#'
+#'
+#' @name managers.df
+#' @docType data
+#' @keywords datasets
+#' @examples
+#'
+#' data(managers.df)
+#' ## maybe str(managers.df) ; plot(managers.df) ...
+#'
+NULL
+
+
+
+
+
+#' Monthly Stock Return Data || Portfolio of Weekly Stock Returns
+#'
+#' sfm.dat: This is a monthly "data.frame" object from January 1978 to December
+#' 1987, with seventeen columns representing monthly returns of certain assets,
+#' as in Chapter 2 of Berndt (1991). sfm.apca.dat: This is a weekly
+#' "data.frame" object with dimension 182 x 1618, which runs from January 8,
+#' 1997 to June 28, 2000 and represents the stock returns on 1618 U.S. stocks.
+#'
+#' CITCRP monthly returns of Citicorp. CONED monthly returns of Consolidated
+#' Edison. CONTIL monthly returns of Continental Illinois. DATGEN monthly
+#' returns of Data General. DEC monthly returns of Digital Equipment Company.
+#' DELTA monthly returns of Delta Airlines. GENMIL monthly returns of General
+#' Mills. GERBER monthly returns of Gerber. IBM monthly returns of
+#' International Business Machines. MARKET a value-weighted composite monthly
+#' returns based on transactions from the New York Stock Exchange and the
+#' American Exchange. MOBIL monthly returns of Mobile. PANAM monthly returns
+#' of Pan American Airways. PSNH monthly returns of Public Service of New
+#' Hampshire. TANDY monthly returns of Tandy. TEXACO monthly returns of
+#' Texaco. WEYER monthly returns of Weyerhauser. RKFREE monthly returns on
+#' 30-day U.S. Treasury bills.
+#'
+#' @name stat.fm.data
+#' @aliases sfm.dat sfm.apca.dat
+#' @docType data
+#' @references Berndt, E. R. (1991). The Practice of Econometrics: Classic and
+#' Contemporary. Addison-Wesley Publishing Co.
+#' @source S+FinMetrics Berndt.dat & folio.dat
+#' @keywords datasets
+NULL
+
+
+
+
+
+#' constructed NYSE 447 assets from 1996-01-01 through 2003-12-31.
+#'
+#' constructed NYSE 447 assets from 1996-01-01 through 2003-12-31.
+#'
+#' Continuous data: PRICE, RETURN, VOLUME, SHARES.OUT, MARKET.EQUITY,LTDEBT,
+#' NET.SALES, COMMON.EQUITY, NET.INCOME, STOCKHOLDERS.EQUITY, LOG.MARKETCAP,
+#' LOG.PRICE, BOOK2MARKET Categorical data: GICS, GICS.INDUSTRY, GICS.SECTOR
+#' Identi
cation data: DATE, PERMNO, TICKER.x
+#'
+#' @name stock
+#' @docType data
+#' @references Guy Yullen and Yi-An Chen
+#' @keywords datasets
+NULL
+
+
+
Modified: pkg/FactorAnalytics/man/fitMacroeconomicFactorModel.Rd
===================================================================
--- pkg/FactorAnalytics/man/fitMacroeconomicFactorModel.Rd 2013-06-18 18:18:01 UTC (rev 2355)
+++ pkg/FactorAnalytics/man/fitMacroeconomicFactorModel.Rd 2013-06-18 18:52:55 UTC (rev 2356)
@@ -2,27 +2,25 @@
\alias{fitMacroeconomicFactorModel}
\title{Fit macroeconomic factor model by time series regression techniques.}
\usage{
- fitMacroeconomicFactorModel(ret.assets, factors,
- factor.set = 2, fit.method = c("OLS", "DLS", "Robust"),
+ fitMacroeconomicFactorModel(assets.names, factors.names,
+ data = data, factor.set = 3,
+ fit.method = c("OLS", "DLS", "Robust"),
variable.selection = c("stepwise", "all subsets", "lar", "lasso"),
decay.factor = 0.95, nvmax = 8, force.in = NULL,
subsets.method = c("exhaustive", "backward", "forward", "seqrep"),
lars.criteria = c("Cp", "cv"))
}
\arguments{
- \item{ret.assets}{N x T Numerical returns data,
- univariate or multivariate, where N is the number of
- assets return and T is the length of time period. data
- has to be saved as class "data.frame" so that lm function
- can be used and must have column names.}
+ \item{assets.names}{names of assets returns.}
- \item{factors}{K x T Numerical factors data, where K is
- the number of factors and T is the length of the time
- period. Data has to be saved as class "data.frame" so
- that lm function can be used and must have column names.}
+ \item{factors.names}{names of factors returns.}
\item{factor.set}{scalar, number of factors}
+ \item{data}{a vector, matrix, data.frame, xts, timeSeries
+ or zoo object with asset returns and factors retunrs
+ rownames}
+
\item{fit.method}{"OLS" is ordinary least squares method,
"DLS" is discounted least squares method. Discounted
least squares (DLS) estimation is weighted least squares
@@ -59,7 +57,16 @@
cross-validation. See detail.}
}
\value{
- an S3 object containing
+ an S3 object containing \item{asset.fit}{Fit objects for
+ each asset. This is the class "lm" for each object.}
+ \item{alpha.vec}{N x 1 Vector of estimated alphas.}
+ \item{beta.mat}{N x K Matrix of estimated betas.}
+ \item{r2.vec}{N x 1 Vector of R-square values.}
+ \item{residVars.vec}{N x 1 Vector of residual variances.}
+ \item{call}{function call.} \item{ret.assets}{Assets
+ returns of input data.} \item{factors Factors of input
+ data.} \item{variable.selection variables selected by the
+ user.}
}
\description{
Fit macroeconomic factor model by time series regression
@@ -72,6 +79,7 @@
p17.
}
\examples{
+\dontrun{
# load data from the database
data(managers.df)
ret.assets = managers.df[,(1:6)]
@@ -87,6 +95,7 @@
colnames(dataToPlot) = c("Fitted","Actual")
chart.TimeSeries(dataToPlot, main="FM fit for HAM1",
colorset=c("black","blue"), legend.loc="bottomleft")
+ }
}
\author{
Eric Zivot and Yi-An Chen.
More information about the Returnanalytics-commits
mailing list