Re: [R] Optimise parameter of a generic function

2009-09-23 Thread Samuel Dennis
Typical, spotted a very stupid typo in my code after posting, and when corrected I have solved my own problem. Sorry for bothering everyone. Line below should have read: optimise(f = nbinopt, interval = c(0,100), maximum=FALSE, tol=0.01) Samuel Dennis wrote: > > optimise(f = nbin063, interval =

[R] Optimise parameter of a generic function

2009-09-23 Thread Samuel Dennis
I would like to know how to determine the best value of a particular parameter in a generic function. My function is: nbin <- function(k,Dt) { R <- Dt / (k + Dt) q <- (k + Dt) / k Pt <- c(0:7) for (r in c(0:7)) { Pt[r+1] <- (factorial(k+r-1)/(factorial(r)*factorial(k-1)))*((R^r)/(q^k)) } Pt } Th