[R] package(moments) issue

Bill Dunlap w||||@mwdun|@p @end|ng |rom gm@||@com
Thu Oct 15 21:43:41 CEST 2020


moments::anscombe.test(x) does give errors when x has too few values or if
all the values in x are the same

> moments::anscombe.test(c(1,2,6))
Error in if (pval > 1) pval <- 2 - pval :
  missing value where TRUE/FALSE needed
> moments::anscombe.test(c(2,2,2,2,2,2,2,2))
Error in if (pval > 1) pval <- 2 - pval :
  missing value where TRUE/FALSE needed

You can use tryCatch() to return some special value where these errors
occur.  E.g., use

tryCatch(anscombe.test(x), error=function(e) list(p.value=NA))

instead of ascombe.test (this assumes you will only look at p.value later -
add other entries as needed.).

-Bill

On Thu, Oct 15, 2020 at 12:09 PM Sania Wadud <sania.wadud using gmail.com> wrote:

> Hi all,
>
> While running the anscombe.test in R, I'm getting an error of *Error in if
> (pval > 1) pval <- 2 - pval : missing value where TRUE/FALSE needed* for a
> few time series columns whereas for most of the series the function is
> working fine. I have checked for those specific columns for missing values.
> However, there is no NA/NAN value in the dataset.
>
> I have also run kurtosis for those time series and I can get results. I
> have noticed the same issue was reported in the following post for python
> (scipy.stat) and the report mentions that there is a bug in moments package
> in R. I was wondering whether the issue has been resolved.
>
> https://github.com/scipy/scipy/issues/1950
>
> Could anyone please help me with the error?
>
> I look forward to hearing from you.
>
> Regards,
> Sania
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list