[Rd] Bug in nlm, found using sem; failure in several flavors (PR#13881)

2009-08-07 Thread adik
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--1660387551-1458482416-1249639718=:2997
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; FORMAT=flowed
Content-ID: 

Hello,

There appears to be a bug in the nlm function, which I discovered
when trying to run an SEM.  The SEM is not bizarre; the covariance matrix is
solve-able and the eigenvalues are greater than zero, and I do not believe
the "sem" package per se to be the problem (as nlm keeps being the part that
fails, though I can't replicate this with other nlm tasks).  I apologize if
I have put too many much information in this message; I'm not a programmer
by trade so I don't really know what's going on here, which hampers my
ability to write consise bug reports.

Here is the code I use:

library(sem)
ice.S <- read.csv("iceS.csv") # attached
rownames(ice.S) <- ice.S[,1]
ice.S[,1] <- NULL
ice.S <- as.matrix(ice.S)
ice.ram <- specify.model("ice.ram") # attached
ice.N <- 342
ice.sem <- sem(ram=ice.ram, S=ice.S, N=ice.N)

...at this point, any number of problems could occur. I have seen the
following.

1) Simple lack of convergence. (might be my model's fault.)
2) Error in nlm(if (analytic.gradient) objective.2 else objective.1, start,
:
   type 31 is unimplemented in 'type2char'
3)  *** caught segfault ***
address 0xc019c87b, cause 'memory not mapped'

Traceback:
  1: nlm(if (analytic.gradient) objective.2 else objective.1, start,
hessian = TRUE, iterlim = maxiter, print.level = if (debug) 2 else 0,
typsize = typsize, ...)
  2: sem.default(ram = ram, S = S, N = N, param.names = pars, var.names =
vars, fixed.x = fixed.x, debug = debug, ...)
  3: sem(ram = ram, S = S, N = N, param.names = pars, var.names = vars,
fixed.x = fixed.x, debug = debug, ...)
  4: sem.mod(ram = ice.ram, S = ice.S, N = ice.N)
  5: sem(ram = ice.ram, S = ice.S, N = ice.N)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 1
aborting ...
Segmentation fault
swiss:data$

(no core was dumped).

Trying with debug mode provides other interesting errors:

> ice.sem <- sem(ram=ice.ram, S=ice.S, N=ice.N, debug=TRUE)

...gets up to some iteration (not always 15), and then R dies ungracefully,
and exits to the shell:

iteration = 15
Step:
  [1]  1.253132e-02  1.183343e-02 -7.651342e-03 -2.490800e-03  2.278938e-03
  [6]  3.197431e-04  6.137849e-04 -2.496882e-03 -1.065829e-03 -2.118179e-03
[11]  2.942936e-03 -1.335936e-03 -3.665618e-03  3.090566e-03  8.534956e-04
[16] -1.440421e-03 -5.230877e-04 -1.053686e-04 -9.771005e-04 -4.269216e-04
[21]  7.261694e-05 -1.039668e-03 -8.409151e-03 -3.497456e-03  2.216899e-03
[26] -4.633520e-03 -4.052130e-03 -4.746537e-03 -1.589622e-03 -2.523766e-04
Parameter:
  [1] -0.76604614 -1.19639662  0.83456888  0.72540413  0.08482452  0.56180393
  [7]  0.50615814  0.55728015  0.83796696  0.88371335 -0.70465116  0.85251098
[13] -0.18346956  0.66857787  0.57012481  0.39116561  0.91237990  0.63951482
[19]  0.26601566  0.29240836  0.44710919  0.94734056  6.52039015  0.02524762
[25] -0.01614603  2.88198219  0.03442452  3.52272237  1.44698423 -0.72964745
Function Value
[1] -15175.94
Gradient:
  [1] -2.085412e+07 -3.819717e+07  3.883989e+07  1.352594e+00 -4.283329e+00
  [6] -1.437250e+00 -6.558913e-01  1.358276e+00  7.930865e+05 -1.293853e+06
[11] -5.816627e+03  5.908197e+05 -2.705742e+08 -1.194400e+07 -4.007083e+07
[16] -4.143068e+07 -6.159782e-01  1.044274e-01 -8.591048e+00 -2.083471e+00
[21] -7.548753e-01 -5.418994e-01 -2.799228e+02 -1.321739e+07 -3.517728e+07
[26] -7.106654e+02 -7.335293e+06 -7.335285e+05  3.117764e-01 -2.234989e+04

Abort trap
swiss:data$

...I have also seen convergence reached, and nlm then die with this message:

Error in nlm(if (analytic.gradient) objective.2 else objective.1, start,
:
   type 27 is unimplemented in 'type2char'

(similar to above, but now referring to type 27)

I have shown this effect (or something similar...never know how it'll fail
next) on the following platforms:

> version
_ 
platform   i386-apple-darwin9.7.0 
arch   i386 
os darwin9.7.0 
system i386, darwin9.7.0 
status 
major  2 
minor  9.1 
year   2009 
month  06 
day26 
svn rev48839 
language   R 
version.string R version 2.9.1 (2009-06-26)

> sessionInfo()
R version 2.9.1 (2009-06-26) 
i386-apple-darwin9.8.0

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] sem_0.9-17

loaded via a namespace (and not attached):
[1] tcltk_2.9.1 tools_2.9.1

(I admit to having compiled this version of R myself (to link to a
hand-compiled ATLAS), though no errors were thrown in the compilation stage. 
I compiled using this config string, at first...

./con

Re: [Rd] Bug in nlm, found using sem; failure in several flavors (PR#13883)

2009-08-08 Thread adik
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--1660387551-150661043-1249684349=:2997
Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

Hi Jeff,

 =09As mentioned in my message, I *did* replicate on another platform.=20
One platform was running linux in a VM, the other running MacOSX, on two
different physical machines.  The problem did not replicate on a PowerPC
box, so if it is a bug with intel chips, I think it's also appropriate to
report here given that the problem seems to cross the OS boundary.  I do no=
t
have access to a Windows machine.

 =09Also, I have spent a decent amount of time running memory testers on
the first machine's memory, to ensure that physical memory is not a
problem...the classic "memcheck" program finds no trouble.

 =09The CSV and .ram files both came through as base-64-encoded
attachments, which you actually quoted back to me in your response,
below...but in case your mail client can't read those and/or you are
interested in this bug, I have pasted them at the end of this message (sinc=
e
they're quite small).

 =09And thanks for the shout-out for bacon. I bought this domain name in
undergrad many years ago, and I must say, I've never regretted it!

--Adam

On Fri, 7 Aug 2009, Jeff Ryan wrote:

> Adam,
>
> It seems that your attachment didn't make it through.
>
> That aside, my experience with strange errors like those (random type
> not implemented ones) has been that you may be looking at a memory
> problem on you machine. Given that you can't replicate on another
> platform (and the .csv file didn't come through), I would think it
> wise to start there.
>
> My 2c.  And I love bacon too :)
>
> Jeff
>
> On Fri, Aug 7, 2009 at 1:10 PM,  wrote:
>> =A0This message is in MIME format. =A0The first part should be readable =
text,
>> =A0while the remaining parts are likely unreadable without MIME-aware to=
ols.
>>
>> --1660387551-1458482416-1249639718=3D:2997
>> Content-Type: TEXT/PLAIN; CHARSET=3DUS-ASCII; FORMAT=3Dflowed
>> Content-ID: 
>>
>> Hello,
>>
>> =A0 =A0 =A0 =A0There appears to be a bug in the nlm function, which I di=
scovered
>> when trying to run an SEM. =A0The SEM is not bizarre; the covariance mat=
rix is
>> solve-able and the eigenvalues are greater than zero, and I do not belie=
ve
>> the "sem" package per se to be the problem (as nlm keeps being the part =
that
>> fails, though I can't replicate this with other nlm tasks). =A0I apologi=
ze if
>> I have put too many much information in this message; I'm not a programm=
er
>> by trade so I don't really know what's going on here, which hampers my
>> ability to write consise bug reports.
>>
>> Here is the code I use:
>>
>> library(sem)
>> ice.S <- read.csv("iceS.csv") # attached
>> rownames(ice.S) <- ice.S[,1]
>> ice.S[,1] <- NULL
>> ice.S <- as.matrix(ice.S)
>> ice.ram <- specify.model("ice.ram") # attached
>> ice.N <- 342
>> ice.sem <- sem(ram=3Dice.ram, S=3Dice.S, N=3Dice.N)
>>
>> ...at this point, any number of problems could occur. I have seen the
>> following.
>>
>> 1) Simple lack of convergence. (might be my model's fault.)
>> 2) Error in nlm(if (analytic.gradient) objective.2 else objective.1, sta=
rt,
>> :
>> =A0 type 31 is unimplemented in 'type2char'
>> 3) =A0*** caught segfault ***
>> address 0xc019c87b, cause 'memory not mapped'
>>
>> Traceback:
>> =A01: nlm(if (analytic.gradient) objective.2 else objective.1, start,
>> hessian =3D TRUE, iterlim =3D maxiter, print.level =3D if (debug) 2 else=
 0,
>> typsize =3D typsize, ...)
>> =A02: sem.default(ram =3D ram, S =3D S, N =3D N, param.names =3D pars, v=
ar.names =3D
>> vars, =A0 =A0 fixed.x =3D fixed.x, debug =3D debug, ...)
>> =A03: sem(ram =3D ram, S =3D S, N =3D N, param.names =3D pars, var.names=
 =3D vars,
>> fixed.x =3D fixed.x, debug =3D debug, ...)
>> =A04: sem.mod(ram =3D ice.ram, S =3D ice.S, N =3D ice.N)
>> =A05: sem(ram =3D ice.ram, S =3D ice.S, N =3D ice.N)
>>
>> Possible actions:
>> 1: abort (with core dump, if enabled)
>> 2: normal R exit
>> 3: exit R without saving workspace
>> 4: exit R saving workspace
>> Selection: 1
>> aborting ...
>> Segmentation fault
>> swiss:data$
>>
>> (no core was dumped).
>>
>> Trying with debug mode provides other interesting errors:
>>
>>> ice.sem <- sem(ram=3Dice.ram, S=3Dice.S, N=3Dice.N, debug=3DTRUE)
>>
>> ...gets up to some iteration (not always 15), and then R dies ungraceful=
ly,
>> and exits to the shell:
>>
>> iteration =3D 15
>> Step:
>> =A0[1] =A01.253132e-02 =A01.183343e-02 -7.651342e-03 -2.490800e-03 =A02.=
278938e-03
>> =A0[6] =A03.197431e-04 =A06.137849e-04 -2.496882e-03 -1.065829e-03 -2.11=
8179e-03
>> [11] =A02.942936e-03 -1.335936e-03 -3.665618e-03 =A03.090566e-03 =A08.53=
4956e-04
>> [16] -1.440421e-03 -5.230877e-04 -1.053686e-04 -9.771005e-04 -4.269216e-=
04
>> [21] =A07.261694e-05 -1.039668e-03 -8.409151e-03 -3.497456e-03 =A02.2168=

[Rd] Configure errors say to report here... (PR#11470)

2008-05-16 Thread adik
Hi,

I'm attempting to compile R 2.7.0 on my G5, which is running OSX
10.5.2. Yes, I know there is a precompiled binary, but my experience has
shown that if I hand-compile ATLAS on my machine and then link R against it
when compiling, R runs faster, hence me compiling it myself.

Anyway, I have this set of errors:

checking X11/Intrinsic.h usability... no
checking X11/Intrinsic.h presence... yes
configure: WARNING: X11/Intrinsic.h: present but cannot be compiled
configure: WARNING: X11/Intrinsic.h: check for missing prerequisite headers?
configure: WARNING: X11/Intrinsic.h: see the Autoconf documentation
configure: WARNING: X11/Intrinsic.h: section "Present But Cannot Be 
Compiled"
configure: WARNING: X11/Intrinsic.h: proceeding with the preprocessor's result 
configure: WARNING: X11/Intrinsic.h: in the future, the compiler will take 
precedence
configure: WARNING: ## --- ##
configure: WARNING: ## Report this to [EMAIL PROTECTED] ##
configure: WARNING: ## --- ##
...
checking X11/Xmu/Atoms.h usability... no
checking X11/Xmu/Atoms.h presence... yes
configure: WARNING: X11/Xmu/Atoms.h: present but cannot be compiled
configure: WARNING: X11/Xmu/Atoms.h: check for missing prerequisite headers?
configure: WARNING: X11/Xmu/Atoms.h: see the Autoconf documentation
configure: WARNING: X11/Xmu/Atoms.h: section "Present But Cannot Be 
Compiled"
configure: WARNING: X11/Xmu/Atoms.h: proceeding with the preprocessor's result
configure: WARNING: X11/Xmu/Atoms.h: in the future, the compiler will take 
precedence
configure: WARNING: ## --- ##
configure: WARNING: ## Report this to [EMAIL PROTECTED] ##
configure: WARNING: ## --- ##
...
checking tk.h usability... no
checking tk.h presence... yes
configure: WARNING: tk.h: present but cannot be compiled
configure: WARNING: tk.h: check for missing prerequisite headers?
configure: WARNING: tk.h: see the Autoconf documentation
configure: WARNING: tk.h: section "Present But Cannot Be Compiled"
configure: WARNING: tk.h: proceeding with the preprocessor's result
configure: WARNING: tk.h: in the future, the compiler will take precedence
configure: WARNING: ## --- ##
configure: WARNING: ## Report this to [EMAIL PROTECTED] ##
configure: WARNING: ## --- ##

...the command line item I pass to configure is this:

feta:R-2.7.0> ./configure --prefix=/usr/local --with-x --without-R-framework 
--without-aqua --with-blas="/usr/local/lib/libptf77blas.a 
/usr/local/lib/libatlas.a" --with-lapack="/usr/local/lib/liblapack.a 
/usr/local/lib/libptf77blas.a /usr/local/lib/libatlas.a" CFLAGS="-maltivec 
-mabi=altivec -mtune=970 -faltivec -O3" CXXFLAGS="-maltivec -mabi=altivec 
-mtune=970 -faltivec -O3"

...the rest of configure completes fine, though when I try to build R, I
make eventually ends up failing in this manner:

gcc -std=gnu99 -I. -I../../src/include -I../../src/include -I/sw/include
-I/usr/
local/include -DHAVE_CONFIG_H   -fPIC  -maltivec -mabi=altivec -mtune=970
-falti
vec -O3 -c cpoly.c -o cpoly.o
cpoly.c: In function 'fxshft':
cpoly.c:299: error: expected identifier or '(' before 'unsigned'
cpoly.c:310: error: 'test' undeclared (first use in this function)
cpoly.c:310: error: (Each undeclared identifier is reported only once
cpoly.c:310: error: for each function it appears in.)
cpoly.c:315: error: expected expression before '__attribute__'
cpoly.c:326: error: expected expression before '__attribute__'
cpoly.c:327: error: expected expression before '__attribute__'
cpoly.c:334: error: expected expression before '__attribute__'
cpoly.c:370: error: expected expression before '__attribute__'
cpoly.c: In function 'vrshft':
cpoly.c:394: error: two or more data types in declaration specifiers
cpoly.c:394: error: expected identifier or '(' before ',' token
cpoly.c:399: error: 'b' undeclared (first use in this function)
cpoly.c:439: error: expected expression before '__attribute__'
cpoly.c:440: error: expected expression before '__attribute__'
cpoly.c:459: error: expected expression before '__attribute__'
cpoly.c:460: error: expected expression before '__attribute__'
cpoly.c:461: error: expected expression before '__attribute__'
cpoly.c:462: error: expected expression before '__attribute__'
cpoly.c: At top level:
cpoly.c:476: error: expected ';', ',' or ')' before 'unsigned'
cpoly.c:498: error: two or more data types in declaration specifiers
cpoly.c:498: error: conflicting types for 'nexth'
cpoly.c:81: error: previous declaration of 'nexth' was here
cpoly.c: In function 'nexth':
cpoly.c:498: error: parameter name omitted
cpoly.c:506: error: expected expression before '__attribute__'
make[3]: *** [cpoly.o] Error 1
make[2]: *** [R] Error 2
make[1]: *** [R] Error 1
make: *** [R] Error 1

...the one reference to a problem like this I could find v