time saver, how to organize your occasion history

questions concerning analysis/theory using program MARK

time saver, how to organize your occasion history

Postby hpdutra » Sat Aug 02, 2008 7:11 pm

Chapter 2 of gentle introduction says that it is better to organize your encounter history as
1000 2 1;
1011 1 3;

instead of
1000 1 0;
1000 1 0;
1000 0 1;
1011 1 0;
1011 0 1;
1011 0 1;
1011 0 1;

especially for large data sets. Well in my case I already had a huge encounter history for each individual, and I did not want to create a huge formula in excel.
If you know how to use R here is an easy way of doing it using the package "reshape"

http://www.nabble.com/RESHAPE-package-q ... #a18794249

You still have to export to excel and remove the ID column and transform it into INP, but boy this saves time! :)
hpdutra
 
Posts: 5
Joined: Mon Jun 09, 2008 2:30 am

Re: time saver, how to organize your occasion history

Postby cooch » Sat Aug 02, 2008 8:45 pm

hpdutra wrote:Chapter 2 of gentle introduction says that it is better to organize your encounter history as
1000 2 1;
1011 1 3;

instead of
1000 1 0;
1000 1 0;
1000 0 1;
1011 1 0;
1011 0 1;
1011 0 1;
1011 0 1;

especially for large data sets.


Not quite - the summarized format has some efficiencies - especially for large datasets, but precludes use of individual covariates. In most cases, there is little lost by using individual encounter histories (rather than summarizing over histories), but doing such a summarization is easy enough...

Well in my case I already had a huge encounter history for each individual, and I did not want to create a huge formula in excel.
If you know how to use R here is an easy way of doing it using the package "reshape"

http://www.nabble.com/RESHAPE-package-q ... #a18794249

You still have to export to excel and remove the ID column and transform it into INP, but boy this saves time! :)


Useful tip. You can do the same in SAS in a couple of lines (actually, one call to PROC MEANS). In fact, any of the semi-standard data manipulation tools can handle this sort of thing easily, which is why MARK doesn't have its own database capabilities - they would be redundant to what is already sitting on the desks of most folks.
cooch
 
Posts: 1654
Joined: Thu May 15, 2003 4:11 pm
Location: Cornell University

Postby hpdutra » Sat Aug 02, 2008 10:37 pm

Hi Evan
I actually know how to do that in SAS, but I don't have that at home. So figuring that out in R was great. I am going to quote you "you can't beat the price of R"
hpdutra
 
Posts: 5
Joined: Mon Jun 09, 2008 2:30 am

Re: R time saver for condensing encounter histories

Postby dhewitt » Mon Aug 04, 2008 12:09 pm

There was some confusion in the thread over at R-help. For folks looking to use this handy shortcut, I posted a clarification. It's simple to do with the 'recast' wrapper that Hadley provides. Note that this particular usage won't create the proper format for more than 2 groups. And, as Evan pointed out, you'll often want covariates so the condensed format won't be the right way to go. But, here it is:

http://www.nabble.com/Re%3A-RE-SHAPE-pa ... 14133.html
dhewitt
 
Posts: 150
Joined: Tue Nov 06, 2007 12:35 pm
Location: Fairhope, AL 36532


Return to analysis help

Who is online

Users browsing this forum: No registered users and 0 guests