Skip to content

probe_interaction() does not work with centered = "none", digits = 3 #50

@nadyamajeed

Description

@nadyamajeed

sim_slopes(..., centered = "none", digits = 3, ...) can be used when centring of terms is unwanted and when 3 decimal places is wanted, but probe_interaction(), which calls on sim_slopes(), does not allow both centered = "none" and digits = 3 at the same time, with the following error: Error in digits + 1L : non-numeric argument to binary operator.

centered = "none" and digits = 3 can, however, be used separately.

Reproducible example:

set.seed(0)
data = data.frame(x = c(0,0,0,0,0,0,0,1,1,1,1), m = -5:5, c = rnorm(11))
data$y = 5 * data$x * data$m + rnorm(11)

res = lm(y ~ x*m + x*c, data = data)
summary(res)

# these can run
interactions::sim_slopes(res, pred = x, modx = m)
interactions::sim_slopes(res, pred = x, modx = m, centered = "none", digits = 3)

# these can run
interactions::probe_interaction(res, pred = x, modx = m)
interactions::probe_interaction(res, pred = x, modx = m, centered = "none")
interactions::probe_interaction(res, pred = x, modx = m, digits = 3)

# this wont run
interactions::probe_interaction(res, pred = x, modx = m, centered = "none", digits = 3)
# Error in digits + 1L : non-numeric argument to binary operator

Setting digits = 5, on the other hand, gives output with 324 decimal places

Code:
interactions::probe_interaction(res, pred = x, modx = m, centered = "none", digits = 5)

Output:

There were 16 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
2: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
3: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
4: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
5: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
6: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
7: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
8: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
9: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
10: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
11: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
12: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
13: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
14: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
15: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324
16: In formatC(x, digits = digits, format = format) : 'digits' reduced to 324

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