Skip to content
Prev 386008 / 398525 Next

package(moments) issue

Another bad case is
    > moments::anscombe.test(rep(c(1,1.1),length=35))
    Error in if (pval > 1) pval <- 2 - pval :
      missing value where TRUE/FALSE needed

I haven't checked the formulas carefully, but I suspect the problem is from
taking the cube root of a negative number in
    z <- (1 - 2/(9 * a) - ((1 - 2/a)/(1 + xx * sqrt(2/(a -
4))))^(1/3))/sqrt(2/(9 * a))
In R, the cube root (or any non-integral power) of a negative real number
is NaN and  ((1 - 2/a)/(1 + xx * sqrt(2/(a - 4))))
is c. -928 in this example.  I think the intent was for the cube root to be
a negative real, c. -9.76, in this case.

If that is the intent, then a fix is to define a cube_root function for
reals
   cube_root <- function (x) sign(x) * abs(x)^(1/3)
and change the z<-... line to use cube_root() instead of ^(1/3).
    z <- (1 - 2/(9 * a) - cube_root(((1 - 2/a)/(1 + xx * sqrt(2/(a -
4))))))/sqrt(2/(9 * a))

-Bill
On Thu, Oct 15, 2020 at 3:15 PM Sania Wadud <sania.wadud at gmail.com> wrote: