This function will be called after an instance is built. User
input will be stored in the environment. The response variable of this model
is y
.
Arguments
- prm
Named List. A list of random variables or closed form expressions that needs to be used while constructing
y
. Constant parameters could also be supplied.- prm_type
Named List. A list of characters denoting the type of the parameters. "r" stands for random variable or closed form used in the expression of
y
, "o" stands for others. This value only affects the string representation of the object.- formula
Formula. This will be passed to
CLOSED_FORM$instantiate
to define a closed form expression fory
. Default isformula = self$formula
.- null_formula
Formula. Formula for fitting the null model. Default is
NULL
.- alt_formula
Formula. Formula for fitting the alternative model. Default is
NULL
.
Examples
# Instantiate
x <- rand_uniform()
e <- rand_normal()
test <- vi_model(prm = list(x = x, e = e),
prm_type = list(x = "r", e = "r"),
formula = y ~ 1 + x + x^2 + e,
null_formula = y ~ x,
alt_formula = y ~ x + I(x^2))
test
#>
#> ── <VI_MODEL object>
#> y = 1 + x + x^2 + e
#> - x: <RAND_UNIFORM object>
#> [a: 0, b: 1]
#> - e: <RAND_NORMAL object>
#> [mu: 0, sigma: 1]