Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upinteract_plot errors with `scale`-ed variables #33
Comments
|
So it seems the source of this problem is that This is such an odd case that I'm not sure if it's worth me trying to anticipate and fix at this juncture. A quick fix is to just do some simple coercion like this: library(interactions)
iris$Sepal.Length_c <- as.numeric(scale(iris$Sepal.Length, center = TRUE, scale = FALSE))
iris$Sepal.Width_c <- as.numeric(scale(iris$Sepal.Width, center = TRUE, scale = FALSE))
fit <- lm(Petal.Length ~ Sepal.Length_c * Sepal.Width_c, iris)
interact_plot(fit, pred = Sepal.Length_c, modx = Sepal.Width_c) |
I'm afraid that odd as it is, it is also common to center variables, especially in moderation analyses (especially in the social sciences). One of those things that just "caught on" and cannot be untaught :/ |
|
Well @mattansb I think you've been proven right as I've gotten at least two emails about this same problem since you created this issue. As it turns out, fixing this isn't as complicated as I first expected. The source of the problem was in my other package, To some extent, this is all just a quirk of how R automatically treats a one-dimensional matrix of numbers and a vector of numbers as if they are the same sometimes but not other times. Now my internal functions just do a check to see if what looks like a numeric variable is actually a one-dimensional matrix created by |
|
Thanks Jacob! |
However this doesn't happen with
sim_slopesorjohnson_neyman.Created on 2020-03-13 by the reprex package (v0.3.0)