Missing Argument in optim()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Missing Argument in optim()

voodooochild
Hello everybody,

i already searched the archieves, but i still don't know what is wrong
in my implementation, mybe anybody coud give me some advice

ll1<-function(rho,theta,beta1,beta2,beta3,beta4,t,Szenariosw5,Testfaellew5,X1,X2)
{
    n<-length(t)    
    t<-cumsum(t)
      tn<-t[length(t)]
      Szenn<-Szenariosw5[length(Szenariosw5)]
      Testn<-Testfaellew5[length(Testfaellew5)]
      X1n<-X1[length(X1)]
    X2n<-X2[length(X2)]
    n/rho-(tn^theta)*(beta1*Szenn+beta2*Testn+beta3*X1n+beta4*X2n)
}

p0<-c(rho=1,theta=1,beta1=1,beta2=1,beta3=1,beta4=1)

optim(p0,fn=ll1,t=t,Szenariosw5=Szenariosw5,Testfaellew5=Testfaellew5,X1=X1,X2=X2)

i always got an error message: Argument "theta" is missing, with no default
but i don't know what is wrong?

thanks!

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: Missing Argument in optim()

Brian Ripley
On Mon, 27 Mar 2006, [hidden email] wrote:

> Hello everybody,
>
> i already searched the archieves, but i still don't know what is wrong
> in my implementation, mybe anybody coud give me some advice
>
> ll1<-function(rho,theta,beta1,beta2,beta3,beta4,t,Szenariosw5,Testfaellew5,X1,X2)
> {
>    n<-length(t)
>    t<-cumsum(t)
>      tn<-t[length(t)]
>      Szenn<-Szenariosw5[length(Szenariosw5)]
>      Testn<-Testfaellew5[length(Testfaellew5)]
>      X1n<-X1[length(X1)]
>    X2n<-X2[length(X2)]
>    n/rho-(tn^theta)*(beta1*Szenn+beta2*Testn+beta3*X1n+beta4*X2n)
> }
>
> p0<-c(rho=1,theta=1,beta1=1,beta2=1,beta3=1,beta4=1)
>
> optim(p0,fn=ll1,t=t,Szenariosw5=Szenariosw5,Testfaellew5=Testfaellew5,X1=X1,X2=X2)
>
> i always got an error message: Argument "theta" is missing, with no default
> but i don't know what is wrong?

>From the help page:

       fn: A function to be minimized (or maximized), with first
           argument the vector of parameters over which minimization is
           to take place.  It should return a scalar result.

ll1 is not such a function, and I think you need to replace the first 6
arguments by a single 6-element vector.

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html