Description Usage Arguments Value Examples
All functions permit fully-customised types of variable to be defined.
Functions other than type_custom
already include standard default values
which make the definition of standard variable types easier and quicker.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | type_custom(
type = "custom",
init = c(0, 10),
randomXj = function(n, v) { rnorm(n, v[1], v[2]) },
x2v = function(x) { c(mean(x), sd(x)) },
v2x = function(v) { v[1] },
smooth = list(quote(smooth_lin(x, xt, 1)), quote(smooth_dec(x, xt, 0.9, 10))),
...
)
type_real(...)
type_positive(...)
type_negative(...)
|
type |
label for identifying the type of variable. The name is not used internally in any case. |
init |
|
randomXj |
function for randomly generating variable values according to the sampling distribution. The function should take the number of observations to be generated as a first argument, and the vector of parameters as a second argument; a vector of random values should be returned. |
x2v |
function for updating the parameters of the sampling distribution. No smoothing is needed. The function should take a single argument to be used for updating the parameters. |
v2x |
function for obtaining point values of variable from the parameters of the sampling distribution. |
smooth |
list of unevaluated expressions of smoothing functions for each parameter of the sampling distribution. |
... |
further arguments to be included into the |
An object of class type
and typevar
, where type
is the value of the
argument type
passed to type_custom
, or predefined lables (if not
overwritten) in case of other functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Define a new type of real variable where the first parameter of the
# sampling distribution is updated through the median (instead of the
# mean):
type_real(
type = 'real2',
x2v = function(x) { c(median(x), sd(x)) }
)
# Define a new type of real variable whith different smoothing
# parameters:
type_real(
type = 'real3',
smooth = list(
quote(smooth_lin(x, xt, 0.8)),
quote(smooth_dec(x, xt, 0.99, 15))
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.