diff --git a/R/riskDecomp.R b/R/riskDecomp.R index 62cc9815..65ad887f 100644 --- a/R/riskDecomp.R +++ b/R/riskDecomp.R @@ -78,12 +78,17 @@ #' wtsStocks145GmvLo = round(wtsStocks145GmvLo,5) #' #' # fit a fundamental factor model +#' exposure.vars = c("SECTOR","ROE","BP","PM12M1M","SIZE", "ANNVOL1M", "EP") #' fit.cross <- fitFfm(data = dat, -#' exposure.vars = c("SECTOR","ROE","BP","MOM121","SIZE","VOL121", -#' "EP"),date.var = "DATE", ret.var = "RETURN", asset.var = "TICKER", -#' fit.method="WLS", z.score = "crossSection") +#' exposure.vars = exposure.vars, +#' date.var = "DATE", +#' ret.var = "RETURN", +#' asset.var = "TICKER", +#' fit.method="WLS", +#' z.score = "crossSection") #' #' decompES = riskDecomp(fit.cross, risk = "ES") +#' #' #get the factor contributions of risk #' portES.decomp = riskDecomp(fit.cross, weights = wtsStocks145GmvLo, risk = "ES", portDecomp = TRUE) #' @export diff --git a/R/summary.pafm.r b/R/summary.pafm.r index 4b576a72..6a9c9d77 100644 --- a/R/summary.pafm.r +++ b/R/summary.pafm.r @@ -12,10 +12,11 @@ #' @examples #' # load data from the database #' data(managers, package = 'PerformanceAnalytics') +#' #' # fit the factor model with LS -#' fit.ts <- fitTsfm(asset.names=colnames(managers[,(1:6)]), -#' factor.names=c("EDHEC.LS.EQ","SP500.TR"), -#' data=managers) +#' fit.ts <- fitTsfm(asset.names = colnames(managers[,(1:6)]), +#' factor.names = c("EDHEC LS EQ","SP500 TR"), +#' data = managers) #' #' fm.attr <- paFm(fit.ts) #' summary(fm.attr) diff --git a/R/summary.tsfm.r b/R/summary.tsfm.r index 1c716d46..1124efcb 100644 --- a/R/summary.tsfm.r +++ b/R/summary.tsfm.r @@ -45,10 +45,6 @@ #' @examples #' # load data #' data(managers, package = 'PerformanceAnalytics') -#' colnames(managers) -#' # Make syntactically valid column names -#' colnames(managers) <- make.names( colnames(managers)) -#' colnames(managers) #' #' fit <- fitTsfm(asset.names=colnames(managers[,(1:6)]), #' factor.names=colnames(managers[,7:9]), diff --git a/R/summary.tsfmUpDn.r b/R/summary.tsfmUpDn.r index 57caa8b5..695790e7 100644 --- a/R/summary.tsfmUpDn.r +++ b/R/summary.tsfmUpDn.r @@ -34,16 +34,12 @@ #' @examples #' # load data #' data(managers, package = 'PerformanceAnalytics') -#' colnames(managers) -#' # Make syntactically valid column names -#' colnames(managers) <- make.names( colnames(managers)) -#' colnames(managers) #' #' # example: Up and down market factor model with LS fit -#' fitUpDn <- fitTsfmUpDn(asset.names=colnames(managers[,(1:6)]), -#' mkt.name="SP500.TR", -#' data=managers, -#' fit.method="LS") +#' fitUpDn <- fitTsfmUpDn(asset.names = colnames(managers[,(1:6)]), +#' mkt.name = "SP500 TR", +#' data = managers, +#' fit.method = "LS") #' #' summary(fitUpDn) #' diff --git a/man/riskDecomp.Rd b/man/riskDecomp.Rd index 67a8bc38..2c5ee0e6 100644 --- a/man/riskDecomp.Rd +++ b/man/riskDecomp.Rd @@ -108,12 +108,17 @@ data("wtsStocks145GmvLo") wtsStocks145GmvLo = round(wtsStocks145GmvLo,5) # fit a fundamental factor model +exposure.vars = c("SECTOR","ROE","BP","PM12M1M","SIZE", "ANNVOL1M", "EP") fit.cross <- fitFfm(data = dat, - exposure.vars = c("SECTOR","ROE","BP","MOM121","SIZE","VOL121", - "EP"),date.var = "DATE", ret.var = "RETURN", asset.var = "TICKER", - fit.method="WLS", z.score = "crossSection") + exposure.vars = exposure.vars, + date.var = "DATE", + ret.var = "RETURN", + asset.var = "TICKER", + fit.method="WLS", + z.score = "crossSection") decompES = riskDecomp(fit.cross, risk = "ES") + #get the factor contributions of risk portES.decomp = riskDecomp(fit.cross, weights = wtsStocks145GmvLo, risk = "ES", portDecomp = TRUE) } diff --git a/man/summary.pafm.Rd b/man/summary.pafm.Rd index b8099650..b6c5c566 100644 --- a/man/summary.pafm.Rd +++ b/man/summary.pafm.Rd @@ -20,10 +20,11 @@ Generic function of summary method for \code{paFm}. \examples{ # load data from the database data(managers, package = 'PerformanceAnalytics') + # fit the factor model with LS -fit.ts <- fitTsfm(asset.names=colnames(managers[,(1:6)]), - factor.names=c("EDHEC.LS.EQ","SP500.TR"), - data=managers) +fit.ts <- fitTsfm(asset.names = colnames(managers[,(1:6)]), + factor.names = c("EDHEC LS EQ","SP500 TR"), + data = managers) fm.attr <- paFm(fit.ts) summary(fm.attr) diff --git a/man/summary.tsfm.Rd b/man/summary.tsfm.Rd index 906c4abd..42ae4d6b 100644 --- a/man/summary.tsfm.Rd +++ b/man/summary.tsfm.Rd @@ -59,10 +59,6 @@ predictions. \examples{ # load data data(managers, package = 'PerformanceAnalytics') -colnames(managers) - # Make syntactically valid column names -colnames(managers) <- make.names( colnames(managers)) -colnames(managers) fit <- fitTsfm(asset.names=colnames(managers[,(1:6)]), factor.names=colnames(managers[,7:9]), diff --git a/man/summary.tsfmUpDn.Rd b/man/summary.tsfmUpDn.Rd index 025e28ce..54d695da 100644 --- a/man/summary.tsfmUpDn.Rd +++ b/man/summary.tsfmUpDn.Rd @@ -45,16 +45,12 @@ objects and combines the coefficients interested together. \examples{ # load data data(managers, package = 'PerformanceAnalytics') -colnames(managers) - # Make syntactically valid column names -colnames(managers) <- make.names( colnames(managers)) -colnames(managers) # example: Up and down market factor model with LS fit -fitUpDn <- fitTsfmUpDn(asset.names=colnames(managers[,(1:6)]), - mkt.name="SP500.TR", - data=managers, - fit.method="LS") +fitUpDn <- fitTsfmUpDn(asset.names = colnames(managers[,(1:6)]), + mkt.name = "SP500 TR", + data = managers, + fit.method = "LS") summary(fitUpDn)