'Error in ncol(x) : object 'x' not found' - mctest and omcdiag

I'm trying to run Farrar-Glauber tests in R, using the mctest package. I've created a data.frame with all the variables that I want to test for multicollinearity. I'm trying to use the omcdiag function but I keep getting the following error:

Error in ncol(x) : object 'x' not found (the data frame definitely exists and works)

I've also tried versions of the data frame with and without y (my dependent variable). I've tried:

omcdiag(CO2_lowerdata, CO2_pc_cmice1)
omcdiag(CO2_lowerdata, CO2_pc_cmice1, na.rm = TRUE, Inter = TRUE, detr = 0.01, red = 0.5,
        conf = 0.95)
omcdiag(CO2_lowerdata[,c(2:9)],CO2_lowerdata$CO2_pc_cmice1)

For all of these I get the following error:

Error in ncol(x) : object 'x' not found

I've also tried reading the data frame as a as.matrix , data.matrix , as.numeric and with as.matrix(sapply(CO2_lowerdata, as.numeric))

However then I get this error message :

Error: $ operator is invalid for atomic vectors

Yet I'm not actually using $ in any of these

Hopefully this is something simple! Super grateful if anyone can help.

Many thanks

I don't have the package but the documentation tells me its not for running on dataframes. its for running on models.

omcdiag(mod, na.rm = TRUE, Inter = TRUE, detr = 0.01, red = 0.5,
                     conf = 0.95, theil = 0.5, cn = 30,...)

Arguments
mod
A model object, not necessarily type lm

There is an example of this in the documentation.

data(Hald)
model <- lm(y~X1+X2+X3+X4, data = as.data.frame(Hald))
od<-omcdiag(model)

That seems to be it, great. Thank you!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.