[R] optim with constraints
Steven
ytsteven at gmail.com
Mon Dec 7 02:32:54 CET 2009
Hi, Prof Nash
Thanks for your comment!
I modified my code to be (added an extra parametr):
optim(c(1.14,0.25,0.06), weibull.like, mydata=mydata, method="L-BFGS-
B", hessian = TRUE, lower = c(0, 0, 0), upper = c(Inf, Inf, 1))
But I had the following error:
Error in optim(c(1.14, 0.25, 0.06), weibull.like, mydata = mydata,
method = "L-BFGS-B", :
non-finite finite-difference value [2]
What does that mean? Much appreciate your help!
Steven
On Dec 7, 1:15 am, "Prof. John C Nash" <nas... at uottawa.ca> wrote:
> As per ?optim
>
> > Usage:
>
> > optim(par, fn, gr = NULL, ...,
> > method = c("Nelder-Mead", "BFGS", "CG", "L-BFGS-B", "SANN"),
> > lower = -Inf, upper = Inf,
> > control = list(), hessian = FALSE)
>
> Note that the optimx() function on R-forgehttp://r-forge.r-project.org/R/?group_id=395
> is a wrapper that allows some other methods too.
>
> JN
>
>
>
>
>
> > Message: 72
> > Date: Sun, 6 Dec 2009 02:53:55 -0800 (PST)
> > From: Steven <ytste... at gmail.com>
> > Subject: [R] optim with constraints
> > To: r-h... at r-project.org
> > Message-ID:
> > <5e293933-91f2-48f7-98e5-bc87905c5... at x25g2000prf.googlegroups.com>
> > Content-Type: text/plain; charset=ISO-8859-1
>
> > Hi, dear R users
>
> > I am a newbie in R and I wantto use the method of meximum likelihood
> > to fit a Weibull distribution to my survival data. I use "optim" as
> > follows:
>
> > optim(c(1, 0.25),weibull.like,mydata=mydata,method="L-BFGS-B",hessian
> > = TRUE)
>
> > My question is: how do I setup the constraints so that the two
> > parametrs of Weibull to be pisotive? Or should I use other function
> > like"nlm"?
>
> > Many thanks! Any comments are greatly appreciated!
>
> > Steven
>
> ______________________________________________
> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.- Hide quoted text -
>
> - Show quoted text -
More information about the R-help
mailing list