Dear all of you,

I would like to get some help from you.
Here I attach you a model, that I would like to be stochastic so I would need each time the value of x changed, the values of parameters (ss, emrg, gf, spp, sr) did too according to a normal distribution, with mean its value and standard deviation given by the parameter name preceded by SDV (In the case of parameter ss, mean is 0.3 and Standad deviation 0.08). I explain myself, the model take the mean value of these parameter (ss, emrg, gf, spp, sr) and I would like for example, when x changed to the value 2, the parameters values changed randomly according to their normal distribution (given the mean and standard deviation values) and got another mean value. And when x was 3 again, and every time until 20. Does anyone, know how to do it?

ss <- 0.3
emrg <- 0.35
gf <- 0.22
spp <- 100
sr <- 0.52

SDVss <- 0.08
SDVemrg <- 0.05
SDVgf <- 0.04
SDVspp <- 22
SDVsr <- 0.1

data.frame <- matrix(0,20,7)
data.frame
data.frame[,1] <- 1:20
data.frame
for(x in 1:20){
                if(x==1){
                                data.frame[1,2] <- 50
                                data.frame[1,3] <- 18
                                data.frame[1,4] <- 3
                                data.frame[1,5] <- 300
                                data.frame[1,6] <- NA
                                data.frame[1,7] <- NA
                                }else{
                                data.frame[x,2] <- (data.frame[(x-1),2]-data.frame[(x-1),3]+data.frame[(x-1),5]*sr)*ss
                                data.frame[x,3] <- data.frame[x,2]*emrg
                                data.frame[x,4] <- data.frame[x,3]*gf
                                data.frame[x,5] <- data.frame[x,4]*spp
                                data.frame[x,6] <- data.frame[x,2]- data.frame[(x-1),2]
                                data.frame[x,7] <- data.frame[x,2]/ data.frame[(x-1),2]
                                }
                }
end
data.frame

Thank you very much in advanced,
Judit Barroso

	[[alternative HTML version deleted]]

