Re: [R] NA return to NLM routine

2012-12-01 Thread Berend Hasselman
On 30-11-2012, at 23:55, Mac Gaulin wrote: > Hello, > > I am trying to understand a small quirk I came across in R. The > following code results in an error: > > k <- c(2, 1, 1, 5, 5) > f <- c(1, 1, 1, 3, 2) > loglikelihood <- function(theta,k,f){ >if( theta<1 && theta>0 ) >return(-

Re: [R] NA return to NLM routine

2012-12-01 Thread Uwe Ligges
On 30.11.2012 23:55, Mac Gaulin wrote: Hello, I am trying to understand a small quirk I came across in R. The following code results in an error: k <- c(2, 1, 1, 5, 5) f <- c(1, 1, 1, 3, 2) loglikelihood <- function(theta,k,f){ if( theta<1 && theta>0 ) return(-1*sum(log(choose(k

[R] NA return to NLM routine

2012-11-30 Thread Mac Gaulin
Hello, I am trying to understand a small quirk I came across in R. The following code results in an error: k <- c(2, 1, 1, 5, 5) f <- c(1, 1, 1, 3, 2) loglikelihood <- function(theta,k,f){ if( theta<1 && theta>0 ) return(-1*sum(log(choose(k,f))+f*log(theta)+(k-f)*log(1-theta))) re