I'm unable to solve an unused arguments error I get when using the smd package

137 views Asked by At

I keep getting an 'unused arguments' error when I call the SMD function

I'm using smd() as part of a larger data analysis, comparing groups created through k-means clustering. And it was all working fine... until it wasn't. I'd been editing other parts of the main script - adding a derived variable.

I've puzzled for some time, checking syntax and the code that creates the function arguments. All to no avail. Finally I wrote a short script to see if I had this problem with some very basic data. And I still do. The new script is

library(smd)

Mean_x <- 75
Mean_y <- 25
n_x <- 25
n_y <- 25
sd_x <- 40
sd_y <- 20
temp_smd <- smd(Mean.1=Mean_x, Mean.2=Mean_y, s.1=sd_x, s.2=sd_y, n.1=n_x, n.2=n_y)

... and I get the error message

Error in smd(Mean.1 = Mean_x, Mean.2 = Mean_y, s.1 = sd_x, s.2 = sd_y,  :
unused arguments (Mean.1 = Mean_x, Mean.2 = Mean_y, s.1 = sd_x, s.2 = sd_y, n.1 = n_x, n.2 = n_y)

I even tried smd::smd, in case there was a package conflict that I wasn't aware of.

All help appreciated

3

There are 3 answers

0
ZKA On

You're using two different packages ({MBESS} and {smd}) with two different smd() functions.

In your code above, you use library(smd) which does not take these arguments in the smd() function. And so of course, trying smd::smd gives the same error. After reinstalling {MBESS} (and I'm guessing probably changing the order of library loading), MBESS::smd has taken precedence over smd::smd again, so now it's working again.

1
Phenomniverse On

From the documentation on smd package (https://cran.r-project.org/web/packages/smd/) it looks like smd is looking for the following arguments:

  • x a vector or matrix of values

  • g a vector of at least 2 groups to compare. This should coercable to a factor.

  • w a vector of numeric weights (optional)

  • std.error Logical indicator for computing standard errors using compute_smd_var. Defaults to FALSE.

  • na.rm Remove NA values from x? Defaults to FALSE.

  • gref an integer indicating which level of g to use as the reference group. Defaults to 1.

Whereas your giving it a bunch of different arguments, which the function isn't able to make use of. Your arguments make sense in terms of the mathematical explanation of what smd is supposed to calculate as presented in the documentation, but the documentation doesn't make it clear (at least to me) how the arguments its expecting relate to the number it calculates. If it were me, I'd probably write my own function to do the calculation.

0
Koning_wurm On

Shutting everything down and re-installing the MBESS package seems to have fixed it? It is all working now anyway! :-)