[ADMB Users] "xxglobal.tmp" error with tpl2rem

9 views
Skip to first unread message

Bolker,Benjamin Michael

unread,
Aug 4, 2009, 1:09:08 AM8/4/09
to us...@admb-project.org

I'm just beginning to use AD Model Builder.
I have successfully (after some struggles) created a few different
likelihood models, with results matching previous model fits in R.
Now I'm trying to add a random effect. Versions of the TPL file
below compiled OK with tpl2cpp before I added the random effect;
now, with tpl2rem, I'm getting

cat: xxalloc4.tmp: No such file or directory
cat: xxalloc5.tmp: No such file or directory
Error executing command cat xxglobal.tmp xxhtop.tmp header.tmp xxalloc1.tmp xxalloc2.tmp xxalloc3.tmp xxalloc4.tmp xxalloc5.tmp xxtopm.tmp xxalloc6.tmp > mccoypred4.cpp

There was an issue with similar keywords listed on the ADMB site, but it
was listed as "resolved".

I'm running on Ubuntu Linux 9.04, with a recent (?? can't find version number ??)
version of ADMB. (Maybe 9.0.202 from the google code page?)

I'd be happy to provide any other diagnostics/information if that will
help solve / diagnose ...

sincerely
Ben Bolker

-------------------------------------
DATA_SECTION

init_int nobs // # of observations
init_int nblock // # of blocks
init_vector killed(1,nobs) // # killed per trial
init_vector size(1,nobs) // size of individuals
init_vector initial(1,nobs) // starting density (# individuals)
init_matrix Z(1,nobs,1,nblock) // random-effects model matrix

PARAMETER_SECTION

init_number c // *mean* c value
init_number d
init_bounded_number h(0.0,1.0,1)
init_number g
init_bounded_number sigma_c(0.00001,1.0,1)
random_effects_vector u(1,nblock)
vector prob(1,nobs)
vector cvec(1,nobs)
objective_function_value f

PROCEDURE_SECTION
// compute vector of c values
cvec = c + sigma_c*(Z*u)
// power-Ricker
prob = 1/(1/(elem_prod(cvec,elem_prod(pow(size/d,g),exp(-size/d))))+h*initial);
// binomial negative log-likelihood
f -= sum( log_comb(initial,killed)+
elem_prod(killed,log(prob))+
elem_prod(initial-killed,log(1-prob)));
_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users

Steve Martell

unread,
Aug 4, 2009, 11:35:16 AM8/4/09
to Bolker,Benjamin Michael, us...@admb-project.org

Bolker,Benjamin Michael

unread,
Aug 4, 2009, 11:58:45 AM8/4/09
to Steve Martell, us...@admb-project.org

thanks for the quick reply.

no luck, though:

ben@bolker-lap2:~/downloads$ ./admb -r ~/students/mccoy/mccoypred3

*** tpl2rem /home/ben/students/mccoy/mccoypred3


cat: xxalloc4.tmp: No such file or directory

Error executing command cat xxglobal.tmp xxhtop.tmp header.tmp xxalloc1.tmp xxalloc2.tmp xxalloc3.tmp xxalloc4.tmp xxalloc5.tmp xxtopm.tmp xxalloc6.tmp > /home/ben/students/mccoy/mccoypred3.cpp

is there something boneheaded/obviously wrong with the TPL file?
it takes me a long time to recognize such things, being so new to ADMB.

I did find that the simple2.tpl example posted on the google code site, which is
basically a translation of the example in the ADMB-RE manual (taking
"simple.tpl" and adding some measurement error) provokes the same
response. The union.tpl example distributed with ADMB-RE works, but I can provoke the same error
by deleting the following lines from union.tpl:

< PRELIMINARY_CALCS_SECTION
< cout << setprecision(4);
<
< GLOBALS_SECTION
<

Here's simple2.tpl:

DATA_SECTION
init_int nobs
init_vector Y(1,nobs)
init_vector X(1,nobs)
PARAMETER_SECTION
init_number a
init_number b
init_number mu
vector pred_Y(1,nobs)
init_bounded_number sigma_Y(0.000001,10)
init_bounded_number sigma_x(0.000001,10)
random_effects_vector x(1,nobs)
objective_function_value f
PROCEDURE_SECTION // This section is pure C++
f = 0;
pred_Y=a*x+b; // Vectorized operations
// Prior part for random effects x
f += -nobs*log(sigma_x) - 0.5*norm2((x-mu)/sigma_x);
// Likelihood part
f += -nobs*log(sigma_Y) - 0.5*norm2((pred_Y-Y)/sigma_Y);
f += -0.5*norm2((X-x)/0.5);
f *= -1; // ADMB does minimization!


________________________________________
From: Steve Martell [s.ma...@fisheries.ubc.ca]
Sent: Tuesday, August 04, 2009 11:35 AM
To: Bolker,Benjamin Michael
Cc: us...@admb-project.org
Subject: Re: [ADMB Users] "xxglobal.tmp" error with tpl2rem

Ian Taylor

unread,
Aug 4, 2009, 12:28:38 PM8/4/09
to Bolker,Benjamin Michael, us...@admb-project.org
Ben,
I just wanted to note that the error I get with the same platform using admb-9.0.202-linux64-gcc4.2.4 is similar:
cat: xxalloc4.tmp: No such file or directory
cat: xxalloc5.tmp: No such file or directory
Error executing command cat xxglobal.tmp   xxhtop.tmp   header.tmp   xxalloc1.tmp   xxalloc2.tmp   xxalloc3.tmp   xxalloc4.tmp    xxalloc5.tmp    xxtopm.tmp    xxalloc6.tmp > bolker.cpp
I have no experience with ADMB-RE so I can't advise you on problems with the TPL file, but your model does run using tpl2cpp if the RE vector is changed to be an init_vector.
-Ian

Steve Martell

unread,
Aug 4, 2009, 12:36:27 PM8/4/09
to Ian Taylor, us...@admb-project.org
I get the same error message on Mac OS X, but it still seems to compile and run ok.

S.

Steve Martell

unread,
Aug 4, 2009, 12:53:49 PM8/4/09
to Bolker,Benjamin Michael, us...@admb-project.org
This line is causing problems in your other model (mccoypred3.tpl);

prob = 1/(1/(elem_prod(cvec,elem_prod(pow(size/d,g),exp(-size/d))))
+h*initial);

specifically, it does not like "pow(size/d,g)" because there does not
appear to be a function that takes the arguments:
'bolker2.cpp:123: error: no matching function for call to
‘pow(data_vector&, df1b2_init_number&)’

You might want to re-write this function in log-space to get it to
work properly.

dave fournier

unread,
Aug 4, 2009, 3:44:28 PM8/4/09
to us...@admb-project.org
Those are really just diagnostic messages in the Linux version.
So long as the .cpp and .htp files get produced you are OK.
The message should be changed from error to warning. the reason it is
printed is that in the simpler tpl files some of the temporary xx*
files are not produced. Better would be to check for that and react
accordingly or simpler just to produce empty versions of those files.

--
David A. Fournier
P.O. Box 2040,
Sidney, B.C. V8l 3S3
Canada
Phone/FAX 250-655-3364
http://otter-rsch.com

dave fournier

unread,
Aug 4, 2009, 4:35:39 PM8/4/09
to us...@admb-project.org
>This line is causing problems in your other model (mccoypred3.tpl);

>prob = 1/(1/(elem_prod(cvec,elem_prod(pow(size/d,g),exp(-size/d))))
>+h*initial);

>specifically, it does not like "pow(size/d,g)" because there does not
>appear to be a function that takes the arguments:
>'bolker2.cpp:123: error: no matching function for call to
>‘pow(data_vector&, df1b2_init_number&)’

>You might want to re-write this function in log-space to get it to
>work properly.

It is difficult to diagnose these missing function problems if you are
not familiar with the package. A lot of the admb functions were not
extended (yet?) to the RE package. anyway what is missing is the function

df1b2vector pow(const df1b2vector& v,const df1b2variable & x)

Probably the most elegant work around is to define your own
and put it in the GLOBALS_SECTION to make it available.

stick this at the bottom of the tpl file.


GLOBALS_SECTION

#include <admodel.h>
#include <df1b2fun.h>
#include <adrndeff.h>

df1b2vector pow(const df1b2vector& v,const df1b2variable & x)
{
int mmin=v.indexmin();
int mmax=v.indexmax();
df1b2vector tmp(mmin,mmax);
for (int i=mmin;i<=mmax;i++)
{
tmp(i)=pow(v(i),x);
}
return tmp;
}

Also in the version of the program I saw you are missing a ";"
in the line above.

--
David A. Fournier
P.O. Box 2040,
Sidney, B.C. V8l 3S3
Canada
Phone/FAX 250-655-3364
http://otter-rsch.com

Bolker,Benjamin Michael

unread,
Aug 5, 2009, 2:03:14 AM8/5/09
to da...@otter-rsch.com, us...@admb-project.org

Thanks to all of you for your most excellent help ...

Sadly, I need some more.

I implemented Dave's GLOBALS_SECTION below and added the missing semicolon.
Everything now compiles (with lots of warnings of the form
/usr/local/src/admb/include/admodel.h:2256: warning: extra qualification ‘param_init_bounded_matrix_vector::’ on member ‘allocate’
but compiles nonetheless).

Now when I run it the result is ... (drum roll) ...

error reading parameters from file ./mccoypred3.pin

I have traced the error through the C++ code to the point where
it tries to allocate the random effects vector -- here's a code snippet

h.allocate(0.0,1.0,1,"h");
g.allocate("g");
sigma_c.allocate(0.00001,1.0,1,"sigma_c");
cout << "before u.allocate\n"; // BMB added
u.allocate(1,nblock,"u");
cout << "after u.allocate\n"; // BMB added

I have also confirmed that this is where it runs into trouble using gdb,
although I can't seem to step into the "u.allocate" line to see what's going
on within ... nblock seems to be read OK (it is used earlier to define the
bounds of the random effects design matrix Z)

mccoypred3.pin looks like this:

-----------------
# "mccoypred3.pin" produced by pin_write() from ADMButils; Wed Aug 5 01:13:15 2009
# c
0.506685

# d
4.08488

# h
0.008644705

# g
3.019749

# sigma_c
0.1
--------------------

mccoypred3.dat:

# "mccoypred3.dat" produced by dat_write() from ADMButils; Wed Aug 5 01:55:40 2009
# nobs
10

# nblock
6

# killed
3 0 1 3 1 0 1 2 2 2

# size
8.830333 9.155 7.991667 8.000833 8.140333 8.711167 16.5265 14.1508 18.8445 14.87525

# initial
6 6 6 6 6 6 6 6 6 6

# Z
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 1
1 0 0 0 0 0
0 1 0 0 0 0
0 0 1 0 0 0
0 0 0 1 0 0

The parameter section of the tpl file is:

PARAMETER_SECTION

init_number c


init_number d
init_bounded_number h(0.0,1.0,1)
init_number g
init_bounded_number sigma_c(0.00001,1.0,1)
random_effects_vector u(1,nblock)
vector prob(1,nobs)
vector cvec(1,nobs)
objective_function_value f


I have tried the random_effects_vector line both as it appears above and as

random_effects_vector u(1,nblock,1)

to indicate activation in phase 1 and

random_effects_vector u(1,nblock,2)

to indicate activation in phase 2 ...

More suggestions? Probably something else boneheaded here.
As always, suggestions for diagnosis/further information/pointers to relevant locations
in TFM will be appreciated.

I have attached a mini-version of the dat file plus tpl, pin file -- but don't know
if the attachments will make it through to the list or not.

(I feel like I'm burning all the karma accumulated on the R-help list ...)

cheers
Ben Bolker


________________________________________
From: users-...@admb-project.org [users-...@admb-project.org] On Behalf Of dave fournier [ot...@otter-rsch.com]
Sent: Tuesday, August 04, 2009 4:35 PM
To: us...@admb-project.org


Subject: Re: [ADMB Users] "xxglobal.tmp" error with tpl2rem

>This line is causing problems in your other model (mccoypred3.tpl);

mccoypred3.pin
mccoypred3.dat
mccoypred3.tpl

Anders Nielsen

unread,
Aug 5, 2009, 3:31:39 AM8/5/09
to Bolker,Benjamin Michael, us...@admb-project.org, da...@otter-rsch.com
Hi Ben,

It is looking for initial values for the random effects also, so add

# u


0 0 0 0 0 0

or whatever is relevant to your 'mccoypred3.pin' file, and try again.

Cheers,

Anders.

dave fournier

unread,
Aug 5, 2009, 12:00:49 PM8/5/09
to us...@admb-project.org

the easiest way to make a pin file is to run the model with the command
line option

-maxfn 0

and copy the output par file (*.p01) in this case to *.pin and edit it.

On another note your random effects will cause trouble
because cvec can be <0


// compute vector of c values

cvec = c + sigma_c*(Z*u);

// power-Ricker

I think you want something like exp(cvec)
or the admb function mfexp(cvec) which is bounded above for very large
values to help avoid overflow.

prob =
1/(1/(elem_prod(mfexp(cvec),elem_prod(pow(size/d,g),exp(-size/d))))+h*init▒

dave fournier

unread,
Aug 5, 2009, 12:29:05 PM8/5/09
to us...@admb-project.org

OTOH looking at your model code again
my change will allow prob>1 so rather than using exp(cvec) it appears
you will need to transform
prob with something like a logistic to make sense.
Reply all
Reply to author
Forward
0 new messages