# Create the estimate object:
variable = c("labor_cost", "investment_cost", "yield", "market_price")
distribution = c("posnorm", "posnorm", "posnorm", "posnorm")
lower = c(200, 20000, 5000, 10)
upper = c(10000, 100000, 20000, 200)
costBenefitEstimate <- as.estimate(variable, distribution, lower, upper)
# Define the model function without name for the return value:
profit1 <- function(x) {
income <- x$yield * x$market_price
costs <- x$labor_cost + x$investment_cost
profit <- income - costs
return(list(Revenues = profit))
}
# Perform the Monte Carlo simulation:
predictionProfit1 <- mcSimulation(estimate = costBenefitEstimate,
model_function = profit1,
numberOfModelRuns = 10000,
functionSyntax = "data.frameNames")
# Run the PLS analysis
pls <- plsr.mcSimulation(object = predictionProfit1,
resultName = names(predictionProfit1$y))
# Plot PLS results
plot_pls(pls)
Run the code above in your browser using DataLab