Description Usage Arguments Value Note See Also Examples
Simulation of a pdmpBorder object
Simulation of a pdmpBorder object
1 2 3 4 5 6 7 |
obj |
obj of class |
initialize |
boolean varialbe. If initialize = TRUE and |
seed |
an integer or NULL. This makes the result of |
outrate |
boolean variable. During simulation, the survival function is
simulated too, because it is needed to determine the next jump time.
Setting outrate = TRUE will return all simulated values including the
survival function |
nroot |
number of maximal possible jumps. The default value is 1e+06
and should be sufficient. If the simulation breaks before the end of
simulation time, try to set a higher value for |
outSlot |
boolean variable. If FALSE, only the result of the simulation
is returned. If TRUE, the whole |
... |
optional parameters passed to the solver function (e.g. hmax for lsoda). |
obj |
obj of class |
seed |
an integer or NULL. This makes the result of |
outSlot |
boolean variable. If FALSE, only the result of the simulation
is returned. If TRUE, the whole |
initialize |
boolean varialbe. If initialize = TRUE and |
outrate |
boolean variable. During simulation, the survival function is
simulated too, because it is needed to determine the next jump time.
Setting outrate = TRUE will return all simulated values including the
survival function |
nroot |
number of maximal possible jumps. The default value is 1e+06
and should be sufficient. If the simulation breaks before the end of
simulation time, try to set a higher value for |
... |
optional parameters passed to the solver function (e.g. hmax for lsoda). |
The returned value depends on the parameter outSlot
.
If outSlot = TRUE
, the function returns the complete pdmpBorder
instance with the simulation result saved in the out
slot.
Otherwise, only the simulation result is returned.
The returned value depends on the parameter outSlot
.
If outSlot = TRUE
, the function returns the complete pdmpBorder
instance with the simulation result saved in the out
slot.
Otherwise, only the simulation result is returned.
If the result is stored in slot out
, it can get lost if the
value of the other slots is changed via <-.
See pdmpBorder-accessors
for further informations.
If the result is stored in slot out
, it can get lost if the
value of the other slots is changed via <-.
See pdmpBorder-accessors
for further informations.
function multSim
or multSimCsv
for multiple simulations, ... for plot and summary methods of the simulation.
function multSim
or multSimCsv
for multiple simulations, ... for plot and summary methods of the simulation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | data("simplePdmp") # load object of class pdmpModel
#### simulations
# simulate and plot the result
plot(sim(simplePdmp, seed = 1))
# simulate and plot the result with random seed
plot(sim(simplePdmp, seed = NULL))
# simulating again with seed = 1 leads to the same result as before
plot(sim(simplePdmp, seed = 1))
#### be careful about slot out!
out(simplePdmp) # NULL, because results have not been stored
simplePdmp <- sim(simplePdmp) # simulation results are stored in out
head(out(simplePdmp))
init(simplePdmp) <- c(f = 5, d = 1)
head(out(simplePdmp)) # NULL, because slot init has changed
simplePdmp <- sim(simplePdmp, outSlot = FALSE)
str(simplePdmp) # only the simulation result, the pdmpModel object is lost
### an example with initialize = TRUE
initModel <- pdmpModel(
descr = "a model with random initial values",
init = c(f = 0, d = 1),
discStates = list(d = c(-1, 1)),
initfunc = function(pdmp){
set.seed(NULL) # necessary to be not affected by parameter 'seed'
init(pdmp) <- c("f" = runif(1, min = 1, max = 100), "d" = 1)
invisible(pdmp)
},
times = c(from = 0, to = 10, by = 0.01),
dynfunc = function(t, x, parms) c(x["d"]*t, 0),
ratefunc = function(t, x, parms) 1,
jumpfunc = function(t, x, parms, jtype) c(-x["f"], (-1)*x["d"])
)
print(init(initModel))
print(head(out(sim(initModel, seed = 2, initialize = TRUE))))
print(head(out(sim(initModel, seed = 5, initialize = TRUE))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.