I’d like to generate an x random variable in this way:
x <- exp(qnorm(runif(10000))*0.2 + 2)
within a while loop, where I create a time variable that sums at each step the new x variable to the previous time variable (that is the cumulative sum of x variables at that point), until the condition time<=365 is not valid anymore.
I want to store all the time variables created at each step in an external dataframe.
What I’ve done:
results <- vector()
tmp <- vector(length = 10000, mode = "numeric")
i <- 1
while(min(time) <= 365){
x <- exp(qnorm(runif(10000))*0.28 + 4.2)
tmp <- data.frame(cbind(tmp, x))
time <- x + tmp[,i]
i <- i + 1
}
I’m stucked with the last step.