##############################################################
# Example 1 (Creating the estimate from the command line):
#############################################################
# Create the estimate object:
variable = c("revenue", "costs")
distribution = c("norm", "norm")
lower = c(10000, 5000)
upper = c(100000, 50000)
costBenefitEstimate <- as.estimate(variable, distribution, lower, upper)
# (a) Define the model function without name for the return value:
profit1 <- function(x) {
x$revenue - x$costs
return(list(Revenues = x$revenue,
Costs = x$costs))
}
# Perform the Monte Carlo simulation:
predictionProfit1 <- mcSimulation(estimate = costBenefitEstimate,
model_function = profit1,
numberOfModelRuns = 10000,
functionSyntax = "data.frameNames")
# Plot the distributions
plot_distributions(mcSimulation_object = predictionProfit1, vars = c("Revenues", "Costs"),
method = "smooth_simple_overlay")
plot_distributions(mcSimulation_object = predictionProfit1, vars = c("Revenues", "Costs"),
method = "hist_simple_overlay", bins = 30)
plot_distributions(mcSimulation_object = predictionProfit1, vars = c("Costs"),
method = "hist_simple_overlay", binwidth = 1000)
plot_distributions(mcSimulation_object = predictionProfit1, vars = c("Revenues", "Costs"),
method = "boxplot_density", outlier_shape = 3)
Run the code above in your browser using DataLab