Description Usage Arguments Details Value Author(s) See Also Examples
This function generates m random general portfolios with n investments each that can have k positive or negative. The probability that a given investment weight is positive is p. The maximum absolute exposure is x.u which has 1 as the default The function is used to evaluate the performance of the portfolio generation algorithm.
1 | rgeneral.test(m, n = 2, k = n, segments = NULL, p = 0.5, x.u = 1)
|
m |
A positive integer value for the number of portfolios |
n |
A positive integer value for the number of investments in the portfolio |
k |
A positive integer value for the number of non-zero long and short positions |
segments |
A vector or list of vectors that defines the portfolio segments |
p |
A positive numeric value for the probability that a position is positive |
x.u |
A positive numeric value for the maximum absolute exposure to an investment |
The function executes the function random.general.test
using the R function
lapply
. The result which is a list contains the investment weight vectors and number
of iterations. Thse data are stored in a matrix of investment weights and a vector
of iterations. These arrays are returned as a list.
A list with two named components.
xmatrix |
An m \times n numerical matrix of investment weights |
iters |
An m \times 1 integer vector for the number of iterations used to obtain the investment weights |
Frederick Novomestky fn334@nyu.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ###
### 100 long only portfolios of 30 investments
###
x.long <- rgeneral.test( 100, 30, p=1.0 )
y.long <- rgeneral.test( 100, 30, 10, p=1.0 )
###
### 100 short only portfolios of 30 investments
###
x.short <- rgeneral.test( 100, 30, p=0.0 )
y.short <- rgeneral.test( 100, 30, 10, p=0.0 )
###
### 100 long short portfolios of 30 investments
###
x.long.short <- rgeneral.test( 100, 30, p=0.5 )
y.long.short <- rgeneral.test( 100, 30, 10, p=0.5 )
###
### 100 long bias portfolios of 30 investments
###
x.long.bias <- rgeneral.test( 100, 30, p=0.7 )
y.long.bias <- rgeneral.test( 100, 30, 10, p=0.7 )
###
### 100 short bias portfolios of 30 investments
###
x.short.bias <- rgeneral.test( 100, 30, p=0.3 )
y.short.bias <- rgeneral.test( 100, 30, 10, p=0.3 )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.