View source: R/simulate_nlme.R
simulate_nlme | R Documentation |
Simulate multiple samples from a nonlinear model
simulate_nlme(
object,
nsim = 1,
psim = 1,
value = c("matrix", "data.frame"),
data = NULL,
...
)
object |
object of class |
nsim |
number of samples, default 1 |
psim |
simulation level for fixed and random parameters see |
value |
whether to return a matrix (default) or an augmented data frame |
data |
the data argument is needed when using this function inside user defined functions. |
... |
additional arguments to be passed to either |
The details can be found in either simulate_gnls
or simulate_nlme_one
.
This function is very simple and it only sets up a matrix and a loop in order to simulate several instances of
model outputs.
It returns a matrix with simulated values from the original object
with number of rows equal to the number of rows of fitted
and number
of columns equal to the number of simulated samples (‘nsim’). In the case of ‘data.frame’
it returns an augmented data.frame, which can potentially be a very large object, but which
makes furhter plotting more convenient.
require(nlme)
data(barley, package = "nlraa")
barley2 <- subset(barley, year < 1974)
fit.lp.gnls2 <- gnls(yield ~ SSlinp(NF, a, b, xs), data = barley2)
barley2$year.f <- as.factor(barley2$year)
cfs <- coef(fit.lp.gnls2)
fit.lp.gnls3 <- update(fit.lp.gnls2,
params = list(a + b + xs ~ year.f),
start = c(cfs[1], 0, 0, 0,
cfs[2], 0, 0, 0,
cfs[3], 0, 0, 0))
sims <- simulate_nlme(fit.lp.gnls3, nsim = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.