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
[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),
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