Javier Acuña
2008-Sep-17 15:03 UTC
[R] Unexpected behaviour when testing for independence with multiple factors
Hi, I'm a new user of R. My background is Electrical Engineering, so please bear with me if this is a silly question. I'm trying to assess whether the results of an experiment satisfy the hypothesis of homoscedasticity (my ultimate goal is to use ANOVA). The result of the experiment is mean delay (dT), which depends on three factors, topology, drift, and lambda. The first two factors are categorical (with 4 levels each) and the last one is numerical, with two levels. A sample of my data is as follows: dT Topology Drift lambda 258.789 Tree b1 .43 244.195 Tree b1 .43 115.961 Tree b2 .3 115.183 Tree b2 .3 I would like to separate dT in the 32 samples (4x4x2), and test if the variance of each sample is equal to the other 31 samples. I tried using fligner.test and bartlett.test, but either test seems to only work for one factor:> fligner.test( dT ~ Topology + Drift + lambda)Fligner-Killeen test of homogeneity of variances data: dT by Topology by Drift by lambda Fligner-Killeen:med chi-squared = 15.4343, df = 2, p-value = 0.0004451> fligner.test( dT ~ Topology )Fligner-Killeen test of homogeneity of variances data: dT by Topology Fligner-Killeen:med chi-squared = 15.4343, df = 2, p-value = 0.0004451 As I see from the previous two outputs, fligner.test only takes into account the first factor. Similar results are obtained for bartlett.test. At this point I don't know if I'm using the test incorrectly or something else. I would really appreciate any help. I'm using R version 2.7.2 (2008-08-25) in Windows XP. Many thanks in advance Javier ---------------------------------------------------- Javier Acuna Electrical Engineering Grad Student Universidad de Chile javier.acuna.o at gmail.com
Ben Bolker
2008-Sep-17 20:41 UTC
[R] Unexpected behaviour when testing for independence with multiple factors
Javier Acu?a <javier.acuna.o <at> gmail.com> writes:> > Hi, I'm a new user of R. My background is Electrical Engineering, so > please bear with me if this is a silly question. > > I'm trying to assess whether the results of an experiment satisfy the > hypothesis of homoscedasticity (my ultimate goal is to use ANOVA). > > The result of the experiment is mean delay (dT), which depends on > three factors, topology, drift, and lambda. The first two factors are > categorical (with 4 levels each) and the last one is numerical, with > two levels. > > A sample of my data is as follows: > > dT Topology Drift lambda > 258.789 Tree b1 .43 > 244.195 Tree b1 .43 > 115.961 Tree b2 .3 > 115.183 Tree b2 .3 > > I would like to separate dT in the 32 samples (4x4x2), and test if the > variance of each sample is equal to the other 31 samples. > I tried using fligner.test and bartlett.test, but either test seems to > only work for one factor: > > > fligner.test( dT ~ Topology + Drift + lambda) > > Fligner-Killeen test of homogeneity of variances > > data: dT by Topology by Drift by lambda > Fligner-Killeen:med chi-squared = 15.4343, df = 2, p-value = 0.0004451 > > > fligner.test( dT ~ Topology ) > > Fligner-Killeen test of homogeneity of variances > > data: dT by Topology > Fligner-Killeen:med chi-squared = 15.4343, df = 2, p-value = 0.0004451 > > As I see from the previous two outputs, fligner.test only takes into > account the first factor. Similar results are obtained for > bartlett.test.I would try fligner.test(dT ~ Topology:Drift:lambda) there's also lots of advice floating around in the archives about not taking these homogeneity of variance tests *too* seriously: for small data sets they are underpowered, for large data sets they are overpowered (i.e., they will detect departures from normality that are not actually a problem for ANOVA results). good luck, Ben Bolker
Michael Dewey
2008-Sep-18 12:32 UTC
[R] Unexpected behaviour when testing for independence with multiple factors
At 16:03 17/09/2008, Javier Acu?a wrote:>Hi, I'm a new user of R. My background is Electrical Engineering, so >please bear with me if this is a silly question.For future reference you might find ?interaction helpful as another tool in your box.>I'm trying to assess whether the results of an experiment satisfy the >hypothesis of homoscedasticity (my ultimate goal is to use ANOVA).It is hard to resist quoting Box (1953, Biometrika, 40, p333) that these tests are '... like putting to sea in a rowing boat to find out whether conditions are safe for an ocean liner to leave port'>The result of the experiment is mean delay (dT), which depends on >three factors, topology, drift, and lambda. The first two factors are >categorical (with 4 levels each) and the last one is numerical, with >two levels. > >A sample of my data is as follows: > >dT Topology Drift lambda >258.789 Tree b1 .43 >244.195 Tree b1 .43 >115.961 Tree b2 .3 >115.183 Tree b2 .3 > >I would like to separate dT in the 32 samples (4x4x2), and test if the >variance of each sample is equal to the other 31 samples. >I tried using fligner.test and bartlett.test, but either test seems to >only work for one factor: > > > fligner.test( dT ~ Topology + Drift + lambda) > > Fligner-Killeen test of homogeneity of variances > >data: dT by Topology by Drift by lambda >Fligner-Killeen:med chi-squared = 15.4343, df = 2, p-value = 0.0004451 > > > fligner.test( dT ~ Topology ) > > Fligner-Killeen test of homogeneity of variances > >data: dT by Topology >Fligner-Killeen:med chi-squared = 15.4343, df = 2, p-value = 0.0004451 > >As I see from the previous two outputs, fligner.test only takes into >account the first factor. Similar results are obtained for >bartlett.test. > >At this point I don't know if I'm using the test incorrectly or >something else. I would really appreciate any help. I'm using R >version 2.7.2 (2008-08-25) in Windows XP. > >Many thanks in advance >Javier > >---------------------------------------------------- >Javier Acuna >Electrical Engineering Grad Student >Universidad de Chile >javier.acuna.o at gmail.comMichael Dewey http://www.aghmed.fsnet.co.uk