# NOT RUN {
set.seed(1, kind = "Mersenne-Twister", normal.kind = "Inversion")
# a Brownian motion model with one regime
modelOU <- PCM(model = PCMDefaultModelTypes()['F'], k = 2)
# assign the model parameters at random: this will use uniform distribution
# with boundaries specified by PCMParamLowerLimit and PCMParamUpperLimit
# We do this in two steps:
# 1. First we generate a random vector. Note the length of the vector equals
# PCMParamCount(modelBM).
randomParams <- PCMParamRandomVecParams(
modelOU, PCMNumTraits(modelOU), PCMNumRegimes(modelOU))
# 2. Then we load this random vector into the model.
PCMParamLoadOrStore(
modelOU,
randomParams,
0, PCMNumTraits(modelBM), PCMNumRegimes(modelBM), load = TRUE)
# let's plot the trajectory of the model starting from X0 = c(0,0)
PCMTrajectory(
model = modelOU,
X0 = c(0, 0),
doPlot2D = TRUE)
# A faceted grid of plots for the two regimes in a mixed model:
pla <- PCMTrajectory(
model = PCMBaseTestObjects$model_MixedGaussian_ab, regime = "a",
X0 = c(0, 0, 0),
doPlot2D = TRUE) +
ggplot2::scale_y_continuous(limits = c(0, 10)) +
ggplot2::facet_grid(.~regime)
plb <- PCMTrajectory(
model = PCMBaseTestObjects$model_MixedGaussian_ab, regime = "b",
X0 = c(0, 0, 0),
doPlot2D = TRUE) +
ggplot2::scale_y_continuous(limits = c(0, 10)) +
ggplot2::facet_grid(.~regime) +
ggplot2::theme(
axis.title.y = ggplot2::element_blank(),
axis.text.y = ggplot2::element_blank(),
axis.ticks.y = ggplot2::element_blank())
cowplot::plot_grid(pla, plb)
# }
Run the code above in your browser using DataLab