0

I want to see the interaction of my model of my two groups S and NS. But the errors keeps coming out. I cannot find why. My code was as bellow.

lms= lm(RSFC_Agebyd_DAN ~ 1 + Age + d + RT + IO + CR + Age:d + Age:RT + Age:IO + Age:CR, data = S)
lmNS = lm(RSFC_Agebyd_DAN ~ 1 + Age + d + RT + IO + CR + Age:d + Age:RT + Age:IO + Age:CR, data = NS)

probe_interaction(lmS,pred=d, modx=Age)
probe_interaction(lmNS, pred=d, modx=Age)

The error message was like this:

Error: ! class must be a character vector, not a list. Backtrace:

  1. interactions::probe_interaction(lmNS, pred = d, modx = Age)
  2. interactions::sim_slopes(model = lmNS, modx = Age, pred = d)
  3. jtools:::summ.lm(...)
  4. jtools:::do_robust(model, robust, cluster, data, vcov)
  5. jtools::get_robust_se(...)
  6. jtools::stop_wrap(...)
  7. rlang (local) <fn>(class = <named list>)

The environment:

packageVersion("interactions") [1] ‘1.1.5’ packageVersion("jtools") [1] ‘2.2.1’

R version 4.2.2 (2022-10-31) -- "Innocent and Trusting" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-apple-darwin17.0 (64-bit)

RStudio 2021.09.2 Build 382 macOS Mojave version 10.14.6

Thank you in advance

I reinstalled R, Rstudio, packages, ... But nothing worked.

camille
  • 16,432
  • 18
  • 38
  • 60
daisuke
  • 1
  • 1
  • 1
    [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. Right now the best anybody can really do is guess: your error message says you supplied something as a list instead of a vector. Have you checked that out? – camille Jan 17 '23 at 20:04
  • Hi camille, thank you for your reply. Yes I noticed. But I don't know which list is it. I found the result of lm() is a list. But the examples given in the help text put the result of lm() into probe_interaction() directly. I think there might be some hidden steps in the probe_interaction() function but I don't know how it works. I can not figure more from their guide : https://rdrr.io/cran/interactions/man/probe_interaction.html – daisuke Jan 17 '23 at 20:43
  • This question reported a similar error message: https://stackoverflow.com/q/75120120/2554330 . I wonder if the solution (installing `sandwich`) would also work for you? – user2554330 Jan 17 '23 at 21:43
  • If you know that `lm` returns a list, then clearly you need to extract the "class" element of that list. – Carl Witthoft Jan 17 '23 at 21:58
  • As a side note: your attempt to fit a linear model to 10 variables is guaranteed to fail in any case. Further, how can you have the independent variables include both `Age` and various elements such as `Age:RT` ? You need to figure out which subsets of your data you actually want to fit here. – Carl Witthoft Jan 17 '23 at 22:00
  • `installing sandwich` works!!!!! Thanks a lot!! – daisuke Jan 17 '23 at 22:10
  • Hi Carl, thank you for your reply. Age:RT is the interaction of Age and RT – daisuke Jan 17 '23 at 22:11
  • Just for the record: In this GitHub issue the problem has been reported to the maintainer of the `interactions` and `jtools` packages. Hopefully, this helps to avoid the problem in future versions of the package. https://github.com/jacob-long/jtools/issues/132 – Achim Zeileis Jan 18 '23 at 01:03

0 Answers0