RiskElement | R Documentation |
This is the parent class defining the structure for the other elements.
name
A character giving a name to this constant
inputs
A tibble with the inputs of the element and its units
depends_on
List describing the dependencies for each input
depends_index
List with the indexes for each independency
depended_by
A list of elements that use this instance as input
input_types
A list with the preferred data type for each input (discrete/continuous/any)
output
Name of the output variable
output_unit
Unit of the output variable
output_type
Type of output variable (discrete/continuous)
simulations
A tibble with the results of the simulations
type
A character describing the type of the element
level
Description of the level for X-D Monte Carlo
simulations_multi
For multidimensional MC
new()
Creates a new instance of this R6 class.
RiskElement$new( name, input_names = NA, units = NA, element_type = "", input_types = list(), output_var = "", output_unit = "", output_type = "", level = 0 )
name
A character defining the name for the element
input_names
A character vector with the names of the inputs
units
A character vector of units for each input
element_type
A character with the type of element
input_types
A list with the type of output for each input
output_var
A character with the name of the output variable
output_unit
A character with the unit of the output
output_type
A character with the type of the output ('continuous' or 'discrete')
level
Level of the variance for 2D Monte Carlo
A new instance of the element
map_input()
Map an input to a element
RiskElement$map_input(input, element, check_units = FALSE, index = 1)
input
A character identifying the input variable
element
An instance of a element to use as input
check_units
Ignored
index
Index of element
(for elements with multiple outputs). By default, 1
self
(invisible)
simulate()
Make simulation. Returns a vector of length niter with self.value.
RiskElement$simulate(niter, seed = NULL)
niter
Number of iterations (length of the vector).
seed
Seed for the pRNG. By default, NULL
(no setting the seed)
A vector with the output variable
simulate_2D()
2D Monte Carlo simulation
RiskElement$simulate_2D(niter0, niter1, seed = NULL)
niter0
number of iterations on the lower level
niter1
number of iterations on the upper level
seed
Seed for the pRNG. By default, NULL
(no setting the seed)
simulate_level()
Simulation of one level for the 2D Monte Carlo
RiskElement$simulate_level(niter0, iter1 = 1, level = 0)
niter0
number of iterations on the lower level
iter1
index representing the iteration (where to write). By default, 1
level
level to simulate (0
by default)
point_estimate()
Gets a discrete (fast and simple) prediction
RiskElement$point_estimate()
get_output()
Get the output
RiskElement$get_output(iter1 = NULL, index = 1)
iter1
Number of iterations (length of the vector).
index
Index fo the output (for multioutput modules). By default, 1
A vector with the output variable
get_output_2D()
Get the output of a 2D simulation
RiskElement$get_output_2D(index = 1)
index
Index fo the output (for multioutput modules). By default, 1
save_as_vector()
Saves the output of the simulation as a vector element
RiskElement$save_as_vector(name = NULL)
name
Name of the new element (vctr_from_+self_name by default)
An instance of Vector
save_as_distribution()
Saves the output of the simulation as an empirical distribution.
RiskElement$save_as_distribution(name = NULL)
name
Name of the new element (distr_from_+self_name by default)
An instance of EmpiricalDistr
density_plot_2D()
Makes density plot of a 2D Monte Carlo simulation
RiskElement$density_plot_2D()
cummulative_plot_2D()
Plots the empirical density function for 2D simulations
RiskElement$cummulative_plot_2D()
cummulative_plot()
Plots the empirical density function
RiskElement$cummulative_plot(add_discrete = FALSE)
add_discrete
whether to add an horizontal line with the discrete estimate.
By default, FALSE
density_plot()
Makes a density plot of the model output
RiskElement$density_plot(add_discrete = FALSE)
add_discrete
whether to add an horizontal line with the discrete estimate.
By default, FALSE
histogram()
Makes a histogram of the model output
RiskElement$histogram(add_discrete = FALSE)
add_discrete
whether to add a vertical line with the discrete estimate.
By default, FALSE
boxplot()
Makes a boxplot of the model output
RiskElement$boxplot(add_discrete = FALSE)
add_discrete
whether to add an horizontal line with the discrete estimate.
By default, FALSE
quantiles()
Quantiles of the output variable
RiskElement$quantiles(probs = c(0.01, 0.1, 0.5, 0.9, 0.99))
probs
values of the quantiles. By default, c(.01, .1, .5, .9, .99)
quantiles_2D()
Quantiles of a 2D Monte Carlo simulation
RiskElement$quantiles_2D(probs = c(0.01, 0.1, 0.5, 0.9, 0.99))
probs
values of the quantiles. By default, c(.01, .1, .5, .9, .99)
get_output_type()
Get the data type of the output. This is a default implementation (just return the output type). For other elements, (e.g., sum) the type depends on the type of the inputs. So, they have their own implementation.
RiskElement$get_output_type()
check_input_types()
Checks that the type of the inputs is consistent
RiskElement$check_input_types(recursive = FALSE)
recursive
whether to also check the types of the dependencies. By default, FALSE
clone()
The objects of this class are cloneable with this method.
RiskElement$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.