[ADMB Users] indexing with a 3-years-lag
Ben Bolker
bbolker at gmail.com
Tue Dec 7 06:26:41 PST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10-12-07 08:25 AM, Luis Ridao wrote:
> 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)?
>
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-----
More information about the Users
mailing list