search for: testprod

Displaying 1 result from an estimated 1 matches for "testprod".

Did you mean: testprog
2003 Jul 14
1
for loop problem
...gr are vectors. ax.to.nax <- function(qx, ax, gr=c(0,1,5,10)){ px <- 1 - qx last.n <- gr[length(gr)] - gr[length(gr) - 1] all.bounds <- c(gr, gr[length(gr)] + last.n) n <- diff(all.bounds) # i <- 1 # this i should loop through the values of # gr: i=0, i=1, i=5 and i=10. # testprod <- prod(px[(i+1):(i+n[i+1])]) return(1 - testprod) } Every attempt to loop through the values of gr, gives the following error message: Error in (i + 1):(i + n[i + 1]) : NA/NaN argument Here is an example of the deplorably erroneous code that causes the message to appear: ax.to.nax.for &lt...