# [R] optim ???

kjetil halvorsen kjetilh at umsanet.edu.bo
Thu Nov 22 17:38:09 CET 2001

```Hola!

santes<-c(210,169,187,160,167,176,185,206,173,146,174,201,198,148,154)
sdespues<-c(201,165,166,157,147,145,168,180,147,136,151,168,179,129,131)
dantes<-c(130,122,124,104,112,101,121,124,115,102,98,119,106,107,100)
ddespues<-c(125,121,121,106,101,85,98,105,103,98,90,98,110,103,82)
presion<-data.frame( santes, sdespues, dantes, ddespues)

logvero <- function(mu,delta,s2ksi,s2eps,beta,s2eta,x,z)
{
n <- length(x)
sigma <- matrix(c(s2ksi+s2eps,beta*s2ksi-s2eps,beta*s2ksi-s2eps,
beta^2*s2ksi+s2eta+2*s2eps),2,2)
xz <- sum((x-mu)*(z-delta))
A <- matrix(c(sum((x-mu)^2),xz,xz,sum((z-delta)^2)),2,2)
A <- (1/2)*solve(sigma) %*% A
logdet <- (-1)*n*log(det(sigma))
logdet-sum(diag(A))
}

optim(par=c(mu=mean(santes),delta=mean(sdespues-santes),s2ksi=422,s2eps=1,s2eta=75),
fn=function(mu,delta,s2ksi,s2eps,s2eta)
logvero(mu,delta,s2ksi,s2eps,0,s2eta,santes,sdespues-santes),
control=list(trace=1, fnscale=-1),
method="BFGS")

gives the result:

Error in as.vector(data) : Argument "s2ksi" is missing, with no default

What is happening?

Kjetil Halvorsen
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```