[Rd] non-differentiable evaluation points in nlminb(), follow-up of PR#15052

2012-09-27 Thread Sebastian Meyer
This is a follow-up question for PR#15052


There is another thing I would like to discuss wrt how nlminb() should
proceed with NAs. The question is: What would be a successful way to
deal with an evaluation point of the objective function where the
gradient and the hessian are not well defined?

If the gradient and the hessian both return NA values (assuming R <
r60789, e.g. R 2.15.1), and also if both return +Inf values, nlminb
steps to an NA parameter vector.
Here is a really artificial one-dimensional example for demonstration:

f <- function (x) {
  cat("evaluating f(", x, ")\n")
  if(is.na(x)) {Inf   # to prevent an infinite loop for R < r60789
  } else abs(x)
}
gr <- function (x) if (abs(x) < 1e-5) Inf else sign(x)
hess <- function (x) matrix(if (abs(x) < 1e-5) Inf else 0, 1L, 1L)
trace(gr)
trace(hess)
nlminb(5, f, gr, hess, control=list(eval.max=30, trace=1))

Thus, if nlminb reaches a point where the derivatives are not defined,
optimization is effectively lost. Is there a way to deal with such
points in nlminb? Otherwise, the objective function is doomed to
emergency stop() if it receives NA parameters because nlminb won't pick
up courage - regardless of the following return value of the objective
function.
As far as I would assess the situation, nlminb is currently not capable
of optimizing objective functions with non-differentiable points.

Best regards,
  Sebastian Meyer

-- 
Sebastian Meyer
Division of Biostatistics
Institute of Social and Preventive Medicine
University of Zurich

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] tcltk capability

2012-09-27 Thread Paul Johnson
Sorry I did not see this sooner.  Response below:

On Thu, Aug 30, 2012 at 2:48 PM, Gabor Grothendieck
 wrote:
> There are quite a few packages that make use of tcltk and although
>
> - most R distributions have tcltk capability
> - its possible to query this via capabilities()[["tcltk"]]
> - attempting to build a package that needs it on such an R
> distribution will give a message letting one know
>
> users still seem to have problems with this.

I agree that packages are using tcltk, but users do so at their peril.
 Just loading tcltk breaks multicore functions like mclapply. I don't
understand why, you might be able to explain it to me.

http://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15040

tcltk is discouraged, at least to some in R core.

I would really appreciate some guidance on what graphics library I
should use to develop GUI for R programs.  There's no future in tcltk,
apparently, but I don't know what to work with.

pj

pj

>
> There was recently an R bug report submitted that likely stemmed from
> the user having such a build of R and recently there was also an R
> help post that seemed to be related to this as well.  As more and more
> packages add GUI capability these incidents are bound to increase.
>
> The best situation would be to arrange that every distribution of R
> have tcltk capability but if this is difficult to arrange then I
> suggest there be a message at start up similar to the existing locale
> message letting the user know that the R distribution they are running
> lacks tcltk capability.  Preferably the message would be somewhat
> menacing so that users are encouraged to get a different distribution
> of R right from the start.
>
> This might reduce such problem reports somewhat.
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Paul E. Johnson
Professor, Political ScienceAssoc. Director
1541 Lilac Lane, Room 504 Center for Research Methods
University of Kansas   University of Kansas
http://pj.freefaculty.orghttp://quant.ku.edu

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] tcltk capability

2012-09-27 Thread Gabor Grothendieck
On Thu, Sep 27, 2012 at 2:18 PM, Paul Johnson  wrote:
> Sorry I did not see this sooner.  Response below:
>
> On Thu, Aug 30, 2012 at 2:48 PM, Gabor Grothendieck
>  wrote:
>> There are quite a few packages that make use of tcltk and although
>>
>> - most R distributions have tcltk capability
>> - its possible to query this via capabilities()[["tcltk"]]
>> - attempting to build a package that needs it on such an R
>> distribution will give a message letting one know
>>
>> users still seem to have problems with this.
>
> I agree that packages are using tcltk, but users do so at their peril.
>  Just loading tcltk breaks multicore functions like mclapply. I don't
> understand why, you might be able to explain it to me.
>
> http://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15040
>
> tcltk is discouraged, at least to some in R core.
>
> I would really appreciate some guidance on what graphics library I
> should use to develop GUI for R programs.  There's no future in tcltk,
> apparently, but I don't know what to work with.

R aside, tcl/tk itself is far from dead. Although not as popular as in
its heyday there is still a core group that works on it and keeps
issuing new versions.  The versions are quite a few years apart but on
the other hand they tend to have major improvements to them which
would seem to justify a longer cycle.  In terms of the tcl/tk
community, new or updated packages for tcl/tk keep coming out. Looking
at some of the tcl/tk packages that I have used in the last year I
notice that several of them have a last release date of this year.
Also at least some books on tcl/tk keep coming out, the tcltk mailing
list is active, there continues to be tcl/tk conferences and there is
a very active tcl/tk wiki.

The above was for the tcl/tk language only but if we look at the tcltk
R package then its bundled with most versions of R so its the easiest
way to have a GUI with minimal installation hassle on most platforms.
On Windows and most Linux distributions just issue library(tcltk) in
your session and you have it with nothing else to do in terms of
installation.  Furthermore there is a reasonably large infrastructure
of R packages either built on tcltk or that can use tcltk as well as a
number of addon R packages that can ease development.

If you can't decide on which GUI toolkit to use have a look at
gWidgets.  It provides a common layer over multiple GUI toolkits which
subject to some limitations based on which features were used lets the
user switch at will among the various toolkits.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel