Apologies if this is not the appropriate place to post this - this my very first contribution to Quantitative Finance Stack Exchange. I was hoping someone could help me with the following issue. I am using yuima
to model a 3-dimensional diffusion process:
model <- setModel(drift = c("((-1)/(2-x1))-1/2","0","0"),
diffusion = matrix(c("1","0","0","0","1","0","0","0","1"), 3, 3),
solve.variable = c("x1","x2","x3"))
and then to simulate it and plot it:
sampling <- setSampling(Initial = 0, Terminal = 10, n = 1000)
yuima <- setYuima(model = model, sampling = sampling)
simulation <- simulate(yuima,xinit = 1)
plot(simulation)
which seems to work. However: this generates a plot of each time-series x1
, x2
, and x3
over time when in reality what I am really trying to visualise is how the three-dimensional path (with polar coordinates x1
, x2
, and x3
) would look like.
Unless there is a version of plot3D
or similar in yuima
(I have googled it with no luck), what would really help me would be if there was a way of converting the (three) time-series simulation
into a matrix or a list, in which case I am pretty sure I would be able to get the desired plot.
Any help will be much appreaciated. All the best.
Edit: the answer I've selected solved my issue, but for future reference these are the contents of simulate
:
> print(str(simulate))
Formal class 'standardGeneric' [package "methods"] with 8 slots
..@ .Data :function (object, nsim = 1, seed = NULL, xinit, true.parameter, space.discretized = FALSE, increment.W = NULL, increment.L = NULL,
method = "euler", hurst, methodfGn = "WoodChan", sampling = sampling, subsampling = subsampling, ...)
..@ generic : chr "simulate"
.. ..- attr(*, "package")= chr "yuima"
..@ package : chr "yuima"
..@ group : list()
..@ valueClass: chr(0)
..@ signature : chr [1:13] "object" "nsim" "seed" "xinit" ...
..@ default : NULL
..@ skeleton : language (function (object, nsim = 1, seed = NULL, xinit, true.parameter, space.discretized = FALSE, increment.W = NULL, i| __truncated__ ...
NULL
simulation
object is an S4 class containing attributes/fields/slots. In order to get the slots from thesimulation
object you writestr(simulation)
. You will observe thatsimulation
is a class called yuima.data and contains an attribute calleddata
. Within this attribute, you can observe another attribute calledzoo.data
that contains a list of three time-series objects called "Series 1", "Series 2", "Series 3". I guessed this was the output data, since the only other data the class contained, was the original data. Also, you can access attributes via@
. $\endgroup$