randport.eval {PortfolioProbe} | R Documentation

## Evaluate Each Random Portfolio

### Description

Takes a random portfolio object and evaluates each individual portfolio. Any set of components of the output of `trade.optimizer` can be saved.

### Usage

    randport.eval(x, keep = c("results", "alpha.values", "var.values",
    	"utility.values"), subset = NULL, do.warn = FALSE,
    	additional.args = NULL, checkinput = TRUE,
    	envir = parent.frame(), FUN = NULL, ...)

### Arguments

`x` | required. An object that is the result of a call to `random.portfolio` or `random.portfolio.utility`.
`keep` | character vector of component names of the output of `trade.optimizer`. If this is `NULL`, then the slightly ironic result is that all components are kept. Values are allowed to partially match the names of optimization object components.
`subset` | either `NULL` or a vector to subscript along the components of `x`.
`do.warn` | the control for the warnings coming from `trade.optimizer`. The default is `FALSE`, meaning all warnings are turned off that can be turned off. The two other likely values are: `TRUE` (turn on all warnings), and `NULL` (use the `do.warn` value that was in effect to start with). (A value of `NULL` here is not necessarily the same as `NULL` in `trade.optimizer`.) This can be any value that the `do.warn` argument to `trade.optimizer` will accept.
`additional.args` | list of arguments to `trade.optimizer` either not in the `random.portfolio` call or that should be changed. In the latter case, argument names need to be given exactly the same as in the original – that is, with the same amount of abbreviation.
`checkinput` | a logical value. If `TRUE`, then a (fallible) check is made to see if there is a change in the value of `price`, `variance`, `expected.return` or `existing` between the current computation and the original computation. There is no warning about arguments that are in `additional.args`.
`envir` | the environment where the objects used to generate the random portfolios are going to be found. This is nonsensical to S+.
`FUN` | a function or a character string naming a function. Each portfolio trade object will be passed to the function.
`...` | additional arguments given to `FUN`.

### Value

a list as long as `x` (or by what is indicated by `subset` if given).

If `FUN` is not given, each component is a list containing the components of the output of `trade.optimizer` listed in `keep`.

If `FUN` is given, then each component is the result of `FUN` applied to the portfolio trade object for the component.

### Details

The objects that are involved (like prices and variances) need to be available in the current session, and presumably should be unchanged.

If you get a warning about a "checkinput difference" for one or more arguments, then you probably want to add those arguments to `additional.args`. Problems like this can arise because the arguments for the original computation were dependent on the iteration in a loop. Outside that original loop the value may be interpreted differently (or cause an error).

If neither expected returns nor variance are given (and a distance utility is not specified), then the utility is set to zero by maximizing expected returns that are all zero.

### Bugs

There are limited circumstances when the `utility.values` component is confused (equal to zero) if `expected.return` can not be found and `utility` is not specified.

### Revision

This help was last revised 2013 April 19.

### See Also

`random.portfolio`, `trade.optimizer`, `random.portfolio.utility`.

### Examples

    randport1 <- random.portfolio(100, prices, variance=varian,
    	long.only=TRUE, bench.constr=c(spx=.04^2/252),
    	lin.constraints=cntrysect.conmat,
    	lin.bounds=cntrysect.bounds, gross.value=1e6)

    randeval1 <- randport.eval(randport1)

    # look at linear constraints of the random portfolios
    randlincon1 <- randport.eval(randport1, keep="con.realized")

    # returns the above plus more
    randsummary <- randport.eval(randport1, FUN=summary)

    # vector of weight differences
    rdist <- unlist(randport.eval(randport1, FUN = function(x)
        trade.distance(x, some.portf, prices=privec, scale="weight")))

[Package PortfolioProbe version 1.06 Index]