I want to test homoscedasticity using the levene.test
function from the lawstat package specifically because I like the bootstrap option and the fact that it returns a list rather then the unmanageable output of car::leveneTest
. From the help of lawstat::levene.test
it is clear that the NAs should be omitted by default from my dataset. Below I provide the original data.
testset.logcount<-c(6.86923171973098, 6.83122969386706, 7.30102999566398,7.54282542695918,6.40823996531185, 6.52891670027766, 6.61278385671974, 6.71933128698373, 6.96567197122011, 6.34242268082221, 6.60205999132796, 6.69897000433602, 6.6232492903979, 6.54157924394658, 6.43136376415899, 6.91381385238372,6.44715803134222, 6.30102999566398, 6.10037054511756, 6.7481880270062,NA, 4.89762709129044,5.26951294421792, 5.12385164096709, 5.11394335230684, 4.43136376415899, 5.73957234445009, 5.83250891270624, 5.3451776165427, 5.77887447200274, 5.38524868240322, 5.75127910398334, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)
testset.treat<-structure(c(1L, 1L, 1L, 1L, 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, 2L, 2L, 2L, 2L), .Label = c("CTL","TRM"), class = "factor")
when I execute lawstat::levene.test(y=testset.logcount,group=testset.treat)
I get the following error message: Error in contrasts<-
(*tmp*
, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
According to me the testset.treat clearly has two levels.
Also when using leveneTest(y=testset.logcount,group=testset.treat)
or fligner.test(x=testset.logcount,g=testset.treat)
both run without any errors.
I could not find out why I got this particular error with lawstat::levene.test and I am hoping that somebody here can help me out.
I am running R 3.0.0 on a x86_64-w64-mingw32/x64 platform (Windows 7, 64 bit).