View source: R/ospProbDesign.R
osp.tvr | R Documentation |
RMC using TvR along a global set of paths. All designs are kept in memory
osp.tvr(N, model, subset = 1:N, method = "lm")
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
Also |
subset |
To reserve out-of-sample paths, specify |
method |
a string specifying regression method to use
|
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
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
)
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"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.