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: rvarad...@jhmi.edu


----- Original Message -----
From: Steven <ytste...@gmail.com>
Date: Sunday, December 6, 2009 5:54 am
Subject: [R] optim with constraints
To: r-help@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@r-project.org mailing list
> 
> PLEASE do read the posting guide 
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to