Re: [R] Error message handling

2004-06-24 Thread Prof Brian Ripley
On Wed, 23 Jun 2004 [EMAIL PROTECTED] wrote:

 Dear, R experts.
 Does anybody have experience with 'optim' function?

Yes.

 I have an error message as the following.
 
 Error in optim(transcoefs, fn = hfdeviance, gr = hfdeviance.grad, method
 = BFGS,  :
 initial value in vmmin is not finite
 
 I want to make a comment when this happen.

 Function 'fn' can return 'NA' or 'Inf' if the function cannot be
 evaluated at the supplied value, but the initial value must have a
 computable finite value of 'fn'. (Except for method 'L-BFGS-B'
 where the values should always be finite.)

It's your error so you can control it (by not making the error).

 Is there way I can put *my* message after this error occur?

You can use try/tryCatch and similar constructs.  But it would be better
to use a valid starting value as optim asks, and you can so that by
calling hfdeviance(transcoefs) and checking it is finite.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Error message handling

2004-06-23 Thread Kang . Changku




Dear, R experts.
Does anybody have experience with 'optim' function?

I have an error message as the following.

Error in optim(transcoefs, fn = hfdeviance, gr = hfdeviance.grad, method
= BFGS,  :
initial value in vmmin is not finite

I want to make a comment when this happen.
Is there way I can put *my* message after this error occur?

Thanks in advance

+
Changku Kang
National Center for Environmental Assessment
EPA  (B211F)
919-541-1396
919-541-0245 (fax)
[EMAIL PROTECTED]

Graduate Student
Department of Statistics, NCSU
[EMAIL PROTECTED]
919-513-2956
+

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html