atyre2 / NRES803

Other
0 stars 8 forks source link

broke check_nonlinear again #10

Open diatomdaniel opened 3 years ago

diatomdaniel commented 3 years ago

Check non_linear does not work with transformed variables that are not specified as as columns in the data frame that was used to build the model. No idea why this is happening, anyone have any ideas?

E.g. data("iris") x <- lm(Sepal.Width ~ log(Sepal.Length), data = iris) check_nonlinear(x)

Error in FUN(X[[i]], ...) : object 'Sepal.Length' not found

atyre2 commented 3 years ago

So -- transformations in the formula often run into problems when you try to do things with the model object afterwards. I bet in the model.frame() result the variable is called something like log(Sepal.Length). The obvious workaround is to do the transformation in the data fed to the model, changing the name of the variable to something like log_Sepal.Length. As far as the code goes, we could try to work harder at parsing the variables out of the formula, or maybe try creating a more informative error message that suggests the work around.