0
votes

I am doing boxM test from biotools R package to test the homogeneity of variance-covariance matrices. I am working on a dataset namely "wine" from r package called rattle. First, I installed the library(car). Then I did following conversions for all variables to prepare the dataset for LDA or QDA after Box's M test.

wine1 <- data.frame(wine)
wine1$Type <- as.factor(wine1$Type)
wine1$Alcohol <- as.numeric(wine1$Alcohol) # I converted all other variables to "numeric" class.

When I ran boxM test in RStudio [Version 0.99.489 and Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko)] as

boxM(wine2[,-c(4, 11, 12, 13)], wine2[,1]) # No physical factors
boxM(wine2[,-c(2, 3, 5, 6, 7, 8, 9, 10, 14)], wine2[,1]) # No chemical factor

it returned following error

Error: is.numeric(x) || is.logical(x) is not TRUE
1
You have not defined wine2IRTFM

1 Answers

0
votes

Two things needed with that data setup: Change wine2 to wine1 (but that did not fix your error) and remove column 1 from the first arguments to boxM:

> boxM(wine1[,-c(1,4, 11, 12, 13)], wine1[,1])

    Box's M-test for Homogeneity of Covariance Matrices

data:  wine1[, -c(1, 4, 11, 12, 13)]
Chi-Sq (approx.) = 378.32, df = 90, p-value < 2.2e-16

> boxM(wine2[,-c(1,2, 3, 5, 6, 7, 8, 9, 10, 14)], wine2[,1])
Error in inherits(data, c("data.frame", "matrix")) : 
  object 'wine2' not found
> boxM(wine1[,-c(1,2, 3, 5, 6, 7, 8, 9, 10, 14)], wine1[,1])

    Box's M-test for Homogeneity of Covariance Matrices

data:  wine1[, -c(1, 2, 3, 5, 6, 7, 8, 9, 10, 14)]
Chi-Sq (approx.) = 147.69, df = 20, p-value < 2.2e-16