A small point for the code [GxP / QC / QA]

posted by Helmut Homepage – Vienna, Austria, 2022-06-01 16:11 (688 d 06:30 ago) – Posting: # 23038
Views: 3,351

Hi Sameep,

corrected in the meantime; use:
    nseq       <- length(unique(data$Sequence))
    seqs       <- character()
    for (subj in seq_along(subjects)) {
      seqs <- c(seqs, unique(as.character(
                               data$Sequence[data$Subject ==
                                             subjects[subj]])))
      if (length(unique(seqs)) >= nseq) break
    }
    ow         <- options("digits") # Save original options
    options(digits = 12) # More digits for anova
    on.exit(ow)          # Ensure that options are reset if an error occurs
    for (i in subj:n) {
      tmp               <- head(data, i * 2)
      res$subjects[i-1] <- length(unique(tmp$Subject))
      # Acc. to GLs: Nested model is bogus; Subject works as well
      m                 <- lm(log(Cmax) ~ Sequence +
                                          Subject %in% Sequence +
                                          Period +
                                          Treatment, data = tmp)
      res$PE[i-1]       <- exp(coef(m)[["TreatmentT"]])
      if (res$subjects[i-1] > nseq) {
        res[i-1, 3:4]  <- as.numeric(exp(confint(m, "TreatmentT",
                                                 level = 1 - 2 * alpha)))
        res$MSE[i-1]   <- anova(m)[["Residuals", "Mean Sq"]]

        res$CV[i-1]    <- 100 * mse2CV(res$MSE[i-1])
        res$power[i-1] <- suppressMessages( # if unbalanced
                            power.TOST(CV = res$CV[i-1] / 100,
                                       theta0 = res$PE[i-1],
                                       n = length(unique(tmp$Subject))))
        if (res$lower[i-1] >= theta1 & res$upper[i-1] <= theta2)
          res$BE[i-1] <- TRUE
      }
    }
    res            <- res[complete.cases(res), ] # Remove NAs

Dif-tor heh smusma 🖖🏼 Довге життя Україна! [image]
Helmut Schütz
[image]

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

Complete thread:

UA Flag
Activity
 Admin contact
22,988 posts in 4,825 threads, 1,661 registered users;
98 visitors (0 registered, 98 guests [including 8 identified bots]).
Forum time: 22:41 CEST (Europe/Vienna)

The only way to comprehend what mathematicians mean by Infinity
is to contemplate the extent of human stupidity.    Voltaire

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