[ADMB Users] 3d ragged array with RE

62 views
Skip to first unread message

Mollie Brooks

unread,
Feb 7, 2012, 7:24:26 PM2/7/12
to ADMB Users
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
mbr...@ufl.edu
http://people.biology.ufl.edu/mbrooks


_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users

H. Skaug

unread,
Feb 8, 2012, 3:09:37 AM2/8/12
to Mollie Brooks, ADMB Users
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

Mollie Brooks

unread,
Feb 8, 2012, 1:45:52 PM2/8/12
to H. Skaug, ADMB Users
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

John Sibert

unread,
Feb 8, 2012, 4:51:00 PM2/8/12
to Mollie Brooks, ADMB Users
I'm guessing that the appropriate allocate functions was never written.
It should be fairly straightforward to modify the allocate function for
a non-ragged 3d array.

There were some problems with the redmine server. Johnoel set up an
alternative, but all the accounts were lost. I think you have to request
a membership or something.

John

--
John Sibert
Emeritus Researcher, SOEST
University of Hawaii at Manoa

Visit the ADMB project http://admb-project.org/

Mollie Brooks

unread,
Feb 20, 2012, 4:04:49 PM2/20/12
to users@admb-project.org Users
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
mbr...@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

Mollie Brooks

unread,
Feb 20, 2012, 11:56:09 PM2/20/12
to Mollie Brooks, users@admb-project.org Users
Sorry for wasting your time.
Weihai Liu found my mistake. I was missing the column indices in my matrix definition dvar_matrix temp_varcov(2,nobs(p));

Mollie

Reply all
Reply to author
Forward
0 new messages