Dear all, In the following code, I was trying to compute each row of the "param" iteratively based on the first row. This likely is not the best way. Can anyone suggest a simpler way to improve the code. Thanks a lot! Hannah
param <- matrix(0, 11, 5) colnames(param) <- c("p", "q", "r", "2s", "t") param[1,] <- c(0.5, 0.5, 0.4, 0.5, 0.1) for (i in 2:11){ param[i,1] <- param[(i-1),3]+param[(i-1),4]/2 param[i,2] <- param[(i-1),4]/2+param[(i-1),5] param[i,3] <- param[(i-1),1]*(param[(i-1),3]+param[(i-1),4]/2) param[i,4] <- param[(i-1),1]*(param[(i-1),4]/2+param[(i-1),5])+param[(i-1),2 ]*(param[(i-1),3]+param[(i-1),4]/2) param[i,5] <- param[(i-1),2]*(param[(i-1),4]/2+param[(i-1),5]) } round(param,3) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.