I have time series data over an 8hour period of animals displaying behaviors.

The behavior being displayed by a particular animal is notated as numbers 1-9, with a number corresponding to a given behavior. These are insects and they can only display one feeding behavior at a time.

The most common behavior for each point in time (i.e. mode or most frequent behavior/number at each second from 0s to 28,800s) was calculated and this data was visualized to get a good representation of how the behavior is changing between treatments groups.

After visualizing the data, it was clear that for one treatment, a particular behavior is less common at certain times compared to another treatment, which would make sense according to our original hypothesis.

Are there any statistical tests that can help exclude the possibility of random chance causing the differences that we see in the exploratory figures?

This is a bit of a weird dataset since it involves values that are frequencies, has a few treatments, and is also a timeseries dataset.

Here is an example of the data file generated which was plotted.

time activity
14396 5
14397 5
14398 5
14399 5
14400 5
14401 12

This file shows the most common behavior at each second. It was calculated from ~20 different samples in one treatment group.

Any help or ideas of statistical methods, packages, pipelines, considerations, etc. would be appreciated! I can work in both R and python so please throw out any and every suggestion you can think!

I'm not a statistician and don't know many methods beyond an anova/KW test.



1 Answer 1


If I understand correctly, you have

  • a set of insects, each of which were exposed to treatment
  • for each insect, we have time series with the value at each point is a single feeding behaviour (one of 9 possible behaviours)

The response variable (a 9-level factor) corresponds nicely with the multinomial distribution. The multinomial is a generalisation of the binomial to $\ge2$ categories. If you use a multinomial as the response, you don't have to use the mode summary that you're currently using - the mode is a useful way to summarise the data, but you lose precious information when you're modelling.

I'm not sure what kind of model you want, because I'm not across the research question. But, a reasonable start to explore the data could be a multinomial GAM (I believe you can fit this model using mgcv in R), where the response variable is the insect behaviour factor, and the predictor variable is a smooth on time + treatment (or something like that). You could compare a model where treatment is a factor, and treatment is not a factor, and see if the response probabilities change.

  • 1
    $\begingroup$ Thanks for the answer. I'm going to do some reading on multinomial GAM modeling! $\endgroup$
    – Daniel K
    Apr 20, 2023 at 19:05
  • $\begingroup$ No worries! It could be that some other kind of model is more appropriate... I do think though, that whatever it is (e.g. a GLMM with a autocorrelation term or something else), it is the multinomial distributed response that you want $\endgroup$
    – Alex J
    Apr 20, 2023 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.