The function fgport is used to create functionally generated portfolio objects.
Usage
fgp(name, gen.function, weight.function)
Arguments
name
a string which is the name of the portfolio (e.g. "Equal-weighted portfolio"")
gen.function
the generating function. It is a smooth function of the market weights (see Theorem 3.1.5 of Fernholz (2002)).
weight.function
the weight function of the portfolio. It must be related to gen.function via (3.1.7) of Fernholz (2002).
Details
The function fgp is used to create functionally generated portfolio objects. Detailed treatments of functionally generated portfolios can be found in Chapter 3 of Fernholz (2002) as well as Pal and Wong (2014). In brief, a functionally generated portfolio is determined by a generating function (gen.function) and the weight function (weight.function).
Some common functionally generated portfolios are provided in the package. For example, EntropyPortfolio is the entropy-weighted, DiversityPortfolio is a constructs fgp objects for the diversity-weigthed portfolio, and ConstantPortfolio defines constant-weighted portfolios.
The most important operation concerning fgp objects is Fernholz's decomposition. See FernholzDecomp for more details.
Value
name
a character string, representing the name of the portfolio
gen.funtion
a function object, representating the generating function
weight.function
a function object, representing the weight function
References
Fernholz, E. R. (2002) Stochastic portfolio theory. Springer.
Pal, S. and T.-K. L. Wong (2014). The geometry of relative arbitrage. arXiv preprint arXiv:1402.3720.
See Also
FernholzDecomp
Examples
# Example 1: The diversity-weighted portfolio with p = 0.5
# This has the same effect has DiversityPortfolio(p = 0.5)
my.portfolio <- fgp("Diversity-Weighted Portfolio, p = 0.5",
function(x) (sum(sqrt(x)))^2,
function(x) sqrt(x) / sum(sqrt(x)))
# Example 2: A quadratic Gini coefficient
# See Example 3.4.7 of Fernholz (2002)
# Generating function
gen.function <- function(x) {
n <- length(x)
return(1 - sum((x - 1/n)^2)/2)
}
# Weight function
weight.function <- function(x) {
n <- length(x)
S <- gen.function(x)
return(((1/n - x)/S + 1 - sum(x*(1/n - x)/S))*x)
}
# Define fgp object
my.portfolio <- fgp("Quadratic Gini",
gen.function, weight.function)
# Its performance in the apple-starbucks market
data(applestarbucks)
market <- toymkt(applestarbucks)
result <- FernholzDecomp(market, my.portfolio, plot = TRUE)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(RelValAnalysis)
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RelValAnalysis/fgp.Rd_%03d_medium.png", width=480, height=480)
> ### Name: fgp
> ### Title: Functionally Generated Portfolio Objects
> ### Aliases: fgp
>
> ### ** Examples
>
> # Example 1: The diversity-weighted portfolio with p = 0.5
> # This has the same effect has DiversityPortfolio(p = 0.5)
> my.portfolio <- fgp("Diversity-Weighted Portfolio, p = 0.5",
+ function(x) (sum(sqrt(x)))^2,
+ function(x) sqrt(x) / sum(sqrt(x)))
>
>
> # Example 2: A quadratic Gini coefficient
> # See Example 3.4.7 of Fernholz (2002)
>
> # Generating function
> gen.function <- function(x) {
+ n <- length(x)
+ return(1 - sum((x - 1/n)^2)/2)
+ }
>
> # Weight function
> weight.function <- function(x) {
+ n <- length(x)
+ S <- gen.function(x)
+ return(((1/n - x)/S + 1 - sum(x*(1/n - x)/S))*x)
+ }
>
> # Define fgp object
> my.portfolio <- fgp("Quadratic Gini",
+ gen.function, weight.function)
>
> # Its performance in the apple-starbucks market
> data(applestarbucks)
> market <- toymkt(applestarbucks)
Warning message:
In toymkt(applestarbucks) :
Since initial.weight is not given, the benchmark is assumed to be equal-weighted initially.
> result <- FernholzDecomp(market, my.portfolio, plot = TRUE)
>
>
>
>
>
>
> dev.off()
null device
1
>