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

posted by Helmut Homepage – Vienna, Austria, 2022-06-01 16:11 (892 d 13:15 ago) – Posting: # 23038
Views: 5,581

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
23,291 posts in 4,891 threads, 1,661 registered users;
92 visitors (0 registered, 92 guests [including 24 identified bots]).
Forum time: 04:26 CET (Europe/Vienna)

I never did anything worth doing by accident,
nor did any of my inventions come by accident;
they came by work.    Thomas Alva Edison

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