Group effect: the endless river [General Statistics]
Dear Breathtakingly Smart People!
Please check my solution...
Below is my R-code:
In order to check whether it works properly I used Data set 1 from Q&A and added group-factor: first 30 subjects - group #1, and the last - group #2.
To compare the results I used the following SAS-code:
Cause I wasn't sure that my code works well I used the step-by-step approach and compared different models (they all may be meaningless by nature but whatever):
1). Sequence Formulation Period as Fixed, Subject(Sequence) as Random
2). Sequence Formulation Period Group as Fixed, Subject(Sequence) as Random
3). Sequence Formulation Period(Group) Group as Fixed, Subject(Sequence) as Random
4). Sequence Formulation Period(Group) Group Sequence*Group as Fixed, Subject(Sequence) as Random
5). Sequence Formulation Period(Group) Group Sequence*Group as Fixed, Subject(Sequence*Group) as Random
The results are as follows:
And now, attention, the questions:
1). Looking the same is not proving to be the same, isn't it?
2). By the way, this is exactly an example where the design changes the decision of BE (of course if scaling was not stated in protocol). BE or not BE?
3). When I try to use Subject(Sequence*Group) as Random in R, it throws an error: "couldn't evaluate grouping factor (Sequence * Group):Subject within model frame: try adding grouping factor to data frame explicitly if possible". Is it right that we can simply neglect the structure of this term as we can do in standard models with Subject instead of Subject(Sequence)?
❝ I agree with PharmCat. Doable in R.
Please check my solution...
Below is my R-code:
library(readxl)
library(lmerTest)
options(contrasts=c("contr.treatment","contr.poly"))
Dataset<-read_excel("DS_01_group.xlsx", sheet = 1)
Model2 <- function(Dataset){
Dataset$Formulation<-factor(Dataset$Formulation, levels = c("R","T"))
Dataset$Sequence<-factor(Dataset$Sequence, levels = c("TRTR", "RTRT"))
Dataset$Period<-factor(Dataset$Period)
Dataset$Group<-factor(Dataset$Group)
mod.lmer <- (lmer(log(Data)~Sequence+Period/Group+Formulation+Group+Group*Sequence+(1|Subject/(Sequence)), data=Dataset))
FormulationEffect.lmer <- summary(mod.lmer)$coefficients["FormulationT","Estimate"]
cat("\n", "PE is", round(exp(as.numeric(FormulationEffect.lmer))*100, digits = 8), "\n")
FormulationT<-summary(mod.lmer)$coefficients["FormulationT",]
CI_Lr<-round(exp(FormulationT[1]+FormulationT[2]*qt(0.05, FormulationT[3]))*100, 4)
CI_Ur<-round(exp(FormulationT[1]-FormulationT[2]*qt(0.05, FormulationT[3]))*100, 4)
cat("\n", "CI is", CI_Lr, "-", CI_Ur,"\n")}
Model2(Dataset)
In order to check whether it works properly I used Data set 1 from Q&A and added group-factor: first 30 subjects - group #1, and the last - group #2.
To compare the results I used the following SAS-code:
proc mixed data=SASuser.Dataset;
class Formulation Subject Period Sequence Group;
model PKlog= Sequence Formulation Period(Group) Group Sequence*Group;
random Subject(Sequence*Group);
estimate "test-ref" Formulation -1 1 / CL alpha=0.10;
run;
Cause I wasn't sure that my code works well I used the step-by-step approach and compared different models (they all may be meaningless by nature but whatever):
1). Sequence Formulation Period as Fixed, Subject(Sequence) as Random
2). Sequence Formulation Period Group as Fixed, Subject(Sequence) as Random
3). Sequence Formulation Period(Group) Group as Fixed, Subject(Sequence) as Random
4). Sequence Formulation Period(Group) Group Sequence*Group as Fixed, Subject(Sequence) as Random
5). Sequence Formulation Period(Group) Group Sequence*Group as Fixed, Subject(Sequence*Group) as Random
The results are as follows:
SAS SAS SAS R R R
# PE 90%CI, L 90%CI, U PE 90%CI, L 90%CI, U
1 115,7298 107,1707 124,9725 115,7298 107,1707 124,9725
2 115,7279 107,1680 124,9716 115,7279 107,1679 124,9716
3 115,7208 107,1080 125,0262 115,7208 107,1080 125,0262
4 115,7275 107,1136 125,0340 115,7275 107,1136 125,0340
5 115,7275 107,1136 125,0340 NA NA NA
And now, attention, the questions:
1). Looking the same is not proving to be the same, isn't it?
2). By the way, this is exactly an example where the design changes the decision of BE (of course if scaling was not stated in protocol). BE or not BE?
3). When I try to use Subject(Sequence*Group) as Random in R, it throws an error: "couldn't evaluate grouping factor (Sequence * Group):Subject within model frame: try adding grouping factor to data frame explicitly if possible". Is it right that we can simply neglect the structure of this term as we can do in standard models with Subject instead of Subject(Sequence)?
—
"Being in minority, even a minority of one, did not make you mad"
"Being in minority, even a minority of one, did not make you mad"
Complete thread:
- Group by sequence interaction Mutasim 2019-08-07 13:16 [General Statistics]
- Group by sequence interaction, an urban myth? Helmut 2019-08-07 14:35
- pristine, genuine, holy, magnificent, inexplicable beautiful variation ElMaestro 2019-08-08 10:06
- I love your subject line! Helmut 2019-08-08 10:31
- Group effect, did you miss it? Astea 2019-12-21 14:12
- Group effect, did you miss it? PharmCat 2019-12-22 01:37
- Group effect: the endless story Helmut 2019-12-22 10:30
- Group effect: the endless riverAstea 2019-12-22 21:23
- Group effect: the endless river PharmCat 2019-12-22 22:52
- replicateBE solution with interactions mittyri 2019-12-23 14:30
- replicateBE solution with interactions Astea 2019-12-23 17:26
- datasets issues mittyri 2019-12-24 10:53
- datasets Helmut 2019-12-24 11:03
- datasets Astea 2019-12-24 19:18
- lmer / lme Helmut 2019-12-25 19:12
- datasets Astea 2019-12-24 19:18
- replicateBE solution with interactions Astea 2019-12-23 17:26
- Group effect: the endless riverAstea 2019-12-22 21:23
- What do you mean exactly? Beholder 2019-12-27 13:44
- What do you mean exactly? Astea 2019-12-29 21:59
- ANOVA acc. to GL Helmut 2019-12-30 12:32
- What do you mean exactly? Astea 2019-12-29 21:59
- Group effect, did you miss it? Astea 2019-12-21 14:12
- I love your subject line! Helmut 2019-08-08 10:31
- pristine, genuine, holy, magnificent, inexplicable beautiful variation ElMaestro 2019-08-08 10:06
- Group by sequence interaction, an urban myth? Helmut 2019-08-07 14:35