Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

simulate.formula

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)

## S3 method for class 'formula_lhs'
simulate(object, nsim = 1, seed = NULL, ...)

Arguments

object

a one- or two-sided formula.

nsim, seed

number of realisations to simulate and the random seed to use; see simulate().

...

additional arguments to methods.

basis

if given, overrides the LHS of the formula for the purposes of dispatching.

newdata, data

if passed, the object's LHS is evaluated in this environment; at most one of the two may be passed.

The dispatching works as follows:

  1. If basis is not passed, and the formula has an LHS the expression on the LHS of the formula in the object is evaluated in the environment newdata or data (if given), in any case enclosed by the environment of object. Otherwise, basis is used.

  2. The result is set as an attribute ".Basis" on object. If there is no basis or LHS, it is not set.

  3. The class vector of object has c("formula_lhs_CLASS", "formula_lhs") prepended to it, where CLASS is the class of the LHS value or basis. If LHS or basis has multiple classes, they are all prepended; if there is no LHS or basis, c("formula_lhs_", "formula_lhs") is.

  4. simulate() generic is evaluated on the new object, with all arguments passed on, excluding basis; if newdata or data are 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_\var{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).

Functions

  • simulate.formula_lhs: A function to catch the situation when there is no method implemented for the class to which the LHS evaluates.

See Also

simulate.ergm() family of functions, which uses this interface.


ergm

Fit, Simulate and Diagnose Exponential-Family Models for Networks

v3.11.0
GPL-3 + file LICENSE
Authors
Mark S. Handcock [aut], David R. Hunter [aut], Carter T. Butts [aut], Steven M. Goodreau [aut], Pavel N. Krivitsky [aut, cre] (<https://orcid.org/0000-0002-9101-3362>), Martina Morris [aut], Li Wang [ctb], Kirk Li [ctb], Skye Bender-deMoll [ctb], Chad Klumb [ctb], Michał Bojanowski [ctb], Ben Bolker [ctb]
Initial release
2020-10-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.