This is my code, but I am facing some issues. This line: results <- MonteCarlo(model, n = 10000), gives me the following error:
Error in MonteCarlo(model, n = 10000) :
argument 2 matches multiple formal arguments
This is the whole code. Can anyone see where I have made a mistake?
install.packages("MonteCarlo")
library(MonteCarlo)
year1.price <- 1800
year2.price <- c(-250, 200, 500)
year3.price <- c(-250, 200, 500)
year4.price <- c(-250, 200, 500)
year5.price <- c(-250, 200, 500)
output.distribution <- c(100, 1000, 1800)
annual.change <- c(-0.15, 0.3, 0.7)
fixed.costs <- c(500000, 750000, 1000000)
legal.costs <- c(500000, 750000, 1000000)
model <- function() {
year1.revenue <- year1.price * output.distribution[2]
year2.revenue <- year2.price[sample(1:3, 1)] * (output.distribution[2] + output.distribution[2] * annual.change[sample(1:3, 1)])
year3.revenue <- year3.price[sample(1:3, 1)] * (output.distribution[2] + output.distribution[2] * annual.change[sample(1:3, 1)])
year4.revenue <- year4.price[sample(1:3, 1)] * (output.distribution[2] + output.distribution[2] * annual.change[sample(1:3, 1)])
year5.revenue <- year5.price[sample(1:3, 1)] * (output.distribution[2] + output.distribution[2] * annual.change[sample(1:3, 1)])
total.revenue <- year1.revenue + year2.revenue + year3.revenue + year4.revenue + year5.revenue
total.costs <- fixed.costs[2] + legal.costs[sample(1:3, 1)]
net.revenue <- total.revenue - total.costs
return(net.revenue)
}
results <- MonteCarlo(model, n = 10000)
summary(results)
