[ADMB Users] indexing with a 3-years-lag

24 views
Skip to first unread message

Luis Ridao

unread,
Dec 7, 2010, 8:25:44 AM12/7/10
to us...@admb-project.org
ADMB-users,

I'm having problems to fit a ssb-rec Ricker curve.
The problem is with the rec array indexing.
Recruitment strength is measured at age 3 so what I do is to create
two extras arrays holding the ssb-rec pairs with a 3-yrs lag.
I thought this solution would make it easier but I get the following
error:

LRC $ ./catage6109_rec_mod_surv_ric
ok to here
Incompatible bounds in dvar_vector& dvar_vector::operator = (_CONST dvar_vector& t)

Snipet of the tpl file:

nyrs=49
.......................
  sdreport_vector ssb(1,nyrs)
  sdreport_vector ssb_m3(1,nyrs-3)      // SAME AS SSB with dimension (1,46)
  sdreport_vector rec(1,nyrs)
  sdreport_vector rec_m3(1,nyrs-3)      // SAME AS REC with dimension (1,46)
  sdreport_vector pred_rec(1,nyrs)
  sdreport_vector pred_rec_m3(1,nyrs-3)    // SAME AS PRED_REC with dimension (1,46)
.........................

FUNCTION ssb_rec_ricker
  ssb=rowsum(elem_prod(elem_prod(N,weight_at_age),mat_at_age))/1000;
  ssb_m3=ssb.sub(1,46);
  rec=column(N,1)/1000;
  cout<<"ok to here"<<endl;          // HERE IS THE
  rec_m3=rec.sub(3,49);              // PROBLEM

  for (int i=1;i<=nyrs-3;i++)
  {
  pred_rec_m3(i)=exp(log_alfa)*ssb_m3(i)*exp(-exp(log_beta)*ssb_m3(i));
  } 

............................

The valid index for rec is (1,49)
Why can't I subset it to (3,49)?

Thanks in advance,
Luis

dave fournier

unread,
Dec 7, 2010, 3:12:04 AM12/7/10
to us...@admb-project.org
Look at the valid indices for rec_m3.

Try

rec_m3=rec.sub(3,49).shift(1);
_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users

Ben Bolker

unread,
Dec 7, 2010, 9:26:41 AM12/7/10
to us...@admb-project.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I think your problem may be that rec.sub(3,49) should be 47 elements
long, but the vector you have allocated is only 46 long ... ?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz+RCEACgkQc5UpGjwzenNSXACeK0LuOXreHDgPxz5/zKmydJcR
oD8AnjlSGLDqFmO7ymMAVnpuzsa96DpZ
=B90p
-----END PGP SIGNATURE-----

dave fournier

unread,
Dec 7, 2010, 7:00:47 PM12/7/10
to us...@admb-project.org
Well you still need the shift(1), but you are right you must be able to
count
as well.
Reply all
Reply to author
Forward
0 new messages