osp.tvr: Tsitsiklis van Roy RMC algorithm with a variety of regression...

View source: R/ospProbDesign.R

osp.tvrR Documentation

Tsitsiklis van Roy RMC algorithm with a variety of regression methods

Description

RMC using TvR along a global set of paths. All designs are kept in memory

Usage

osp.tvr(N, model, subset = 1:N, method = "lm")

Arguments

N

the number of forward paths to train on

model

a list defining the simulator and reward model, with the two main model hooks being payoff.func (plus parameters) and sim.func (plus parameters).

Also x0 is a required part of the model. Can be either a vector of length model$dim or a vector of length model$dim*N

subset

To reserve out-of-sample paths, specify subset (eg 1:1000) to use for testing. By default everything is in-sample.

method

a string specifying regression method to use

  • spline: smooth.spline from base which only works in 1D

  • cvspline: smooth.spline from base with automatically chosen (via cross-validation) degrees of freedom/number of knots. Only works in 1D

  • randomforest: (from randomForest package) requires rf.maxnode and rf.ntree (number of trees) model parameters

  • loess: only works in 1D or 2D, requires lo.span model parameter

  • earth: multivariate regression splines (MARS) using earth package. requires earth.deg (interaction degree), earth.nk (max number of terms to keep), earth.thresh params

  • rvm: relevance vector machine from kernlab package. Optional rvm.kernel model parameter to decide which kernel family to utilize. Default kernel is rbfdot

  • deepnet: neural network using deepnet. Specify nn.layers as a vector to describe the number of nodes across hidden layers

  • lm [Default]: linear global regression using model$bases (required) basis functions (+ constant)

Details

Works with a probabilistic design that requires storing all paths in memory. Specifying subset allows to compute in parallel with the original computation an out-of-sample estimate of the value function

Calls model$payoff.func, so the latter must be set prior to calling. Also needs model$dt and model$r for discounting

Calls model$sim.func to generate forward paths

Emulator is trained on all paths, even those that are out-of-the-money

Value

a list containing

  • fit a list containing all the models generated at each time-step. fit[[1]] is the emulator at t=\Delta t, the last one is fit[[M-1]] which is emulator for T-\Delta t.

  • val: the in-sample pathwise rewards

  • test: the out-of-sample pathwise rewards

  • p: the final price (2-vector for in/out-of-sample)

  • timeElapsed (based on Sys.time)

Examples

set.seed(1)
require(earth)
model2d <- list(K=40,x0=rep(40,2),sigma=rep(0.2,2),r=0.06,div=0,
 T=1,dt=0.04,dim=2, sim.func=sim.gbm, payoff.func=put.payoff,pilot.nsims=1000,
 earth.deg=2,earth.nk=200,earth.thresh=1E-8)
tvrSolve <- osp.tvr(N=41000,model2d, subset=1:1000,method="earth")
# "in-sample v_0 1.224009; and out-of-sample: 1.233986"

mludkov/mlOSP documentation built on April 29, 2023, 7:56 p.m.