Skip to content

interact_plot errors with scale-ed variables  #33

Description

@mattansb
library(interactions)

iris$Sepal.Length_c <- scale(iris$Sepal.Length, center = TRUE, scale = FALSE)
iris$Sepal.Width_c <- 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)
#> Error: variables 'Sepal.Length_c', 'Sepal.Width_c' were specified with different types from the fit

However this doesn't happen with sim_slopes or johnson_neyman.

sim_slopes(fit, pred = Sepal.Length_c, modx = Sepal.Width_c)
#> JOHNSON-NEYMAN INTERVAL 
#> 
#> When Sepal.Width_c is OUTSIDE the interval [-10.36, -2.05], the slope of
#> Sepal.Length_c is p < .05.
#> 
#> Note: The range of observed values of Sepal.Width_c is [-1.06, 1.34]
#> 
#> SIMPLE SLOPES ANALYSIS 
#> 
#> Slope of Sepal.Length_c when Sepal.Width_c = -0.44 (- 1 SD): 
#> 
#>   Est.   S.E.   t val.      p
#> ------ ------ -------- ------
#>   1.53   0.10    14.78   0.00
#> 
#> Slope of Sepal.Length_c when Sepal.Width_c =  0.00 (Mean): 
#> 
#>   Est.   S.E.   t val.      p
#> ------ ------ -------- ------
#>   1.75   0.06    27.64   0.00
#> 
#> Slope of Sepal.Length_c when Sepal.Width_c =  0.44 (+ 1 SD): 
#> 
#>   Est.   S.E.   t val.      p
#> ------ ------ -------- ------
#>   1.97   0.09    21.75   0.00

johnson_neyman(fit, pred = Sepal.Length_c, modx = Sepal.Width_c)
#> JOHNSON-NEYMAN INTERVAL 
#> 
#> When Sepal.Width_c is OUTSIDE the interval [-10.36, -2.05], the slope of
#> Sepal.Length_c is p < .05.
#> 
#> Note: The range of observed values of Sepal.Width_c is [-1.06, 1.34]

Created on 2020-03-13 by the reprex package (v0.3.0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions