## MONTE CARLO SIMULATION HELP

I am trying to run a Monte Carlo on a dataset (see reprex below)

I think I need numbers selected at random for each factor (A,E..) between the min and max values (AMin and AMax, EMin and EMax) for each G which are then multiplied by the FTW for each G?

Basically I am trying to see the impact of minimum and maximum values on output - do the input values make a difference for any of the FG outputs (and which ones) or does the FTW need to be reduced to have an effect?

I found the following code and I tried to adapt it to my data but I can't

I am looking for an output as a ggplot simulation graph (if possible but am open to suggestions)

I would really really appreciate any help on this as I am really stuck

This is the code I found on another question and tried to change;

expr <- expression(a+b*2+c*3+d/2)

x <- list(?)

u <- lapply(x, function(x) x/10)

u.MC<-uncertMC(expr, x, u, distrib=rep("norm", 4), method="MC")

print(u.MC, simplify=FALSE)

n=1000

rmin=df$AMin

rmax=df$AMax

r<- runif(n, rmin, rmax)

kmin=df$EMin

kmax=df$EMax

k<- runif(n, kmin, kmax)

rk<-cbind(r,k)

(I'm not sure if these numbers are suitable for my data?)

dstart=c(0.8,1)

dinit<-seq(dstart[1],dstart[2],0.1)

dfin=c(0.2,0.4)

sigma<-0.1

vt<-rnorm(1,0,sigma)

B<-matrix(df?, nrow=length(k),ncol=?, byrow=TRUE)

B[,1]<-k*dinit[length(dinit)]*10
for (j in 1:length(k)){
for (t in 1:(10-1)){
B[j,t+1] = B[j,t]+r[j]*?-?[t]

*B[j,t]*(1-(B[j,t]/k[j]))

matall<-cbind( rk,B)

if (j == length(k) & i == max(dinit) & t == (nyr-1))

lastyear<-ifelse((matall[,ncol(matall)]/k)>dfin[1] &

(matall[,ncol(matall)]/k)<dfin[2],

matall[,ncol(matall)],NA)

```
structure(list(NAME = c("W", "M", "W", "M", "W", "M", "W",
"M"), G = c(1, 2, 1, 2, 1, 2, 1, 2), Grp_Stat = c("AMin", "AMin",
"AMax", "AMax", "EMin", "EMin", "EMax", "EMax"), Value = c(0.0034,
0.0029, 0.0334, 0.0254, 0.000168, 0.00078, 0.07737,
0.0208), Output = c("A", "A", "A", "A", "E", "E",
"E", "E"), Input = c("MINIMUM", "MINIMUM", "MAXIMUM", "MAXIMUM",
"MINIMUM", "MINIMUM", "MAXIMUM", "MAXIMUM"), FTW = c(50, 100,
50, 100, 50, 100, 50, 100)), row.names = c(NA, -8L), class = c("tbl_df",
"tbl", "data.frame"))
```