0
$\begingroup$

I have a regression with a harmonic effect of day of the year, which interacts with other variables. I am not sure how to interpret the coefficients. My model is:

m1 <- lme(lcount ~ AirT + sin(2*pi/360*DOY) + cos(2*pi/360*DOY) + 
          AirT*sin(2*pi/360*DOY) + AirT*cos(2*pi/360*DOY) + RainAmt + RainAmt*AirT,
          random = ~1|plot))

I get significant interaction effects of air temperature with the linearized harmonic day of the year (DOY) function. My response variable is the log of animal counts on each day. I want to describe how the effect of air temperature on animal observations changes depending on the day of the year.

Does anyone have suggestions on how I can interpret my beta values and/or how I can visualize the effect? I am using R but am not that skilled. The package I used for analyzing my data is nlme.

EDIT: My primary goals are (1) to describe the response of animals to environmental variables and (2) to predict future activity periods (i.e. when and under what conditions should a research bother trying to catch these animals). So if there is a better way to model this data, I would be interested in hearing it (such as cubic splines - see comments below).

$\endgroup$
  • $\begingroup$ This will be difficult to interpret indeed unless you constrain the ratio of the third and second coefficients to equal the ratio of the fifth and fourth: otherwise the two harmonic terms are potentially out of phase. Harmonic representations are not very good representations of seasonal temperature fluctuations, anyway: have you considered using a cubic spline instead? $\endgroup$ – whuber Jan 11 '12 at 20:21
  • $\begingroup$ @whuber - I have no idea how I'd constrain those ratio's in R. I'm still quite a novice (in R and statistics). I'm not familiar with cubic splines. Do you have any references you'd recommend offhand? My primary goals are (1) to describe the response of animals to environmental variables and (2) to predict future activity periods (i.e. when and under what conditions should a research bother trying to catch these animals). Are cubic splines suitable for these purposes? $\endgroup$ – djhocking Jan 11 '12 at 22:07
  • $\begingroup$ (1) Search here for information on splines. (2) Consider using a generalized linear model for these data. $\endgroup$ – whuber Jan 11 '12 at 22:14
3
$\begingroup$

Before you do any more modelling I'd definitely try to get a good visualisation of the data. Lattice graphics are good at this sort of thing. One trick might be to cut up the DOY variable into months, seasons, or whatever are the meaningful divisions in your field. Then you can do a different plot for each season showing the different relationship between the air temperature and animal count. The code below does this by breaking DOY automatically into 12 equal parts.

library(lattice)
xyplot(lcount~AirT | cut(DOY, 12), panel=function(x,y){
    panel.xyplot(x, y)
     panel.loess(x, y, span=1)})

You can experiment with different ways of showing your location effect - different coloured characters for different plots, or you can feed it into the formula above (eg replace the formula above with "lcount~AirT | cut(DOY, 4) + location") and get a different plot for each combination of location and quarter (assuming quartering the year is useful for you - probably isn't so you need some other way of dividing up DOY).

Have a read of the help files for xyplot and lattice.

Do you have Pinheiro and Bates' book on mixed effects models in S-Plus? Very similar to R and lots of good advice on this sort of issue. My copy's not here right now.

$\endgroup$
  • $\begingroup$ Your R command can be shortened as xyplot(..., type=c("p","smooth")). The span (which is 2/3 by default) can be directly passed to panel.loess() so that your expression is equivalent to xyplot(lcount~AirT | cut(DOY, 12), type=c("p","smooth"), span=1). You can also use shingle (or equal.count) instead of cut. $\endgroup$ – chl Jan 20 '12 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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