| simulate.formula {lme4} | R Documentation |
A simulate Method for formula objects that dispatches based on the Left-Hand Side
Description
This method evaluates the left-hand side (LHS) of the given formula and dispatches it to an appropriate method based on the result by setting an nonce class name on the formula.
Usage
## S3 method for class 'formula'
simulate(object, nsim = 1 , seed = NULL, ...,
basis, newdata, data)
Arguments
object |
a one- or two-sided |
nsim, seed |
number of realisations to simulate and the random
seed to use; see |
... |
additional arguments to methods |
basis |
if given, overrides the LHS of the formula for the purposes of dispatching |
newdata, data |
if passed, the |
Details
The dispatching works as follows:
If
basisis not passed, and the formula has an LHS the expression on the LHS of the formula in theobjectis evaluated in the environmentnewdataordata(if given), in any case enclosed by the environment ofobject. Otherwise,basisis used.The result is set as an attribute
".Basis"onobject. If there is nobasisor LHS, it is not set.The class vector of
objecthasc("formula_lhs_CLASS", "formula_lhs")prepended to it, where CLASS is the class of the LHS value orbasis. If LHS orbasishas multiple classes, they are all prepended; if there is no LHS orbasis,c("formula_lhs_", "formula_lhs")is.-
simulategeneric is evaluated on the newobject, with all arguments passed on, excludingbasis; ifnewdataordataare missing, they too are not passed on. The evaluation takes place in the parent's environment.
A "method" to receive a formula whose LHS evaluates to CLASS
can therefore be implemented by a function
simulate.formula_lhs_CLASS(). This function can expect a
formula object, with additional attribute .Basis giving the
evaluated LHS (so that it does not need to be evaluated again).