2
#install.packages("car")
library(car)

model1<-lm(Temp ~ . , data = climate) # all the independent variables are numeric.
summary(model1) # Proper output
vif(model1)

I get an error and a warning when I execute the the vif(model1).

Error in as.vector(y) - mean(y) : non-numeric argument to binary operator
In addition: Warning message:
In mean.default(y) : argument is not numeric or logical: returning NA

I have gone through similar queries in stackoverflow. Most of them suggested to install car package. I have done that still no luck.

str(climate)

'data.frame': 308 obs. of 9 variables:

$ MEI : num 2.556 2.167 1.741 1.13 0.428 ...

$ CO2 : num 346 346 344 342 340 ...

$ CH4 : num 1639 1634 1633 1631 1648 ...

$ N2O : num 304 304 304 304 304 ...

$ CFC.11 : num 191 192 193 194 194 ...

$ CFC.12 : num 350 352 354 356 357 ...

$ TSI : num 1366 1366 1366 1366 1366 ...

$ Aerosols: num 0.0863 0.0794 0.0731 0.0673 0.0619 0.0569 0.0524 0.0486 0.0451 0.0416 ...

$ Temp : num 0.109 0.118 0.137 0.176 0.149 0.093 0.232 0.078 0.089 0.013 ...

  • 2
    Is temp numeric? Is temp a variable stored in climate, so that `climate$temp` does not return an error? If the answer is no to either of these, then this is probably the cause of the error. Please post the output of `str(climate)` at the bottom of your question. – lmo Aug 15 '17 at 18:25
  • Can you list your R version? Could be an empty model that you are running vif() on. I can't see climate data in the data folder of the car package. Check d <- data(package = "car");d – HoofarLotusX Aug 15 '17 at 18:36
  • @office206 R version 3.3.2 – z1789744 niu Aug 15 '17 at 19:17
  • Couldn't help noticing: in the `str(climate)` output, `$Temp` is capitalized. – Matt Tyers Aug 15 '17 at 19:47
  • @MattTyers. A mistake in posting the question here. My actual code has Uppercase T. Il make changes in the question. Thanks :) – z1789744 niu Aug 15 '17 at 21:57
  • You bet! Was hoping the answer could just be that simple. – Matt Tyers Aug 15 '17 at 22:03

0 Answers0