Skip to content

cpa.normal returns error for two examples from help file #220

@jwilliman

Description

@jwilliman

I tried running a few of the examples in the help file and got the following error messages. In particular I wanted to run the calculation with the vector of sample sizes.

library(clusterPower)
#> Warning: package 'clusterPower' was built under R version 4.1.3
# Find the number of clusters per condition needed for a trial with alpha = .05, 
# power = 0.8, 10 observations per cluster, no variation in cluster size, a difference 
# of 1 unit,  ICC = 0.1 and a variance of five units:
## Not run: 
cpa.normal(nsubjects = 10, d = 1, ICC = .1, vart = 5)
#> Error in cpa.normal(nsubjects = 10, d = 1, ICC = 0.1, vart = 5): Exactly one of 'alpha', 'power', 'nclusters', 'nsubjects', 'd' must be NA.

# Find the power achieved when each trial arm has 5 clusters of
# sizes 100, 50, 25, 100, and 100. When a vector of cluster sizes 
# is provided (as in this example), the "ncluster" argument is ignored.

cpa.normal(alpha = .05, power = NA, nsubjects = c(100, 50, 25, 100, 100),
           d = .2, ICC = .1, sigma_b_sq = .1)
#> Error in cpa.normal(alpha = 0.05, power = NA, nsubjects = c(100, 50, 25, : Exactly one of 'alpha', 'power', 'nclusters', 'nsubjects', 'd' must be NA.
sessionInfo()
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_New Zealand.1252  LC_CTYPE=English_New Zealand.1252   
#> [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C                        
#> [5] LC_TIME=English_New Zealand.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] clusterPower_0.7.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.7        later_1.3.0       pillar_1.6.3      compiler_4.1.1   
#>  [5] highr_0.9         mathjaxr_1.4-0    R.methodsS3_1.8.1 R.utils_2.11.0   
#>  [9] iterators_1.0.13  tools_4.1.1       digest_0.6.28     evaluate_0.14    
#> [13] lifecycle_1.0.1   tibble_3.1.5      R.cache_0.15.0    pkgconfig_2.0.3  
#> [17] rlang_0.4.11      reprex_2.0.1      foreach_1.5.1     shiny_1.7.1      
#> [21] yaml_2.2.1        xfun_0.26         fastmap_1.1.0     withr_2.4.2      
#> [25] styler_1.6.2      stringr_1.4.0     knitr_1.36        fs_1.5.0         
#> [29] vctrs_0.3.8       glue_1.4.2        R6_2.5.1          fansi_0.5.0      
#> [33] rmarkdown_2.11    purrr_0.3.4       magrittr_2.0.1    promises_1.2.0.1 
#> [37] backports_1.2.1   codetools_0.2-18  ellipsis_0.3.2    htmltools_0.5.2  
#> [41] xtable_1.8-4      mime_0.12         httpuv_1.6.3      utf8_1.2.2       
#> [45] stringi_1.7.5     crayon_1.4.1      R.oo_1.24.0

Created on 2022-05-10 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions