R-alpha: lines, nlm, save and suggestions

Philippe Lambert (phlamber@luc.ac.be)
Mon, 25 Nov 1996 00:42:09 +0100 (MET)


From: Philippe Lambert <phlamber@luc.ac.be>
Message-Id: <9611242342.AA07096@alpha.luc.ac.be>
Subject: R-alpha: lines, nlm, save and suggestions
To: r-testers@stat.math.ethz.ch
Date: Mon, 25 Nov 1996 00:42:09 +0100 (MET)

Part 1: problem with the LINES instructions
======

Here is an example of a line command that leads to a break down of
my X Window server:

> x <- 1:50
> y <- 0.0001*x
> z <- NULL
> x
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
[26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
> y
 [1] 0.0001 0.0002 0.0003 0.0004 0.0005 0.0006 0.0007 0.0008 0.0009 0.0010
[11] 0.0011 0.0012 0.0013 0.0014 0.0015 0.0016 0.0017 0.0018 0.0019 0.0020
[21] 0.0021 0.0022 0.0023 0.0024 0.0025 0.0026 0.0027 0.0028 0.0029 0.0030
[31] 0.0031 0.0032 0.0033 0.0034 0.0035 0.0036 0.0037 0.0038 0.0039 0.0040
[41] 0.0041 0.0042 0.0043 0.0044 0.0045 0.0046 0.0047 0.0048 0.0049 0.0050
> z
NULL

> plot(x,y)
> lines(x,z,lty=4)


leads to the error message


XFree86 Version 3.1.2 / X Window System
(protocol Version 11, revision 0, vendor release 6000)
Operating System: Linux 
Configured drivers:
  S3: accelerated server for S3 graphics adaptors (Patchlevel 0)
      mmio_928, s3_generic
(using VT number 7)

Fatal server error:
Caught signal 8.  Server aborting

X connection to :0.0 broken (explicit kill or server shutdown).
X connection to :0.0 broken (explicit kill or server shutdown).
xterm-1:  fatal IO error 2 (Broken pipe) or KillClient on X server ":0.0"
xinit:  connection to X server lost.


Note that a NULL vector as a second argument in the lines instruction just
leads to a 45 degree line. Here, LINES does indeed starts drawing this line,
but seems to eventually fail because the y-axis covers small values.
Indeed, simply defining
    > z <- 0.1*x
works fine.

Unfortunately, I was not able to reproduce this error when not specifying
LTY=4. But the above example always leads to a fatal server error on my
system(Linux ELF 1.2.13 with XFree86 3.1.2).

Part 2: suggestions for improving the optimization routine NLM
======

In one of my last message, I mentioned that the GAUSS optimization
routine turns out to be very flexible in practice. By flexibility, I
not only mean that it allows the specification of the gradiant and of
the hessian, but also that it automatically selects another
optimization algorithm or (and) uses another method to determine the
step length when problems occur in the optimization process.

The implemented algorithms are:
- steepest descent (naive and simple: H=identity; usually used to locate
the minimum region before a switch to a more efficient method)
- Newton-Raphson method (when the problem is well behaved: computationally
intensive when the number of parameters is large)
- Broyden, Fletcher, Goldfarb, shanno algorithm 
    and 
  Davidon, Fletcher, Powell method (quasi-Newton method: approximation of H).
- Polak-Ribiere conjugate gradiant method (interesting when many parameters;
does not require H).

The step choice methods are:
- step length=1
- cubic or quadratic step length method (similar to Dennis and Schnabel, as
used in NLM).
- Brent's step length method (or golden section method; Brent, 1972)
- step halving

Here are the main references in the GAUSS manual for PROC OPTUM:
- Brent, R.P (1972) Algorithms for minimization without derivatives.
Englewood Cliffs, NJ: Prentice-Hall.
- Fletcher, R. and Powell, M. (1963) A rapidly convergent descent method
for minimization. The Computer Journal 6: 163-168.
- Gill, P.E. and Murray, W. (1972) Quasi-NEwton methods for unconstrained 
optimization. J.Inst.Math.Appl. 9: 91-108.

This might suggest further developments in NLM.

Part 3: function save
======

save(z0,z1,z2,z3,z4,file="fit.sav",ascii=TRUE)
save(z0,z1,z2,z3,z4,file="fit2.sav",ascii=FALSE)

(where the zi's are some lists)

yields a larger binary file!!!??

$ ls -l fit.sav
-rw-r--r--   1 plambert users       37231 Nov 24 22:41 fit.sav
$ ls -l fit2.sav
-rw-r--r--   1 plambert users       37713 Nov 24 22:44 fit2.sav


Part 4: a last suggestion
======

Do you think that it would be a good idea to add a subdirectory on
each mirror containing user-contributed R (and compatible S) functions
(with possibly a further subdirectory where one can upload code at an
"alpha" stage)? I do not know how much work maintaining such sites
would require.


	Philippe Lambert
	phlamber@luc.ac.be

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- For info or help, send "info" or "help",
To [un]subscribe, send "[un]subscribe"
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-