View source: R/ospProbDesign.R
osp.prob.design | R Documentation |
RMC using probabilistic design: backpropagation along fixed set of paths (a la Longstaff-Schwartz).
All designs are kept in memory. By default produces only an in-sample estimate. Use in conjuction
with forward.sim.policy
to generate out-of-sample price estimates.
osp.prob.design(N, model, subset = 1:N, method = "lm")
N |
is the number of paths |
model |
defines the simulator and reward model, with the two main model hooks being.
Initial condition is |
subset |
To have 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
, model$T
for simulation and model$r
for discounting
Calls model$sim.func
to generate forward paths
Emulator is trained only on paths where payoffs are strictly positive
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
total running time in seconds, based on Sys.time
set.seed(1)
model2d <- list(look.ahead=1,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)
bas22 <- function(x) return(cbind(x[,1],x[,1]^2,x[,2],x[,2]^2,x[,1]*x[,2]))
model2d$bases <- bas22
prob.lm <- osp.prob.design(30000,model2d,method="lm",subset=1:15000)
prob.lm$p
# yields [1] 1.440918 1.482422
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.