[ADMB Users] 3d ragged array with RE
Mollie Brooks
mbrooks at ufl.edu
Mon Feb 20 13:04:49 PST 2012
Hi,
I'm tying to figure out a way to work around not being able to use a ragged array in my random effects model. I've tried 2 alternatives and run into problems with each.
I had been using an object
3darray varcov(1,nponds,2,nobs,2,nobs)
to store the variance covariance matrix for the observations of all the ponds. nobs is an ivector of length nponds. I got that matrix out as varcov(p).
ALTERNATIVE 1
I tried making a large 3d array that was large enough to cover the various sizes
3darray varcov(1,nponds,2,maxobs,2,maxobs)
To access each submatrix, I tried to use the command varcov(p).sub(2,nobs(p)), but got an error that this is not defined for df1b2 arrays.
ALTERNATIVE 2
Then I tried not defining any varcov array in the parameter section. Instead, in the procedure section, I define
dvar_matrix temp_varcov(2,nobs(p));
calc_temp_varcov(p,temp_varcov); # a function to fill in the values of temp_varcov
The program stops in the middle of calc_temp_varcov without any errors. It stops on the line where I try to store a calculated value in temp_varcov(2,l). See code below. All of the calculations that go into it look fine.
I've also tried the function definition
FUNCTION void calc_temp_varcov(const int & p, dvar_matrix & temp_varcov)
FUNCTION void calc_temp_varcov(const int & p, dvar_matrix temp_varcov)
cout<<"nobs(p)="<<nobs(p)<<endl;
for(int l=2; l<=nobs(p); l++)
{
cout<<pow(rho, 2*column(tk_minus_b(p),2)(obsdates(1,p)+1,obsdates(l,p)))<<endl;
cout<<sum(pow(rho, 2*column(tk_minus_b(p),2)(obsdates(1,p)+1,obsdates(l,p))))<<endl;
temp_varcov(2,l)=sigmaSq*sum(pow(rho, 2*column(tk_minus_b(p),2)(obsdates(1,p)+1,obsdates(l,p))));
cout<<"not ok here"<<endl;
temp_varcov(l,2)=temp_varcov(2,l);
}
Any idea how to make either of these alternatives work? Or any other ideas?
thanks,
Mollie
Mollie Brooks
Ph.D. Candidate
NSF IGERT Fellow
Biology Department
University of Florida
mbrooks at ufl.edu
http://people.biology.ufl.edu/mbrooks
On 8 Feb 2012, at 2:03 PM, Hans J. Skaug wrote:
> Hi,
>
> You can of course use a matrix that is large enough to "cover"
> your ragged if it is fairly homogeneous.
>
> I registered in Redmine again, so I added the issue.
>
> Hans
>
>> -----Original Message-----
>> From: Mollie Brooks [mailto:mbrooks at ufl.edu]
>> Sent: Wednesday, February 08, 2012 7:46 PM
>> To: H. Skaug
>> Cc: ADMB Users
>> Subject: Re: [ADMB Users] 3d ragged array with RE
>>
>> Thanks Hans,
>> I'll try to figure out how to work around it.
>>
>> My redmine account also seems to not be working at the moment. Maybe
>> redmine is broken.
>>
>> Mollie
>>
>>
>> On 8 Feb 2012, at 3:09 AM, H. Skaug wrote:
>>
>>> Hi,
>>>
>>> You are probably right: 3d ragged arrays are not implemented for random
>> effects.
>>> I have never tried, but it would be nice if things works uniformly across the
>>> RE and non-RE versions.
>>>
>>> Can you create a Redmine issue (my account is not working at the moment).
>>>
>>> Hans
>>>
>>>
>>>
>>> On Wed, Feb 8, 2012 at 1:24 AM, Mollie Brooks <mbrooks at ufl.edu> wrote:
>>>> Hi,
>>>> I was running a model without any random effects and it was working fine.
>> Now I need to change it to include random effects.
>>>>
>>>> I'm getting an error on the line where I used to be able to allocate a 3d
>> ragged array.
>>>>
>>>> This is the error
>>>> pond.cpp:765: error: no matching function for call to
>> 'df1b23array::allocate(int, data_int&, int, data_int&, int, data_ivector&, const
>> char [11])'
>>>>
>>>> This is the line in the cpp file
>>>> tk_minus_b.allocate(1,nponds,1,ndays,1,nobs,"tk_minus_b");
>>>>
>>>> This seems to be the line in the tpl file
>>>> 3darray tk_minus_b(1,nponds,1,ndays,1,nobs)//(p,b,k)
>>>>
>>>> nobs is an ivector with length=nponds
>>>>
>>>> Are ragged arrays not available with random effects?
>>>>
>>>> thanks,
>>>> Mollie
>>>>
>>>> Mollie Brooks
>>>> Ph.D. Candidate
>>>> NSF IGERT Fellow
>>>> Biology Department
>>>> University of Florida
>>>> mbrooks at ufl.edu
>>>> http://people.biology.ufl.edu/mbrooks
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at admb-project.org
>>>> http://lists.admb-project.org/mailman/listinfo/users
>>>
>
>
More information about the Users
mailing list