piecewiseSEM icon indicating copy to clipboard operation
piecewiseSEM copied to clipboard

using `scale` in model formula still not applying properly

Open jslefche opened this issue 3 years ago • 1 comments

eg

library(piecewiseSEM)
data <- data.frame(y=  runif(100), x = runif(100))
model <- lm(y ~ x, data)
coefs(model)
model2 <- lm(scale(y) ~ scale(x), data)
coefs(model) # here estimate and std.estimate should be the same

jslefche avatar Jul 18 '22 13:07 jslefche

Ok so this is also weird for interactions: i think the package takes the product and then scales, when it should scale each variable THEN take the product. At least, I think this is how it should work...

jslefche avatar Jul 18 '22 21:07 jslefche

Actually, I think this is working as intended, see:

stdCoefs(model)
unstdCoefs(model2)

Also, running coefs(model2) gives a warning about the use of scale for response

So closing for now

jslefche avatar Dec 02 '22 17:12 jslefche