Tracking down error [Power / Sample Size]

posted by Helmut Homepage – Vienna, Austria, 2020-05-12 11:49 (170 d 18:33 ago) – Posting: # 21427
Views: 4,159

Hi Alyssa,

» Then i continued with the following command but it appeared error: […]

Let’s try to figure it out. Execute this code:
library(PowerTOST)
CVwR    <- 0.426
CV      <- rep(CVwR, 2)
designs <- c("2x3x3", "2x2x3", "2x2x4")
target  <- c(0.80, 0.85, 0.90)
res     <- data.frame(design = rep(designs, each = length(target)),
                      target = target, n = NA, power = NA)
for (j in 1:nrow(res)) {
  res[j, 3:4] <- sampleN.scABEL(CV = CV, design = res$design[j],
                                targetpower = res$target[j],
                                print = FALSE, details = FALSE)[8:9]
}
print(res, row.names = FALSE)


If it works now, fine. If you get the same error, try:
res[1, 3:4] <- sampleN.scABEL(CV = CV, design = "2x3x3",
                              targetpower = 0.8, print = FALSE,
                              details = FALSE)[8:9]
print(res[1, ], row.names = FALSE)


Expected:
 design target  n   power
  2x3x3    0.8 42 0.81976


If you get an error (or something else), let’s see what you have installed. Try this:
p <- c("PowerTOST", "mvtnorm", "stats", "utils",
       "graphics", "grDevices", "cubature",
       "TeachingDemos", "crossdes", "devtools")
i <- data.frame(name = c("R", p),
                version = c(noquote(as.character(getRversion())),
                            rep(NA, length(p))),
                status = c("-", rep("required", 8),
                           rep("suggested", 2)))
for (j in 2:nrow(i)) {
  i[j, 2] <- noquote(as.character(packageVersion(i[j, 1])))
}
print(i, row.names = FALSE)

On my machine:
          name    version    status
             R      4.0.0         -
     PowerTOST 1.4.9.9999  required
       mvtnorm      1.1.0  required
         stats      4.0.0  required
         utils      4.0.0  required
      graphics      4.0.0  required
     grDevices      4.0.0  required
      cubature      2.0.4  required
 TeachingDemos       2.12  required
      crossdes      1.1.1 suggested
      devtools      2.3.0 suggested

If you have [image] <4.0.0, I suggest to update. Then copy the entire library-folder of the old installation over the new installation. When asked whether newer files should be overwritten, answer No. Open the console of the new [image] and execute:
  update.packages(checkBuilt = TRUE, ask = FALSE)
Once done, it should look similar to mine. 1.4.9.9999 is the development version of PowerTOST; on your machine it should be 1.4.9. If one is missing (<NA> in the column version), download/install it.
To get more information about you installation, execute:
  devtools::session_info()
On my machine:
- Session info ---------------------------------------------------------------
 setting  value                       
 version  R version 4.0.0 (2020-04-24)
 os       Windows 7 x64 SP 1         
 system   x86_64, mingw32             
 ui       Rgui                       
 language EN                         
 collate  German_Germany.1252         
 ctype    German_Germany.1252         
 tz       Europe/Vienna               
 date     2020-05-12                 

- Packages -------------------------------------------------------------------
 package       * version    date       lib source       
 assertthat      0.2.1      2019-03-21 [1] CRAN (R 4.0.0)
 backports       1.1.6      2020-04-05 [1] CRAN (R 4.0.0)
 callr           3.4.3      2020-03-28 [1] CRAN (R 4.0.0)
 cli             2.0.2      2020-02-28 [1] CRAN (R 4.0.0)
 crayon          1.3.4      2017-09-16 [1] CRAN (R 4.0.0)
 cubature        2.0.4      2019-12-04 [1] CRAN (R 4.0.0)
 desc            1.2.0      2018-05-01 [1] CRAN (R 4.0.0)
 devtools        2.3.0      2020-04-10 [1] CRAN (R 4.0.0)
 digest          0.6.25     2020-02-23 [1] CRAN (R 4.0.0)
 ellipsis        0.3.0      2019-09-20 [1] CRAN (R 4.0.0)
 fansi           0.4.1      2020-01-08 [1] CRAN (R 4.0.0)
 fs              1.4.1      2020-04-04 [1] CRAN (R 4.0.0)
 glue            1.4.0      2020-04-03 [1] CRAN (R 4.0.0)
 magrittr        1.5        2014-11-22 [1] CRAN (R 4.0.0)
 memoise         1.1.0      2017-04-21 [1] CRAN (R 4.0.0)
 mvtnorm         1.1-0      2020-02-24 [1] CRAN (R 4.0.0)
 pkgbuild        1.0.8      2020-05-07 [1] CRAN (R 4.0.0)
 pkgload         1.0.2      2018-10-29 [1] CRAN (R 4.0.0)
 PowerTOST     * 1.4.9.9999 2020-05-11 [1] local         
 prettyunits     1.1.1      2020-01-24 [1] CRAN (R 4.0.0)
 processx        3.4.2      2020-02-09 [1] CRAN (R 4.0.0)
 ps              1.3.3      2020-05-08 [1] CRAN (R 4.0.0)
 R6              2.4.1      2019-11-12 [1] CRAN (R 4.0.0)
 Rcpp            1.0.4.6    2020-04-09 [1] CRAN (R 4.0.0)
 remotes         2.1.1      2020-02-15 [1] CRAN (R 4.0.0)
 rlang           0.4.6      2020-05-02 [1] CRAN (R 4.0.0)
 rprojroot       1.3-2      2018-01-03 [1] CRAN (R 4.0.0)
 sessioninfo     1.1.1      2018-11-05 [1] CRAN (R 4.0.0)
 TeachingDemos   2.12       2020-04-07 [1] CRAN (R 4.0.0)
 testthat        2.3.2      2020-03-02 [1] CRAN (R 4.0.0)
 usethis         1.6.1      2020-04-29 [1] CRAN (R 4.0.0)
 withr           2.2.0      2020-04-20 [1] CRAN (R 4.0.0)

[1] D:/Program Files/R/R-4.0.0/library

Likely your list will be shorter; please post here what you got.


PS: When you post code/output, please embed it within the respective BBCode. With active JavaScript highlight the text in the message-area and click on the Button Code. THX.

Dif-tor heh smusma 🖖
Helmut Schütz
[image]

The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:

Activity
 Admin contact
21,179 posts in 4,414 threads, 1,474 registered users;
online 7 (0 registered, 7 guests [including 5 identified bots]).
Forum time: Friday 05:22 CET (Europe/Vienna)

The idea is to try and give all the information to help others
to judge the value of your contribution;
not just the information that leads to judgment
in one particular direction or another.    Richard Feynman

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5