# How to test if reading from two devices are significantly different?

I am trying to compare readings from an old flowmeter and a new digital flowmeter to find out if they are significantly different. With the new meter I did readings under different conditions eg. calibrated at 30 seconds, calibrated at 60 seconds, uncalibrated at 30 seconds and uncalibrated at 60 seconds. I want to compare my old flowmeter (first column on dataset) to the other readings (columns 2:5 on dataset). I used anova to compare the groups and found some differences but I am stuck with TukeyHSD...My question is: Is this the correct way to do the comparisons...I would appreciate some advice on how to accomplish this task...Here is my dataset and code....

    meter <- structure(list(SiteNumber = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("site1",
"site2", "site3", "site4"), class = "factor"), old_dev = c(2.09,
1.927, 2.11, 2.114, 2.11, 1.995, 2.605, 2.563, 2.393, 2.286,
2.529, 2.371, 2.214, 2.128, 2.302, 2.204, 2.274, 3.513, 2.61,
3.502, 3.155, 3.131, 3.55, 3.656, 3.666, 3.618, 3.023, 3.226,
3.649, 3.519, 3.322, 3.352, 3.323, 3.144, 2.869, 3.383, 3.076,
2.978, 3.189, 2.934, 2.813, 3.015, 3.014, 3.056, 2.952, 2.988,
2.976, 3.049, 2.869, 2.965, 2.895, 2.064, 1.333, 1.432, 1.599,
1.52, 1.51, 2.734, 2.182, 2.71, 2.488, 2.242, 1.998, 1.175, 1.791,
2.152, 3.414, 3.278), new_dev_unc30 = c(2.6, 2.6, 2.7, 2.6, 2.3,
2.6, 3.2, 2.9, 2.1, 2.8, 1.8, 2.6, 2.5, 1.4, 2.7, 2.6, 2.2, 4.1,
3.4, 3.7, 4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.4, 1.4, 2, 4.2,
3.3, 3.2, 3.3, 3.4, 2.1, 3.4, 2.5, 3.8, 3.8, 3.9, 3.6, 3.5, 2.4,
2.9, 3.1, 2.3, 2.6, 3.1, 2.2, 0.8, 3.2, 2.6, 3.1, 0.9, 1.7, 1.2,
1.5, 1.2, 1, 1.1, 2.6, 1.6, 1.9, 0.6, 2.3, 1.4, 1.2, 1.5, 1.2,
1.4, 1.4)), .Names = c("SiteNumber", "old_dev", "new_dev_unc30",
"new_dev_unc60", "new_dev_cal30", "new_dev_cal60"), class = "data.frame", row.names = c(NA,
-68L))


Here is what I did:

str(meter)
attach(meter)
boxplot(list(old_dev,new_dev_unc30,new_dev_unc60,new_dev_cal30,new_dev_cal60))
summary(firsttest <- aov(old_dev ~ new_dev_unc30 + new_dev_unc60 + new_dev_cal30 + new_dev_cal60 ))
plot(firsttest)
TukeyHSD(??????)

-
 since I am trying to compare the old_device to the new device calibrated and uncalibrated to see if there are significant differences, is it OK to use aov like this: summary(test1 <- aov(old_dev ~ new_dev_unc30)); summary(test2 <- aov(old_dev ~new_dev_unc60)); summary(test3 <- aov(old_dev ~ new_dev_cal30)); summary(test4 <- aov(old_dev ~ new_dev_cal60)) to compare the old device with the different modes of the new one? – user9093 Feb 9 '12 at 22:50 NO! The syntax for formulas with aov is always dependent.variable ~ independent.variable where independent.variable needs to be a nominal factor (see ?factor). And please edit your question and do not post questions as answers. – Henrik Feb 10 '12 at 9:59

## migrated from stackoverflow.comFeb 8 '12 at 21:52

The analysis you are doing seems to be incorrect (as I see it). Additionally, from you description I do not understand your data. Your data is a two-factorial design with the factors SiteNumber (SiteNumber1 to SiteNumber4) and the device (OldDevice and 4 times the new device). This does not correspond with your description.

In the following I submit the data to a 2-way ANOVA (using the reshape and ez package) with both factors (variale = device). It reveals only a main effect of SiteNumber but no effect of the device:

library(reshape)
library(ez)

meter.long <- melt(meter)
meter.long$id <- factor(seq_len(dim(meter.long)[1])) ezANOVA(meter.long, wid = .(id), dv = .(value), between = .(SiteNumber, variable))  gives: $ANOVA
Effect DFn DFd           F            p p<.05         ges
1          SiteNumber   3 320 107.9167057 2.734194e-48     * 0.502912712
2            variable   4 320   0.6228809 6.464967e-01       0.007725858
3 SiteNumber:variable  12 320   1.0357982 4.153921e-01       0.037390111

\$Levene's Test for Homogeneity of Variance
DFn DFd      SSn     SSd       F            p p<.05
1  19 320 16.15142 58.6906 4.63488 2.008842e-09     *


In sum this analysis allows one conclusion regarding your question: There is no evidence that there is a difference between measures from the two devices independent of the calibration.

-
 Thanks Henrik, Would it make any difference if I remove the siteNumber column? I only care about comparing the old device (old_dev) with all the other columns (old_dev,new_dev_unc30,new_dev_unc60,new_dev_cal30,new_dev_cal60). The siteNumber doesnt matter – user9069 Feb 9 '12 at 3:00 Leaving Site Number out shouldn't change anything. You can try it out by removing SiteNumber from the call to ezANOVA. – Henrik Feb 9 '12 at 7:21 Is there another way I can do anova besides the ez package? – user9093 Feb 9 '12 at 21:44 yes. ez is simply a wrapper of the Anova function in the car package (which I also recommend). You could also use lm or aov from base R, but it is less comfortable (and does not support type 3 SS). I would go with ez or car. – Henrik Feb 9 '12 at 21:59

I would plot the values and perform a least products regression to see if there is anything interesting going on in the data, but there do seem to be statistical tests that would be appropriate. Comparing methods of measurement is an interest of my friend John Ludbrook. He has a review of statistical methods that you can get here: http://www.cytel.com/papers/Ludbrook-Special-2002.pdf

-