[ADMB Users] spline smoother on selectivity (shorter version)

Luis Ridao luridao at gmail.com
Tue Mar 8 07:42:03 PST 2011


ADMB-help,

Sorry for my previous email (it was sent before I could finish it off)

Following suggestions proposed to my initial request I have modified the code:

DATA_SECTION
....
 init_vector LO(1,nNodes)// SPLINES
 init_vector HI(1,nNodes)
 init_ivector PH(1,nNodes)
 init_vector parm(1,2)

PARAMETER_SECTION
.....
 init_bounded_number_vector log_sel1(1,nNodes,LO,HI,PH)
// SPLINES
 init_bounded_number_vector log_sel2(1,nNodes,LO,HI,PH)
// SPLINES
 init_bounded_number_vector log_sel3(1,nNodes,LO,HI,PH)
// SPLINES
 vector predSel1(1,nages)      // SPLINES
 vector predSel2(1,nages)      // SPLINES
 vector predSel3(1,nages)      // SPLINES

PROCEDURE_SECTION
......
  for (i=1;i<=nyrs;i++)
  {
  if (i<=16)
  {
    vcubic_spline_function qs(nodes,log_sel1,parm(1),parm(2));   // SPLINES
    predSel1.sub(1,9)=qs(ages.sub(1,9));
    predSel1(10)=0;
    predSel1(11)=0;
    predSel1(12)=0;

  }
  else
  {
  if (i<=35)
  {
    vcubic_spline_function qs(nodes,log_sel2,parm(1),parm(2));   // SPLINES
    predSel2.sub(1,9)=qs(ages.sub(1,9));
    predSel2(10)=0;
    predSel2(11)=0;
    predSel2(12)=0;
......
......

And the .dat file looks like:
....
.....
# selection Nodes
 6
# node info
 -15 -15 -15 -15 -15 -15		# lower bound
  15  15  15  15  15  15		# upper bound
   2   2   2   2   2   2		# phase

# derivative at first and last nodes
   0  0


I have run the model with different knots and it works when they are
set to 4, 5, 6, 8 or 9
BUT not for 7 ("Hessian does not appear to be positive definite")
I'm happy with 6 knots (the AIC is lowest for this value)
but I was just wondering why this issue keeps coming up.

The code is attached,
best,
Luis

On Tue, Mar 8, 2011 at 3:31 PM, Luis Ridao <luridao at gmail.com> wrote:
> ADMB-help,
>
> Following suggestions proposed to my initial request I have modified the code:
>
> DATA_SECTION
> ....
>  init_vector LO(1,nNodes)// SPLINES
>  init_vector HI(1,nNodes)
>  init_ivector PH(1,nNodes)
>  init_vector parm(1,2)
>
> PARAMETER_SECTION
> .....
>  init_bounded_number_vector log_sel1(1,nNodes,LO,HI,PH)                // SPLINES
>  init_bounded_number_vector log_sel2(1,nNodes,LO,HI,PH)                // SPLINES
>  init_bounded_number_vector log_sel3(1,nNodes,LO,HI,PH)                // SPLINES
>  vector predSel1(1,nages)      // SPLINES
>  vector predSel2(1,nages)      // SPLINES
>  vector predSel3(1,nages)      // SPLINES
>
> On Tue, Mar 1, 2011 at 12:54 PM, Luis Ridao <luridao at gmail.com> wrote:
>> ADMB-help,
>>
>> Following Dave's suggestion on implementing a spline smoother
>> on selectivity (in a separable catch-at-age model) I managed to
>> do something like:
>>
>> PARAMETER_SECTION
>>   init_vector log_sel1(1,nNodes)        // nNodes = 5 -> (1,2,3,4,5)
>>   init_vector log_sel2(1,nNodes)        // nages = 12 ->
>> (1,2,3,4,5,6,7,8,9,10,11,12)
>>   sdreport_vector predSel1(1,nages)
>>   sdreport_vector predSel2(1,nages)
>>
>> for (i=1;i<=nyrs;i++)
>>   {
>>   if (i<=36)
>>   {
>>     vcubic_spline_function qs(nodes,log_sel1);   // SPLINES
>>     predSel1=qs(ages);
>>
>>   }
>>   else
>>  ......
>>
>> for(i=1;i<=nyrs;i++)
>>   {
>>   if (i<=36)
>>   {
>>   F(i)=mfexp(log_fy(i))*mfexp(predSel1);
>>   }
>>   else
>>   .........
>>
>> The program compiles and runs without problems but when the number of
>> "nodes"
>> are changed to another amount (e.g. 6) ADMB complains about Hessian:
>>
>> "Warning -- Hessian does not appear to be positive definite
>> Hessian does not appear to be positive definite"
>>
>> The model template and data files  are attached
>>
>> Thanks in advance
>>
>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sai09_rm_pt_sr_3sel_9609_spl6.tpl
Type: application/octet-stream
Size: 14699 bytes
Desc: not available
URL: <http://lists.admb-project.org/pipermail/users/attachments/20110308/30ff7353/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sai09_rm_pt_sr_3sel_9609_spl6.dat
Type: application/x-ns-proxy-autoconfig
Size: 18635 bytes
Desc: not available
URL: <http://lists.admb-project.org/pipermail/users/attachments/20110308/30ff7353/attachment.dat>


More information about the Users mailing list