[R] optim with constraints

Ravi Varadhan rvaradhan at jhmi.edu
Sun Dec 6 16:35:30 CET 2009


Read the help page for `optim'.  You already seem to be aware that "L-BFGS-B" should be used.  How much more harder is to read the help page further to figure out how to supply the constraints?

There are also various other algorithms, but "L-BFGS-B" should be able to do the job. 

Ravi.
____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: Steven <ytsteven at gmail.com>
Date: Sunday, December 6, 2009 5:54 am
Subject: [R] optim with constraints
To: r-help at r-project.org


> 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-help at r-project.org mailing list
> 
> PLEASE do read the posting guide 
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list