Re: [Rd] Name length of function argument? (PR#10357)

2007-10-20 Thread Prof Brian Ripley
Please study the help page before posting. In the example code given 'p' is partially matching the second argument 'par' of optim(), so the unnamed first argument matches to the second argument 'fn'. In the second case, 'f' matches 'par' and 'pp' matches '...', and 'f' is of 'type closure'. O

Re: [Rd] Name length of function argument? (PR#10357)

2007-10-20 Thread Duncan Murdoch
[EMAIL PROTECTED] wrote: > Hi, > I've just been programming a function to calculate the likelihood in a > probit model. > The function looks like this > > likelihood <- function(Y,X,p) { > Z <- p[1] +p[2]*X > P <- Y*pnorm(Z) + (1-Y)*(1-pnorm(Z)) > -prod(P) > } > > out <- optim(likelihood,p=c(0,0),

[Rd] Name length of function argument? (PR#10357)

2007-10-19 Thread deiwiks
Hi, I've just been programming a function to calculate the likelihood in a probit model. The function looks like this likelihood <- function(Y,X,p) { Z <- p[1] +p[2]*X P <- Y*pnorm(Z) + (1-Y)*(1-pnorm(Z)) -prod(P) } out <- optim(likelihood,p=c(0,0),Y=wells$switch,X=wells$dist, hessian=TRUE) X a