occasion data merge.design.covariates

posts related to the RMark library, which may not be of general interest to users of 'classic' MARK

occasion data merge.design.covariates

Postby stellatus » Mon Feb 14, 2011 7:09 pm

Hello,

I'm having a problem merging occasion specific data with my design data.

I'm working with the robust design and my data consist of six primary sessions of 8,7,6,8,7 and 7 days in length. I want to assign temperature (min, max and avg) as time specific covariates to "p" and "c" for each sampling occasion. In the design data list the values under the "time" field for p are not unique numbers, but start again from 1 for each primary session: i.e. 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,1... and so on for the 43 occasions. This is my code so far:

dat<-import.chdata(filename="pinks_all_covar2.txt",header=T)
int<-read.table(file="int.txt,header=F)
process1<-process.data(dat,model="Robust",begin.time=1,time.intervals=int)
mdd1<-make.design.data(process1)
temp<-read.table(file="temp.txt",header=T)
ptime<-mdd1$p$time
avgtemp<-data.frame(time=ptime,avgtemp=temp[,1])

So I've taken the times directly from mdd1$p$time so that the time field in the new data frame matches the time field in the design data list. However when I attempt the merge with the following code, I get an error message:

mdd1$p<-merge.design.covariates(mdd1$p,avgtemp,bygroup=FALSE,bytime=TRUE)

Error in 'row.names<-.data.frame'('*tmp*',value=c("1","2","3","4",: invalid 'row.names' length

There was no problem with creating the avgtemp data frame, both fields had 43 values. In the dipper example there are seven unique occasions and seven values for effort assigned. In my case each sampling occasion is a unique time, but the mdd1$p$time field has repeated numbers for each session. I'm not sure if this has something to do with the error?

Any help will be much appreciated,

Annabel.
stellatus
 
Posts: 12
Joined: Sun Feb 13, 2011 9:28 pm

Re: occasion data merge.design.covariates

Postby jlaake » Tue Feb 15, 2011 12:09 pm

That function was not written for the robust design structure. What you want to use is session rather than time. You can code something similar or trick the code by renaming your columns such that session becomes time and time becomes something else. Then run merge.design.covariates and finally rename the column names back to their original names.

--jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: occasion data merge.design.covariates

Postby stellatus » Tue Feb 15, 2011 10:02 pm

Thanks very much Jeff,

Renaming the session column didn't work, I think because the values in that were 1,1,1,1,1,1,1,1,2,2,2... and so on (I got the same error message as above). So I made a new column and called it "time" with the values 1:43. This is working now.

Cheers,
Annabel
stellatus
 
Posts: 12
Joined: Sun Feb 13, 2011 9:28 pm

Re: occasion data merge.design.covariates

Postby jlaake » Tue Feb 15, 2011 10:18 pm

I didn't realize that it was secondary occasion-specific. So if I understand correctly, there are 43 occasions and the average temp is different on each occasion. In that case, what you did was the only solution. Just realize that now if you use ~time it will have 43 values instead of its original number of occasions. --jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA

Re: occasion data merge.design.covariates

Postby stellatus » Tue Feb 15, 2011 10:43 pm

Yep, that's right, my temperature data is secondary occasion specific - I have 43 different temperature readings for each occasion.

After merging my temperature data, I have gave my new time column a different name "time_new" and changed the original time column back to "time".

But I guess ~time isn't meaningful for my analysis because the first occasion in primary session one has nothing to do with the first occasion in primary session two etc. (but they have the same value). ~time_new and ~session are probably more meaningful.

Thanks again for you help,
Annabel :)
stellatus
 
Posts: 12
Joined: Sun Feb 13, 2011 9:28 pm

Re: occasion data merge.design.covariates

Postby jlaake » Tue Feb 15, 2011 10:49 pm

You are catching on quickly. This thread is a good example to show that design data are what you want them to be for your specific problem. RMark creates a set of default design data for each specific type of model but beyond that you are free to add,delete or re-define any and all of the columns of the design data. The only thing you should never do is to sort the rows of the design data because that would misalign the design data with the PIMS.

regards --jeff
jlaake
 
Posts: 1479
Joined: Fri May 12, 2006 12:50 pm
Location: Escondido, CA


Return to RMark

Who is online

Users browsing this forum: No registered users and 2 guests