Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using the method in this post, I have made a plot to visualize the interaction between two predictor variables using the effects package in , but I'm not really sure what I am looking at.

Tide heights and rain averages are continuous. 8 bins were the maximum the function would allow me to use. The following is the call to effect producing this plot:

 R > plot(effect(term="rain.avg2:tide.avg",mod=bkrain9.lm,default.levels=8),
          main="", xlab="Precipitation - 24hr average (cm)",
          ylab=expression("TCB Concentration - CFU*100m"*L^-1),multiline=TRUE)

Plot updated. Could somebody explain the purpose of this plotting feature in context to predictor interactions?


Background: For a class project, I have created a linear regression model to evaluate the effects of the interaction between two predictor variables (tide height and precipitation) on bacteria concentrations.

Thermo-tolerant coliform bacteria concentrations were sampled at 5 sites in a day, where a sample time was recorded at sampling completion. I took an average of these for roughly 20 days, and calculated an associated 24hr average of precipitation before sampling completion, and a 50 minute (the sampling duration) average of tide height before sampling completion.

share|improve this question

migrated from Nov 16 '12 at 14:44

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

So I'm learning the ropes with this, but should I just flag my post for a moderator to do this? I'm guessing this is why I've received a down-vote. Thanks. – shootingstars Nov 16 '12 at 12:52
To receive a helpful answer you should provide more info regarding your data and the analysis you have done so far. E.g. it seems that both predictor variables are continuous? Did you split up your data according two rain.avg2 in 8 bins for plotting purposes? – jokel Nov 16 '12 at 15:10
Added more relevant information. I feel like I understand this a bit more after correcting which was the focal predictor and which was the non-focal predictor, but additional explanations are of course helpful. – ryanjdillon Nov 17 '12 at 17:41
@patricksforscher pretty much gave you the answer -- the different lines correspond to the effect of 168 hour average precipitation on the TCB concentration when the tide.avg is held fixed at the values indicated in the legend. So the yellow line is how the TCB concentration changes as average precipitation changes and tide.avg is held constant at 125.46 – tchakravarty Nov 17 '12 at 17:51
You might be interested in taking a look at the coplot() function and, more generally, John Fox's effects package. – chl Nov 17 '12 at 20:38
up vote 1 down vote accepted

Without knowing more about the specifics of the dataset, I can't be especially helpful. However, in general an interaction plot shows the effects of a focal predictor on the dependent variable at specific values of the nonfocal predictor. In your case, your plot is showing the effects of "tide.avg" on "tcb.avg" when "rain.avg" is 0, .22, .44, etc.

share|improve this answer
Thanks Patrick. I have updated my question to be more specific. – ryanjdillon Nov 17 '12 at 17:42

@PatrickS.Forscher is giving you the right answer here. Having an interaction means that the relationship between level of precipitation and the bacterial concentration depends on the height of the tide. When the tide is 27.4 (cm?), the level of precipitation has essentially no effect on bacterial concentrations, but the effect of precipitation becomes increasingly steeper as the tide goes up, such that even small changes in precipitation can be associated with big changes in the concentration of the bacteria. For example, when the tide height reaches 141.8, a .1 increase in precipitation is associated with an increase in the bacterial concentration of about 200 units.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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