getting information out of Rao test output
?s 18:04 de 08/01/2023, Nick Wray escreveu:
Hello I'm using the Rao Spacing test from the circular package on a series of (circular) data vectors but I can't find a way of simply recording whether the null is rejected or not for each vector in the series - the test gives me an individual result but unlike with other tests in R (say MannKendall or pettitt etc) I can't find a way of delving into the guts of the output to extract either1)both the test statistic and critical value or 2)the status of ejection or not of the null eg as T/F I''ve tried various things including str(rao) and rao[[1]] as.character(rao) etc rao<-rao.spacing.test(pi_data,alpha=0.05) ## my input Rao's Spacing Test of Uniformity Test Statistic = 169.6952 Level 0.05 critical value = 155.19 Reject null hypothesis of uniformity-- can't break this down Des anyone know how I could do this? Thanks, Nick Wray [[alternative HTML version deleted]]
______________________________________________ R-help at 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.
Hello,
This test returns a non-standard object, meaning, not an object of class
"htest" and its print method creates and invisibly returns an object
with the value you want.
library(circular)
#>
#> Attaching package: 'circular'
#> The following objects are masked from 'package:stats':
#>
#> sd, var
# data
x <- circular(runif(200, 0, 2*pi))
# run the test
test_result <- rao.spacing.test(x, alpha=0.1)
# save the print method result
print_result <- print(test_result)
#>
#> Rao's Spacing Test of Uniformity
#>
#> Test Statistic = 135.2864
#> Level 0.1 critical value = 140.06
#> Do not reject null hypothesis of uniformity
print_result$accepted
#> [1] TRUE
If you run
getAnywhere("print.rao.spacing.test")
you will see that the printing is made by a series of cat instructions
so to get the TRUE/FALSE above you will need to print the result like above.