[19172] in s-news-athena

home help back first fref pref prev next nref lref last post

Re: [S] ms() and trace= arg

daemon@ATHENA.MIT.EDU (Nicole DePriest)
Thu Sep 9 13:37:06 1999

Date: Thu, 9 Sep 1999 13:29:38 -0400 (EDT)
From: Nicole DePriest <ntd@stat.ohio-state.edu>
To: s-news@wubios.wustl.edu
Cc: bugs@statsci.com
Message-Id: <Pine.SOL.4.10.9909091324440.29331-100000@stat.mps.ohio-state.edu>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII


Hello,

The other day I posted a problem regarding the trace= argument of the
ms() function.  The trace arg seemd to be ignored when I ran ms() in
5.1.  It ran fine in 3.4.  (My department has recently upgraded from
Splus 3.4 to 5.1.)  Prof. Ripley finally determined that there is a bug 
in that the trace arg will be ignored unless a Hessian is supplied along
with the function to be minimized.  Thanks again for the help.


The example provided by Prof. Ripley that does work:

  library(MASS, first=T)
  attach(geyser)
  lmix2 <- deriv3(
     ~ -log(p*dnorm((x-u1)/s1)/s1 + (1-p)*dnorm((x-u2)/s2)/s2),
     c("p", "u1", "s1", "u2", "s2"),
     function(x, p, u1, s1, u2, s2) NULL)
  # that takes a while.

  p0 <- c(p=mean(waiting < 70), u1=50, s1=5, u2=80, s2=5)
  tr.ms <- function(info, theta, grad, scale, flags, fit.pars)
  {
    cat(round(info[3], 3), ":", signif(theta), "\n")
    invisible()
  }

  wait.mix2 <- ms(~ lmix2(waiting, p, u1, s1, u2, s2),
     start=p0, data = geyser, trace = tr.ms)


The example I ran in which the trace arg did not work:

  attach(geyser)
  p0 <- c(p=mean(waiting < 70), u1=50, s1=5, u2=80, s2=5)
  tr.ms <- function(info, theta, grad, scale, flags, fit.pars)
  {
    cat(round(info[3], 3), ":", signif(theta), "\n")
    invisible()
  }

  lmix <- function(x,p,u1,s1,u2,s2)
  {
     -log(p*dnorm((x-u1)/s1)/s1 + (1-p)*dnorm((x-u2)/s2)/s2)}
  }

  tmp.mix <- ms(~ lmix(waiting, p, u1, s1, u2, s2),start=p0,
                data = geyser,trace = tr.ms)


On Wed, 8 Sep 1999, Prof Brian D Ripley wrote:

> The answer is that it traces if and only if a Hessian is supplied,
> but not if only the function values or a gradient is supplied. That
> clearly is a bug, so please report it (to bugs@statsci.com).

> My example has a Hessian, your version has only function values.
> I checked: it never calls the trace function, so there is not a
> problem with seeing the output, there just isn't any.


----------------------------------------------------------------------
Original Posting:

Hello,

My question is regarding the trace argument of ms().  My department
recently upgraded from Version 3.4 (HP platform) to Version 5.1
Release 1 for Sun SPARC, SunOS 5.5 : 1999.  I tried running a call to
ms() that worked fine in the previous version.  When trying to run it
in the new version, problems arose.

It turns out the problem was due to the trace argument I was using.  I
was supplying my own function but nothing was being outputted.  I
decided to see if the built-in function trace.ms() would work.  Again,
the trace argument seemed to be completely ignored.  No output was
printed as was expected.  I was under the impression trace.ms would
yield parameter Has anyone encountered any problems using trace in
ms() in version 5.1 or am I missing something?

Again, I had no problems in 3.4.

I'll summarize to the list.

Nicole

______________________________________________________________________________
Nicole DePriest
Statistics Department
The Ohio State University
1958 Neil Ave., #404
Columbus, OH 43210, USA
(614) 292-6038
ntd@stat.mps.ohio-state.edu


-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post