I have a set of data: http://pastebin.com/KHLKD8XB

which is based on TVC (total viable counts - i.e., numbers of bacteria) from water going into a machine (BM), water taken from the machine (IM) and water taken from a device which is washed in that machine (Scope).

Whilst the counts are performed on a 200ml sample, results are reported as cfu/100ml, hence you appear to find 1/2 a bacteria in some samples.

ggplot(data=testscope,aes(x=date, y=tvc, colour=class)) + 
    geom_step()  + facet_grid(class ~ ., scales="free")  + 
    labs(title="Machine TVC versus Scope TVC") + ylab("cfu/100ml")

Plotted using ggplot2:

enter image description here

My question is: How can I check whether TVC readings from the Scope are related to TVC readings from the machine ?

By eye, I can't discern a pattern between the machine level (IM) and the Scope levels.

Note that although I have the BM data, that is not something we are particularly interested in at present - it is IM versus Scope that we need to understand.

EDIT: Note that the dataset uses natural log, not base 10. My mistake.

  • $\begingroup$ Hi @PJP, welcome to the site! Forgive my ignorance, but if TVC is a count variable, why does it not always come in integers? Count data are usually modelled by a Poisson regression or a Negative binomial regression if your data show overdispersion. $\endgroup$ – COOLSerdash May 28 '13 at 9:52
  • $\begingroup$ Hi @COOLSerdash. It's because we report in standardised TVC/100ml but we filter larger quantities (I think around 400ml-500ml). So 10 bugs in 400ml =2.5/100ml. $\endgroup$ – PJP May 28 '13 at 9:55
  • 1
    $\begingroup$ That's important information that should be in the question I think. $\endgroup$ – Glen_b -Reinstate Monica May 28 '13 at 12:09

Granger causality tests if a time series can be better predicted with the additional information from another time series compared to only the time series itself. The problem is that under certain conditions the test does not work, for example if the time series are integrated.

Case 1: Time series are not integrated (easy case) The time series above do not look integrated to me, but be sure to carry out the tests for integration (KPSS, ADF, ...). If they are not integrated, and there is no structural break you can just carry out the standard Granger-causality test. For example you could use the vars package for that. So, set up are VAR model first and then use the causality() function.

Case 2: At least one time series is integrated (more difficult): In this case you could use the Toda-Yamamoto procedure. Another (more demanding) method is the vector error correction model (VECM). HTH

  • $\begingroup$ Welcome to the site, @Candide. This looks like a helpful contribution (+1), we hope we'll see more in the future. Note that we prefer you don't sign your posts or add other, peripheral / conversational comments. Your flair, with your username and a link to your user page are automatically added to all your posts. $\endgroup$ – gung - Reinstate Monica Jun 5 '13 at 15:54

The Granger Casuality Test would seem appropriate.This link gives a nice R example. http://www.christophpfeiffer.org/2012/11/07/toda-yamamoto-implementation-in-r/

  • 1
    $\begingroup$ Welcome to the site, @wcairns. Would you mind expanding a little bit on what the Granger test is & why it's the right answer here? $\endgroup$ – gung - Reinstate Monica May 29 '13 at 14:31
  • $\begingroup$ ouch. My head hurts after working through that. $\endgroup$ – PJP May 29 '13 at 19:33
  • $\begingroup$ ouch. My head hurts after working through that! ;-) Thanks for the advice. I have got as far as the Dickey-Fuller and KPSS tests, but need to understand what I'm doing. $\endgroup$ – PJP May 29 '13 at 20:33

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.