# Modelling a large time series dataset in R, any insight?

I am hoping someone out there can help me with some statistics as I am relatively new to coding. I have a large dataset which I want to model appropriately to answer some key biological questions. I am looking at whale shark scarring over a 9-year time frame in three populations in the Indian Ocean and the questions I want to ask are:

1. Does the distribution of animals in each scarring category (location/ age/ cause/ type) differ between aggregations?

2. Does the distribution of animals in each scarring category (location/ age/ cause/ type) change over time within an aggregation?

3. Do population demographics (size/sex) influence the distribution of animals in each scarring category (location/ age/ cause/ type)?

Each year has a number of known individuals who have scarring information associated with them. This presents difficulties for question one as individuals can show up more than once, making some years dependent on others. One way to overcome this would be to only model new sharks or old sharks with new injuries.

• Dependent variables: (1) Severity - Maj scar Yes/No Binary. (2) Type – Categorical (3) Location on body – Categorical. (4) Cause – Categorical.

• Samples: 997 individuals grouped in three aggregations (Djibouti, Seychelles, Maldives)

• Independent variables: Year, Sex, Size

Sample data:

 ID     Location    Year  Severity  Age     Type    Location  Cause  Sex
WS000   Maldives    2009    x        x        x         x       x     U
WS004   Maldives    2009   Min     Healed  Abrasion   Dorsal    x     M
WS005   Maldives    2009    x        x        x         x       x     M
WS006   Maldives    2009   Min     Healed  Undefined  Caudal    x     M
WS010   Maldives    2009   Min     Fresh   Abrasion   Caudal    x     M


Does anyone have any insight as to which approach I should take for each question?

EDITED:

To move further I will give a little more of a description and explain what I hope to achieve.

So, I will be working from two datasets. For one I have removed all duplicate sightings of individuals keeping only the most major injury. I aim to use this to make comparisons between 'Aggregations' using individuals sighted in the 9 year time frame. For the other I have removed all duplicate sightings of scars so that I can make comparisons within aggregations over time. I think making these adjustments makes my data far more manageable and removes confounding in both instances.

My data set will look like this (example of the one with duplicate scars removed):

ID             Aggregation  Year Severity Age     Type   Location   Cause Sex Size Number
dji.2003.003    Djibouti    2012    0   Healed  Amputation 2nd Dorsal       M   6   2
dji.2003.003    Djibouti    2013    1   Fresh   Laceration   Head     Boat  M   6   4
dji.2003.011    Djibouti    2009    1   Healed  Laceration  Caudal    Boat  M   4   1
dji.2004.003    Djibouti    2009    0   Healed  Abrasion    Caudal          M   4.5 1
dji.2004.003    Djibouti    2010    1   Healed  Laceration  Flank     Boat  M   4.5 4
dji.2004.003    Djibouti    2011    0   Healed  Deformity   Pectoral        M   4   1
dji.2004.003    Djibouti    2012    0   Healed  Abrasion    Head            M   4.5 4
dji.2004.005    Djibouti    2009    0   Healed  Laceration  Head      Boat  M   4   3
dji.2004.005    Djibouti    2010    0   Healed  Nick        Caudal          M   4   3
dji.2004.005    Djibouti    2014    0   Healed  Abrasion    Caudal          M   4   4
dji.2004.012    Djibouti    2010    0                                       M   3.5 0
dji.2004.012    Djibouti    2011    0   Healed  Abrasion    Flank           M   4.5 4
dji.2004.012    Djibouti    2012    1   Healed  Amputation  Caudal    Bite  M   5   4
dji.2004.012    Djibouti    2013    0   Healed  Bite        Caudal    Bite  M   4   1
dji.2004.016    Djibouti    2009    0   Healed  Undefined   Caudal          M   3.5 2
dji.2004.016    Djibouti    2013    0   Healed  Bite       Pectoral   Bite  M   4.5 4
dji.2004.018    Djibouti    2012    0                                       M   6   0
dji.2004.020    Djibouti    2009    0   Healed  Abrasion    1st Dorsal      M   6   4
dji.2004.020    Djibouti    2010    0   Healed  Abrasion    Caudal    Boat  M   4.5 4
dji.2004.020    Djibouti    2011    0   Healed  Deformity   Caudal          M   4.5 2
dji.2004.020    Djibouti    2012    0   Healed  Deformity   Caudal          M   4.5 4
dji.2004.020    Djibouti    2014    0   Healed  Nick        Caudal          M   3.5 4


To clarify:

Aggregation - Which population the shark is from
Age - Age of the injury, 2 levels healed or fresh
Severity - Binary response: 1- Major scar, 0- Min scar or no scar
Size - Estimated size of the individual
Number - Number of injuries

So, for the comparison between Aggregation sites what tests can I perform to see if there are differences in scarring patterns?

Then for my other data set I want to look at what factors influence scarring and do scarring patterns change over time. How can I model this? Mixed effect generalized linear model with an 'Individual ID' random effect? I am a bit stumped here.

Thanks again!

## migrated from stackoverflow.comMay 26 '17 at 19:18

This question came from our site for professional and enthusiast programmers.

• Not sure which is the difference with your other question. Anyway, great to see statistics being used to study whale sharks :) what about getting in touch with the Statistics department of your university? That would be probably the best way to ensure that your analysis is executed correctly. Also, can you keep track of each individual across the years? It may make more sense to have 997 time series of sample size at most 9. BTW, why whale sharks get so many scars? I would have thought the biggest fish to be relatively safe from aggression. Are they scars from boat propellers? – DeltaIV May 27 '17 at 21:00
• Thanks for your reply @DeltaIV. Yes, the majority of scarring is vessel induced. I will try and seek help from th stats team here, but I fear this is a tricky dataset to model. Can you explain what you mean by '997 time series of sample size at most 9'. Thanks again! – Freya Womersley Jun 14 '17 at 15:32
• You're welcome! After all this time I forgot about the question :) I wouldn't worry too much about the trickiness of the dataset (let the statisticians worry about that, I can tell you by personal experience they'll be delighted :) A more serious concern could be that you're asking too many questions for just one data set $S$, where moreover most variables are categorical/ordinal (which contain less information than continuous variables). If you run a lot of tests on the same $S$, the chance to find a significant result when all nulls are true increases: this the problem of ctd... – DeltaIV Jun 16 '17 at 8:09
• ...ctd multiple comparisons. If you want to know more,start from here and follow indications therein. Concerning the '997/9' I will explain, but can you please answer a few questions before? 1. What are the definitions of Size and Age? Note that Size is mentioned in the question but absent in your data set. Also, if Location and Aggregation are actually the same variable, please use just one term everywhere. 2. Does the x mean a missing value for the variable? 3. Cause is always x in your mini-data set. We can't ctd... – DeltaIV Jun 16 '17 at 9:18
• ...ctd make any educated guess about the distribution of Cause this way. Please include a much bigger data set, possibly with measurements for all years for a few individuals. For example, 10 individuals measured for at most 9 years gives a data set of at most 90 rows (and 10 columns, if I understood correctly what is your list of variables). – DeltaIV Jun 16 '17 at 9:22