simulate_nlme {nlraa} | R Documentation |
Simulate samples from a nonlinear mixed model from fixed effects
Description
Simulate multiple samples from a nonlinear model
Usage
simulate_nlme(
object,
nsim = 1,
psim = 1,
value = c("matrix", "data.frame"),
data = NULL,
...
)
Arguments
object |
|
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 |
Details
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.
Value
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.
Examples
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)