inst/doc/intro.R

## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  echo = TRUE,
  warning = FALSE,
  collapse = TRUE,
  comment = "#>"
)

## ----results = 'hide', message = FALSE----------------------------------------
library(MCSimMod)

## ----results = 'hide'---------------------------------------------------------
mod_string <- "
States = {y};
y0 = 2;
m = 0.5;
Initialize {
    y = y0;
}
Dynamics {
    dt(y) = m;
}
End.
"

## ----results = 'hide'---------------------------------------------------------
model <- createModel(mString = mod_string)

## ----results = 'hide', message = FALSE----------------------------------------
model$loadModel()

## ----results = 'hide', message = FALSE----------------------------------------
times <- seq(from = 0, to = 20, by = 0.1)
out <- model$runModel(times)

## ----echo = FALSE, results = 'asis'-------------------------------------------
library(knitr)
kable(out[1:5, ])

## -----------------------------------------------------------------------------
model$parms
model$Y0

## ----fig.dim = c(6, 4), fig.align = 'center'----------------------------------
# Plot simulation results.
plot(out[, "time"], out[, "y"],
  type = "l", lty = 1, lwd = 2, xlab = "Time",
  ylab = "y"
)

Try the MCSimMod package in your browser

Any scripts or data that you put into this service are public.

MCSimMod documentation built on Aug. 21, 2025, 5:54 p.m.