Error message when trying to run mcp2atm post-hoc tests

Hi everyone. So I'm still quite new to this forum, but I'm hoping that somebody can help me.
I have conducted a robust 2 way anova on some data using the "t2way" function from the WRS2 package. I'm trying to run robust post-hoc tests using "mcp2atm" from the WRS2 package, but I keep getting the error message " Error in match.arg(method) : 'arg' must be of length 1"

I have the data saved in an excel spreadsheet, with factor 1( cooking method: s, b, m, f , or p) and factor 2 (storage: as, rs) in seperate columns, then I have the dependent variable (d3) in a seperate column. The data file is called vd3.
I import data from excel into R using the "import dataset" function, and then attempt to run the following code:

mcp2atm(d3 ~ storage * method, data = vd3)
Error in match.arg(method) : 'arg' must be of length 1

Any help will be appreciated, thank you!

How does your case differ?

library(WRS2)

# example from help(t2waybt)

## 2-way ANOVA on trimmed means
t2way(attractiveness ~ gender*alcohol, data = goggles)
#> Call:
#> t2way(formula = attractiveness ~ gender * alcohol, data = goggles)
#> 
#>                  value p.value
#> gender          1.6667   0.209
#> alcohol        48.2845   0.001
#> gender:alcohol 26.2572   0.001
## post hoc tests
mcp2atm(attractiveness ~ gender*alcohol, data = goggles)
#> Call:
#> mcp2atm(formula = attractiveness ~ gender * alcohol, data = goggles)
#> 
#>                     psihat  ci.lower  ci.upper p-value
#> gender1           10.00000  -6.00223  26.00223 0.20922
#> alcohol1          -3.33333 -20.49551  13.82885 0.61070
#> alcohol2          35.83333  19.32755  52.33911 0.00003
#> alcohol3          39.16667  22.46796  55.86537 0.00001
#> gender1:alcohol1  -3.33333 -20.49551  13.82885 0.61070
#> gender1:alcohol2 -29.16667 -45.67245 -12.66089 0.00025
#> gender1:alcohol3 -25.83333 -42.53204  -9.13463 0.00080

str(goggles)
#> 'data.frame':    48 obs. of  3 variables:
#>  $ gender        : Factor w/ 2 levels "Female","Male": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ alcohol       : Factor w/ 3 levels "None","2 Pints",..: 1 1 1 1 1 1 1 1 2 2 ...
#>  $ attractiveness: int  65 70 60 60 60 55 60 55 70 65 ...

Created on 2023-05-09 with reprex v2.0.2

Note that LHS is numeric and RHS are both factor

Hi technocrat,

I have converted the independent variables to factors and that appears to have sorted the issue.
Thanks for your help!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.