# entropy_pooling: Numerical Entropy Minimization In ffp: Fully Flexible Probabilities for Stress Testing and Portfolio Construction

 entropy_pooling R Documentation

## Numerical Entropy Minimization

### Description

This function solves the entropy minimization problem with equality and inequality constraints. The solution is a vector of posterior probabilities that distorts the least the prior (equal-weights probabilities) given the constraints (views on the market).

### Usage

```entropy_pooling(
p,
A = NULL,
b = NULL,
Aeq = NULL,
beq = NULL,
solver = c("nlminb", "solnl", "nloptr"),
...
)
```

### Arguments

 `p` A vector of prior probabilities. `A` The linear inequality constraint (left-hand side). `b` The linear inequality constraint (right-hand side). `Aeq` The linear equality constraint (left-hand side). `beq` The linear equality constraint (right-hand side). `solver` A `character`. One of: "nlminb", "solnl" or "nloptr". `...` Further arguments passed to one of the solvers.

### Details

When imposing views constraints there is no need to specify the non-negativity constraint for probabilities, which is done automatically by `entropy_pooling`.

For the arguments accepted in `...`, please see the documentation of `nlminb`, `solnl`, `nloptr` and the examples bellow.

### Value

A vector of posterior probabilities.

### Examples

```# setup
ret <- diff(log(EuStockMarkets))
n   <- nrow(ret)

# View on expected returns (here is 2% for each asset)
mean <- rep(0.02, 4)

# Prior probabilities (usually equal weight scheme)
prior <- rep(1 / n, n)

# View
views <- view_on_mean(x = ret, mean = mean)

# Optimization
ep <- entropy_pooling(
p      = prior,
Aeq    = views\$Aeq,
beq    = views\$beq,
solver = "nlminb"
)
ep

### Using the ... argument to control the optimization parameters

# nlminb
ep <- entropy_pooling(
p      = prior,
Aeq    = views\$Aeq,
beq    = views\$beq,
solver = "nlminb",
control = list(
eval.max = 1000,
iter.max = 1000,
trace    = TRUE
)
)
ep

# nloptr
ep <- entropy_pooling(
p      = prior,
Aeq    = views\$Aeq,
beq    = views\$beq,
solver = "nloptr",
control = list(
xtol_rel = 1e-10,
maxeval  = 1000,
check_derivatives = TRUE
)
)
ep
```

ffp documentation built on Sept. 29, 2022, 5:10 p.m.