set.segments: Set segment weights from portfolios

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function assigns the given investment weights to larget portfolios using the investment indices in the segments

Usage

1
set.segments(portfolios, n, segments)

Arguments

portfolios

A vector or matrix of investment weights for the segments

n

A positive integer value for the number of investments in the larger portfolio

segments

A vector or list of vectors that defines the segment investments

Details

A private function vector.set.segments is used to take weights in a given portfolio vector and assign them to a larger vector using the collapsed investment index vector. If the portfolios argument is a matrix, then the R function apply is used to perform this task for each row vector.

Value

A vector or matrix.

Author(s)

Frederick Novomestky fn334@nyu.edu

See Also

collapse.segments

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
###
### simulate 300 long only portfolios with 30 investments
###
portfolios <- rlongonly( 300, 30 )
###
### define six segments with five investments in each
###
segment1 <- 1:5
segment2 <- 11:15
segment3 <- 21:25
segment4 <- 31:35
segment5 <- 41:45
segment6 <- 51:55
segments <- list( segment1, segment2, segment3, segment4, segment5, segment6 )
newPortfolios <- set.segments( portfolios, 60, segments )

Example output

Loading required package: truncdist
Loading required package: stats4
Loading required package: evd

rportfolios documentation built on May 2, 2019, 3:40 p.m.