0

currently I'm in my master(I'm still a beginner in r) and I've run into an error I can't figure out by myself. I've ran a moderation model (out0) and afterwards I centered it around 0, 10 and 20 and looked at their Simple Slopes. I want to do the same using the RockChalk package in r.

out0 = lm(msq2$TA ~ EA * NegAff + PA, data = msq2)
range(msq2$NegAff) #0:28
plotOut1 <- plotSlopes(out0,
                       plotx      = "EA",
                       modx       = "NegAff",
                       modxVals   = seq(0, 20, 10), #we are centering from 0 to 20 in steps of 10
                       plotPoints = TRUE)

I did this with another dataset and that worked out fine. However, I get this message warning right now:

Error in model.frame.default(myfmla, dataOrig, na.action = na.action) : 
  invalid type (list) for variable 'msq2'
In addition: Warning message:
Using formula(x) is deprecated when x is a character vector of length > 1.
  Consider formula(paste(x, collapse = " ")) instead. 

Could someone please tell me where I'm making a mistake? I assume it is in the way I formulated modxVals but I used different values and that did not work

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • FYI, code blocks begin with three backticks, an optional language specification, *and nothing more*, so please do not put code on the same line as the backticks. Similar,y it is closed with three backticks only, alone on their line. That is, `\`\`\`lang-r\nline1\nline2\n```\n`. See https://stackoverflow.com/editing-help. – r2evans Oct 09 '20 at 17:42
  • Also FYI, when using formulas and the `data=` argument, it is better to *not* include the `msq2$` within the formula, just `lm(TA ~ EA*NegAff + PA, data=msq2)`. While I don't know that that is impacting this **error**, it can have an impact in other situations. – r2evans Oct 09 '20 at 17:44
  • The code and error are fairly clear, the only thing we need to make this question reproducible is *sample data*. Can you reduce your `msq2` to the minimum needed to reproduce this error (e.g., just those four columns, and perhaps 10-20 rows) and post the output from `dput(head(x))` for that subset? Thanks! Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Oct 09 '20 at 17:49

1 Answers1

0

thanks r2evans. simply removing msq2$ answered the question!