keep it simple! [🇷 for BE/BA]
Hi ElMaestro,
Statler & Waldorf-day today?
Go ahead. I have to repeat myself: Here we are dealing with a balanced, replicated 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
… or:
Here (‼) you could even ignore the entire data structure:
I’m not promoting SAS.
We have to find a way to get the treatment-means from the model Yung-jin is using in
❝ […] 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, replicated 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.

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]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
Helmut Schütz
![[image]](https://static.bebac.at/img/CC by.png)
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes
Dif-tor heh smusma 🖖🏼 Довге життя Україна!
![[image]](https://static.bebac.at/pics/Blue_and_yellow_ribbon_UA.png)
Helmut Schütz
![[image]](https://static.bebac.at/img/CC by.png)
The quality of responses received is directly proportional to the quality of the question asked. 🚮
Science Quotes

Complete thread:
- Reproducing Bear results in Phoenix mittyri 2015-04-14 08:35 [🇷 for BE/BA]
- Bug in bear? Helmut 2015-04-14 14:07
- Bug in bear? mittyri 2015-04-14 20:43
- Bug in bear? Helmut 2015-04-15 02:17
- use the same dataset? yjlee168 2015-04-20 10:13
- Bug in bear? mittyri 2015-04-14 20:43
- Bugs in bear with replicated demo data set? yjlee168 2015-04-15 09:38
- Bugs fixed in bear? yjlee168 2015-04-17 01:21
- Bugs fixed in bear? Helmut 2015-04-17 14:25
- Bugs fixed in bear? yjlee168 2015-04-17 18:50
- Bugs fixed in bear? ElMaestro 2015-04-17 23:14
- lme() in bear yjlee168 2015-04-18 11:12
- lme() in bear ElMaestro 2015-04-18 11:28
- lme() in bear yjlee168 2015-04-18 12:02
- lme() in bear ElMaestro 2015-04-18 13:42
- Mean means Helmut 2015-04-18 14:08
- Mean means ElMaestro 2015-04-18 16:01
- Mean means Helmut 2015-04-19 00:59
- Mean means ElMaestro 2015-04-19 09:14
- LL and AIC Helmut 2015-04-19 11:08
- Confused ElMaestro 2015-04-19 11:42
- LL and AIC Helmut 2015-04-19 11:08
- lsmeans for mixed model in R yjlee168 2015-04-19 23:36
- lsmeans() & lme() Helmut 2015-04-20 01:28
- lsmeans() & lme() yjlee168 2015-04-20 10:23
- lsmeans() & lme() ElMaestro 2015-04-20 10:35
- keep it simple!Helmut 2015-04-20 14:34
- keep it simple! ElMaestro 2015-04-20 15:39
- ML vs. REML Helmut 2015-04-20 16:35
- keep it simple! ElMaestro 2015-04-20 15:39
- keep it simple!Helmut 2015-04-20 14:34
- lsmeans() & lme() Helmut 2015-04-20 01:28
- Mean means ElMaestro 2015-04-19 09:14
- Mean means Helmut 2015-04-19 00:59
- Mean means ElMaestro 2015-04-18 16:01
- Mean means Helmut 2015-04-18 14:08
- lme() in bear ElMaestro 2015-04-18 13:42
- lme() in bear yjlee168 2015-04-18 12:02
- lme() with NA in R yjlee168 2015-04-19 23:44
- lme() in bear ElMaestro 2015-04-18 11:28
- lme() in bear yjlee168 2015-04-18 11:12
- Dataset Helmut 2015-04-18 13:30
- Dataset and lme() in bear yjlee168 2015-04-18 23:14
- Bugs fixed in bear? ElMaestro 2015-04-17 23:14
- Bugs fixed in bear? yjlee168 2015-04-17 18:50
- Bugs fixed in bear? Helmut 2015-04-17 14:25
- Bug in bear? Helmut 2015-04-14 14:07