[R] how to restrict a parameter in optim()

Ben Bolker bolker at ufl.edu
Wed Oct 29 23:06:22 CET 2008


Luis SAGAON TEYSSIER <luis.sagaon_teyssier <at> etumel.univmed.fr> writes:

> 
> Dear all,
> 
> I'm trying to estimate some parameters with the optim() function but I  
> need to restrict one parameter and I have not found how to do it.  
> Could you help me please?

  Thought someone else would answer by now.
  use the arguments method="L-BFGS-B", lower=c(-Inf,-Inf,-Inf,-Inf,0),
    upper=c(Inf,Inf,Inf,Inf,1)
 
 you may need to tweak these slightly (e.g. set the bounds slightly
within the desired [0,1] range or set the lower/upper bounds for
the unbounded parameters to large negative/positive numbers)
if you get errors about NaNs etc.



More information about the R-help mailing list