[R] Multilevel modeling of animal behavior

From: ILAI KEREN <ILAIKEREN_at_msn.com>
Date: Sat 05 Mar 2005 - 01:54:46 EST


Hello all,
My question is how do I write a multilevel regression model of individual responses to environmental predictors that accounts for social interactions between individuals. i.e.;

1) Individual response is nested within a group response.  
2) The same environmental predictors apply to both hierarchical levels but, 
3) Lower level slope/intercept are also affected by high-level response. 

Is there an appropriate, easy to use, model in NLME ? I can't seem to find one.

My statistical skills are very weak (as will be evident from the following study design), and my programming in R is limited. The data is of individual animals responding to changing weather conditions, but all animals were kept as one group (and therefore interact with each other). as noted Group mean is either useless or less powerful.

I think treating the data as hierarchical with inter-level interactions (Hox, 1995) might resolve the problem, allowing analysis on individuals. But am unsure of my approach. I will be grateful if anyone is interested in reading the following problem in detail and commenting on any aspect of my proposed solution.

Thank you in advance, Elai.

+++++++++
+ General: + 
+++++++++

I am trying to analyze the impact of temperature, wind, and solar radiation on cattle behavior in winter (e.g. exposure to the sun, use of windbreaks).  

Individual cow's behavior in the field is partly influenced by group behavior and it's nearest neighbors, also known as "herd effect" (Shiyomi and Tsuiki, 1999; Shiyomi, 2004). For example: decision to use a windbreak depends on: a) wind speed,
b) how many cows are already using it. Another example may be individual decisions on where to forage will depend on movement patterns of the herd and not just the topography.

To avoid overestimating the importance of my environmental predictors (not accounting for the social factor), or underestimating (individual responses despite opposing social pressure), and "side step" pseudo-replication, seems like I can use a multilevel model, where environment influences the group and both environment and group influence the individual (Blakely et al., 2000).

Simpler solutions (analyze only herd means, add herd effect as covariate, etc.) will be more then welcome, but seem to always violate some assumption (equal slopes of covariate, independence from predictors), or lose much of the analytical power.

  1. Shiyomi, M., Tsuiki, M., 1999. Model for the spatial pattern formed by a small herd in grazing cattle. Ecological Modelling 119, 231-238.
  2. Shiyomi, M., 2004. How are distances between individuals of grazing cows explained by a statistical model? Ecological Modelling 172, 87-94
  3. Blakely, T.A., Woodward, A.J., 2000. Ecological effects in multi-level studies. J. Epidemiol. Commun. H. 54, 367-374.
++++++++++++++++++++++++++++++

+ A specific example from my research:+
++++++++++++++++++++++++++++++

Cold stressed cows maximize surface area exposed to the sun. Therefore on cold sunny days they will increasingly orient to a 90o angle to the sun's azimuth. We want to build a regression model orientation vs. temperature and wind, but cows in a group all walk (and therefore orient) more or less in the same direction.

Methods

A small herd of twelve cows (ID) was observed in the field, and individual orientations (orid) noted (compass; 0o = north, 90o = east, etc. all angular units in radians) every hour. We can assume observation (obs) at time t+1 is independent of observation t. Individual orientations depend on temperature (temp), radiation (swr) and a measure of herd effect (He).

sample data:

obs ID orid swr temp azimuth

114 6042 0.35 192.6 -39.72 2.51
114 6107 4.01 210.9 -35.38 2.52
114 6056 4.19 210.9 -35.38 2.53
114 1068 1.05 210.9 -35.38 2.53
114 1034 0.35 210.9 -35.38 2.54
114 1098 0.52 210.9 -35.38 2.54
114 1042 0.70 210.9 -35.38 2.55
114 6079 0.35 210.9 -35.38 2.55
114 6517 0.70 210.9 -35.38 2.55
115 6042 0.70 306 -31.92 2.75
115 6146 0.87 306 -31.92 2.76
115 1098 1.22 306 -31.92 2.77
115 1556 1.05 306 -31.92 2.77
115 1042 1.22 306 -31.92 2.78
115 6517 0.52 306 -31.92 2.78
115 6056 0.35 320.4 -27.45 2.79
115 1068 0.35 320.4 -27.45 2.80
115 1034 0.35 320.4 -27.45 2.80
115 1505 0.87 320.4 -27.45 2.80
115 6107 3.14 320.4 -27.45 2.80
116 6042 0.70 360.3 -25.26 3.00
116 6079 1.22 368 -24.49 3.01
116 6517 4.71 368 -24.49 3.02
116 6056 2.36 368 -24.49 3.02
116 6107 4.36 368 -24.49 3.03
116 1556 1.05 368 -24.49 3.04
116 1068 0.61 368 -24.49 3.04
116 1505 2.27 376.5 -22.91 3.05
116 1034 1.75 376.5 -22.91 3.05
116 6146 1.66 376.5 -22.91 3.05
116 1042 0.70 376.5 -22.91 3.06
116 1098 2.09 376.5 -22.91 3.07
117 6042 1.48 378.3 -23.57 3.26
117 1034 5.59 376.5 -23.33 3.26
117 1042 4.36 376.5 -23.33 3.27
117 6079 1.57 376.5 -23.33 3.27
117 1098 4.97 376.5 -23.33 3.27
117 6146 4.71 376.5 -23.33 3.28
117 1505 4.63 376.5 -23.33 3.29
117 1556 3.93 376.5 -23.33 3.29
117 6107 1.40 376.5 -23.33 3.30
117 6056 1.92 372.1 -22.84 3.30
117 6517 2.09 372.1 -22.84 3.31

Solution:

# Herd effect is defined as "difficulty straying from the herd"
# It is quantified by multiplying individual distances from the mean vector by rho;
# thus a high value implies It is more difficult to stray from a "tight" group.
# Distance is converted to degrees or rho multiplied by 100 for purposes of scaling;

orih<- rep(tapply(orid,obs,circ.mean),tapply(orid,obs,length)) Herd.rho<- rep(tapply(orid,obs,est.rho),tapply(orid,obs,length)) He<- deg(abs(orid - orih))*Herd.rho

# In this example the direction of the head or which side of the cow is exposed doesn't matter, so we can
# relate orid to azimuth on a 0o-90o scale (we are interested only in increasing "perpendicularity":

oriscale1<-ifelse(abs(orid-azimuth)> 1.570796&abs(orid-azimuth) <= 3.141593, 3.141593 -abs(orid-azimuth),abs(orid-azimuth))
oriscale2<- ifelse(abs(orid-azimuth)> 3.141593&abs(orid-azimuth) <= 4.712389, abs(orid-azimuth)- 3.141593,oriscale1)
orid.azmt<- ifelse(abs(orid-azimuth)> 4.712389, 6.283185-abs(orid-azimuth), oriscale2)

# recalculating orih and He from the orid.azmt keeps all orientations in the same quartile,
# and eliminates negative orih values:

orih.azmt<- rep(tapply(orid.azmt,obs,circ.mean),tapply(orid,obs,length)) Herd.azmt.rho<- rep(tapply(orid.azmt,obs,est.rho),tapply(orid,obs,length)) He90<- abs(orid.azmt - orih.azmt))*Herd.azmt.rho*100

##########################

## What should be my next step? ##
##########################

# First I tried to insert He90 in a simple linear regression:

summary(lm(orid.azmt~ swr*temp*He90))

## over fitting?

## also tried various combinations such as nesting orih.azmt within environment:

summary(lm(orid.azmt~ (swr*temp)/hori.azmt+He90))

# and in the error term:

summary(aov(orid.azmt~ hori.azmt+swr*temp+Error(swr*temp/He90)))

## But non seem appropriate, or meet the notation for multilevel as described in the literature.

## I will very much appreciate a suggested model (in notation and code) that can provide the correct ## intercept and slope for environmental variables (and maybe significance of herd effect on the side).  

### Thanks, Elai. ##

#######################
###############################

Elai Keren,
Dept. Animal & Range Sciences
Montana State University
Bozeman, MT
E-mail: ILAIKEREN@MSN.COM<mailto:ILAIKEREN@MSN.COM>

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Mar 05 03:57:56 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:40 EST