Learn R Programming

rportfolios (version 1.0-1)

random.shortonly.test: Random short only portfolio

Description

This function generates a vector of investment weights for a portfolio where the weights are non-positive, absolute weights do not exceed a given upper and and the sum of the absolute weights is a given total. The number of non zero positions in the portfolio is k. The function is used to evaluate the performance of the portfolio generation algorithm.

Usage

random.shortonly.test(n = 2, k = n, segments = NULL, x.t = 1, x.l = 0, x.u = x.t, max.iter = 1000)

Arguments

n
An integer value for the number of investments in the portfolio
k
An integer value for the number of non zero weights
segments
A vector or list of vectors that defines the portfolio segments
x.t
Numeric value for the sum of the absolute value of the investment weights
x.l
Numeric value for the lower bound on the absolute value of an investment weight
x.u
Numeric value for the upper bound on the absolute value of an investment weight
max.iter
An integer value for the maximum iteration in the acceptance rejection loop

Value

A list with two named components

Details

The function uses random.longonly.test to generate a long only portfolio in test mode. The component x compute is used to define the short portfolio. The short portfolio together with the component iter, the number of iterations used to construct the long only portfolio, are stored in a list of named components.

See Also

random.shortonly

Examples

Run this code
###
### generate a short only portfolio of 30 investments with 30 non-zero positions
###
x.result <- random.shortonly.test( 30 )
###
### generate a short only portfolio of 30 investments with 10 non-zero positions
###
y.result <- random.shortonly.test( 30, 10 )

Run the code above in your browser using DataLab