In response to the second question about the placement of D<=t, there are two instances of it: once after the comment "starts inside node" (After the line with the comment "start & end in first node") and one after "starts outside node." Did that answer the question?
I don't know if this helps, but I originally had it in terms of just "m" time steps (its below; the changed parts are highlighted), but I wanted to convert it into actual time "w." That's when the problem started. Probability <- function(N, f, m, b, y, t) { #N is the number of lymph nodes (500-600) #f is the fraction of Dendritic cells (in the correct node) that have the antigen #m is the number of time steps #b is the starting position (somewhere in the node or somewhere in the gap between nodes. It is a number between 1 and (x+t)) #y is the number of time steps it takes to traverse the gap #t is the number of time steps it takes to traverse a node. A <- 1/N B <- 1-A C <- 1-f D <- (((m+b-1)%%(y+t))+1) if (b<=t) {########starts inside node if (m<=(t-b)){return(B + A*(C^m))} # start & end in first node if (D<=t) { # we finish in a node a <- (B + A*(C^(t-b))) #first node b <- ((B + A*(C^t))^(floor((m+b)/(y+t))-1)) # intermediate nodes (if any) c <- (B + A*(C^D)) # last node return(a*b*c) } else {return(Probability(N, f, *(m-1)*, b, y, t))} ## finish in a gap } else {###### starts outside node if (m<=(y+t-b)) {return(1)} #also end in the gap if (D<=t) { #end in a node b <- ((B + A*(C^t))^(floor((m/(y+t))))) c <- (B + (A*(C^D))) return(b*c) } else {return(Probability(N, f, *(m-1)*, b, y, t))} #outside node } } I changed (m-1) to (m*q-q) in order to get the same effect, but perhaps it had some adverse effect? I still don't know how to fix this... -- View this message in context: http://r.789695.n4.nabble.com/An-infinite-recursion-error-please-explain-tp3688260p3689597.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.