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

posted by Helmut Homepage – Vienna, Austria, 2022-06-01 16:11 (548 d 12:35 ago) – Posting: # 23038
Views: 2,505

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,811 posts in 4,783 threads, 1,638 registered users;
28 visitors (0 registered, 28 guests [including 8 identified bots]).
Forum time: 03:46 CET (Europe/Vienna)

Inspiration is constantly in the air.
It’s up to us to develop the sensitivity
to pick up on it.    Herbie Hancock

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