keep it simple! [🇷 for BE/BA]

posted by Helmut Homepage – Vienna, Austria, 2015-04-20 16:34 (3580 d 18:27 ago) – Posting: # 14715
Views: 28,075

Hi ElMaestro,

❝ […] those who had a love affair with SAS' invention.


Statler & Waldorf-day today?

❝ […] one day I will add a package called 'marginal means' and it will do absolutely nothing except alias the lsmeans function to a function called marginal.means and suddenly everything will make a lot more sense. I will receive the Fields Medal for it. At least. Plus 17 Michelin Stars and the Golden Palms.


Go ahead. I have to repeat myself: Here we are dealing with a balanced, repli­cated design and complete data. I’m not (!) dealing with any muddle. I’m averaging subjects’ responses for each treatment and later averaging the means.
Try it in OO Calc

subj drug seq prd lnCmax   meanR   meanT    R(1)    R(2)    T(1)    T(2)
1      1   2   2  7.46107 7.44972 ------- ------- 7.44972 ------- -------
1      1   2   3  7.43838 ------- ------- ------- ------- ------- -------
1      2   2   1  7.39817 ------- 7.40062 ------- ------- ------- 7.40062
1      2   2   4  7.40306 ------- ------- ------- ------- ------- -------
2      1   1   1  7.30047 7.29367 ------- 7.29367 ------- ------- -------
2      1   1   4  7.28688 ------- ------- ------- ------- ------- -------
2      2   1   2  7.51589 ------- 7.51860 ------- ------- 7.51860 -------
2      2   1   3  7.52132 ------- ------- ------- ------- ------- -------
3      1   2   2  7.48437 7.48717 ------- ------- 7.48717 ------- -------
3      1   2   3  7.48997 ------- ------- ------- ------- ------- -------
3      2   2   1  7.63675 ------- 7.63916 ------- ------- ------- 7.63916
3      2   2   4  7.64156 ------- ------- ------- ------- ------- -------
4      1   1   1  7.22548 7.22183 ------- 7.22183 ------- ------- -------
4      1   1   4  7.21818 ------- ------- ------- ------- ------- -------
4      2   1   2  7.39572 ------- 7.39264 ------- ------- 7.39264 -------
4      2   1   3  7.38956 ------- ------- ------- ------- ------- -------
5      1   2   2  7.34923 7.34601 ------- ------- 7.34601 ------- -------
5      1   2   3  7.34278 ------- ------- ------- ------- ------- -------
5      2   2   1  7.23346 ------- 7.23382 ------- ------- ------- 7.23382
5      2   2   4  7.23418 ------- ------- ------- ------- ------- -------
6      1   1   1  7.47079 7.46794 ------- 7.46794 ------- ------- -------
6      1   1   4  7.46508 ------- ------- ------- ------- ------- -------
6      2   1   2  7.32778 ------- 7.32448 ------- ------- 7.32448 -------
6      2   1   3  7.32119 ------- ------- ------- ------- ------- -------
7      1   2   2  7.35628 7.35946 ------- ------- 7.35946 ------- -------
7      1   2   3  7.36265 ------- ------- ------- ------- ------- -------
7      2   2   1  7.40428 ------- 7.40731 ------- ------- ------- 7.40731
7      2   2   4  7.41035 ------- ------- ------- ------- ------- -------
8      1   1   1  7.56993 7.57250 ------- 7.57250 ------- ------- -------
8      1   1   4  7.57507 ------- ------- ------- ------- ------- -------
8      2   1   2  7.38709 ------- 7.39018 ------- ------- 7.39018 -------
8      2   1   3  7.39326 ------- ------- ------- ------- ------- -------
9      1   2   2  7.29641 7.29979 ------- ------- 7.29979 ------- -------
9      1   2   3  7.30317 ------- ------- ------- ------- ------- -------
9      2   2   1  7.47250 ------- 7.47534 ------- ------- ------- 7.47534
9      2   2   4  7.47817 ------- ------- ------- ------- ------- -------
10     1   1   1  7.23562 7.23921 ------- 7.23921 ------- ------- -------
10     1   1   4  7.24280 ------- ------- ------- ------- ------- -------
10     2   1   2  7.30182 ------- 7.30518 ------- ------- 7.30518 -------
10     2   1   3  7.30854 ------- ------- ------- ------- ------- -------
11     1   2   2  7.02731 7.02286 ------- ------- 7.02286 ------- -------
11     1   2   3  7.01840 ------- ------- ------- ------- ------- -------
11     2   2   1  7.42774 ------- 7.43070 ------- ------- ------- 7.43070
11     2   2   4  7.43367 ------- ------- ------- ------- ------- -------
12     1   1   1  7.34084 7.33758 ------- 7.33758 ------- ------- -------
12     1   1   4  7.33433 ------- ------- ------- ------- ------- -------
12     2   1   2  7.12850 ------- 7.13249 ------- ------- 7.13249 -------
12     2   1   3  7.13648 ------- ------- ------- ------- ------- -------
13     1   2   2  7.11883 7.12286 ------- ------- 7.12286 ------- -------
13     1   2   3  7.12689 ------- ------- ------- ------- ------- -------
13     2   2   1  7.38088 ------- 7.38398 ------- ------- ------- 7.38398
13     2   2   4  7.38709 ------- ------- ------- ------- ------- -------
14     1   1   1  7.37651 7.37337 ------- 7.37337 ------- ------- -------
14     1   1   4  7.37023 ------- ------- ------- ------- ------- -------
14     2   1   2  7.44892 ------- 7.45182 ------- ------- 7.45182 -------
14     2   1   3  7.45472 ------- ------- ------- ------- ------- -------
                     mean 7.32814 7.39188 7.35801 7.29827 7.35934 7.42442
                        n 14      14      7       7       7       7

(7.35801+7.29827)/2=7.32814
(7.35934+7.42442)/2=7.39188


… or:

cnames <- c("subj", "drug", "seq", "prd", "Cmax",
  "AUC0t","AUC0INF","lnCmax","lnAUC0t","lnAUC0INF")
TotalData <- read.csv("SingleRep_stat_demo.csv",
  header=T, row.names=NULL, col.names=cnames, sep=",", dec=".")
Cmax <- TotalData[, !(names(TotalData) %in% c("AUC0t", "AUC0INF",
  "lnCmax", "lnAUC0t","lnAUC0INF"))] RSeq1 <- subset(Cmax, (drug == 1 & seq == 1))
RSeq2 <- subset(Cmax, (drug == 1 & seq == 2))
TSeq1 <- subset(Cmax, (drug == 2 & seq == 1))
TSeq2 <- subset(Cmax, (drug == 2 & seq == 2))
RSeq1[, "lnCmax"] <- log(RSeq1$Cmax)
RSeq2[, "lnCmax"] <- log(RSeq2$Cmax)
TSeq1[, "lnCmax"] <- log(TSeq1$Cmax)
TSeq2[, "lnCmax"] <- log(TSeq2$Cmax)
SubjInRSeq1 <- length(RSeq1[, 1])/2
SubjInRSeq2 <- length(RSeq2[, 1])/2
SubjInTSeq1 <- length(TSeq1[, 1])/2
SubjInTSeq2 <- length(TSeq2[, 1])/2
SubjMeansInRSeq1 <- vector("numeric", length=SubjInRSeq1)
SubjMeansInRSeq2 <- vector("numeric", length=SubjInRSeq2)
SubjMeansInTSeq1 <- vector("numeric", length=SubjInTSeq1)
SubjMeansInTSeq2 <- vector("numeric", length=SubjInTSeq2)
for(j in 1:SubjInRSeq1)
  SubjMeansInRSeq1[j] <- (RSeq1$lnCmax[j]+RSeq1$lnCmax[j+SubjInRSeq1])/2
for(j in 1:SubjInRSeq2)
  SubjMeansInRSeq2[j] <- (RSeq2$lnCmax[j]+RSeq2$lnCmax[j+SubjInRSeq2])/2
for(j in 1:SubjInTSeq1)
  SubjMeansInTSeq1[j] <- (TSeq1$lnCmax[j]+TSeq1$lnCmax[j+SubjInTSeq1])/2
for(j in 1:SubjInTSeq2)
  SubjMeansInTSeq2[j] <- (TSeq2$lnCmax[j]+TSeq2$lnCmax[j+SubjInTSeq2])/2
SubjMeansR <- c(SubjMeansInRSeq1, SubjMeansInRSeq2)
SubjMeansT <- c(SubjMeansInTSeq1, SubjMeansInTSeq2)
MeanR <- sum(SubjMeansR)/(SubjInRSeq1+SubjInRSeq2)
MeanT <- sum(SubjMeansT)/(SubjInTSeq1+SubjInTSeq2)
cat("R:", sprintf("%.6f", MeanR),
"\nT:", sprintf("%.6f", MeanT), "\n")

R: 7.328141
T: 7.391880


Here (‼) you could even ignore the entire data structure:

R <- subset(Cmax, drug == 1)
R <- R[, "lnCmax"] <- log(R$Cmax)
T <- subset(Cmax, drug == 2)
T <- T[, "lnCmax"] <- log(T$Cmax)
MeanR <- mean(R)
MeanT <- mean(T)
cat("R:", sprintf("%.6f", MeanR),
"\nT:", sprintf("%.6f", MeanT), "\n")

R: 7.328141
T: 7.391880


I’m not promoting SAS. :-D We have to find a way to get the treatment-means from the model Yung-jin is using in bear – which must agree with the simple / marginal / however-you-like-to-name-them means in a balanced case first. Then we have to check what’s happening to unbalanced datasets.

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
Thread locked

Complete thread:

UA Flag
Activity
 Admin contact
23,376 posts in 4,912 threads, 1,664 registered users;
142 visitors (0 registered, 142 guests [including 3 identified bots]).
Forum time: 10:02 CET (Europe/Vienna)

Every system is perfectly designed
to get the results it gets.    Paul B. Batalden

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