[R] Missing Argument in optim()
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Mar 27 13:14:29 CEST 2006
On Mon, 27 Mar 2006, voodooochild at gmx.de 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, ripley at stats.ox.ac.uk
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
More information about the R-help
mailing list