I have a dataset for time (hours decimal format) spent carrying out different behaviours of cattle in a day. I'm trying to run a general linear mixed model with two independent variables (lactation status: milk or dry, and period: Day or night) for 4 behaviours (walk, lay, stand, graze).

Cow ID Lacatation.Status Period Period.Length Walking Lying Standing Grazing
Cow1 Milk Day 6.64 0.47 4.41 0 1.75
Cow1 Dry Night 11.99 0.33 2.01 8.30 1.34
Cow2 Dry Day 9.30 0.83 5.01 0.96 2.48
Cow2 Milk Night 11.87 0.31 3.24 5.31 2.99
Cow3 Milk Day 6.64 0.47 4.41 0 1.75
Cow3 Dry Night 11.99 0.33 2.01 8.30 1.34
Cow4 Dry Day 9.30 0.83 5.01 0.96 2.48
Cow4 Milk Night 11.87 0.31 3.24 5.31 2.99

My response variables (behaviours) are dependent on one another, e.g. if cattle walk 4hrs within day (12hrs) then there's only 8hrs left for remaining variables. Can I use percent <- (data$Period.Length-data$walking.hrs) to account for the linear relationship of the variables (repeat for each behaviour)? Cow ID would be random effect.

Behaviours have non-normal distribution - should I tranform the data using arcsine-square-root prior to analysis, or leave as is and run a generalised linear mixed model? I'm also reading that a beta regression may be more suitable for this data type?

I want to see what affect period has on behaviours, and what affect lactation status has.


2 Answers 2


As the sum of times for all behaviors is necessarily 24 hours per day, you have what is called "compositional data" for outcomes. There are specialized methods for handling this type of data to take that constraint into account. There are at least two R packages that are designed for compositional data, the Compositional package and the compositions package. I don't have much experience with them, and I don't know whether they handle mixed models, but along with searches for "compositional data" they should give you a start toward finding a way forward.

  • 1
    $\begingroup$ Hi Edm, thank you. I'd not heard of those packages so I'll be sure to check them out and update once I have. $\endgroup$
    – Kyle
    Commented Aug 8, 2021 at 8:35

This is a bit like the problem of dummy coding categorical variables when they are predictors in a regression model (or when you have multinomial outcomes). When you add the fourth category, it doesn't tell you anything you didn't already know. If you know that they are doing less walking, grazing and standing, they must be doing less laying.

If you try to add all four variables, the model will (I think) not be identified.

Instead, as with categorical predictors, you can exclude one and then run the model, and if you desire, exclude a different one and run it again.

  • $\begingroup$ Hi Jeremy, thank you for your help. I'll attempt the advice given tomorrow and update on my results. Much appreciated. $\endgroup$
    – Kyle
    Commented Aug 8, 2021 at 8:37

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.