ABBREVIATIONS

A Active Drug

B Placebo

Baseline BP B0

BP Blood Pressure [in mmHG]

CV Cardio Vascular Disease

DOD Difference of Difference (T test)

LM linear model

MDS Multi-dimension scaling

TRT Treatment either placebo or Drug Beta blocker

RCT Randomized Clinical Trial

RM Repeated Measures

RTM Regression to the Mean

RV Random Variable

SD Standard deviation

| Given that

:: Packages R

GOAL

The study of longitudinal data is a challenge for Scientists ,Students and practitioner because one wants to make inference and modelling but often failed to account for RM in their classic statistical tests : Assumptions are broken and is a flaw in publications : As result coefficient might be still reflect true value but the SE of coefficient or test or inflated1.

The main subject here is how including a baseline as a co variate act on your “Linear parameters” model prediction.

We present a short analysis as follow:

RCT and DATA

Beta blocker and Reserpine like drugs3 has been proven significantly efficient in CV diseases (Stroke,Infarction,BP reduction etc), this since the 60’s which was the golden age of these discoveries.

The physiological mechanisms are:

Covariates : Sex,Age and a Baseline [BP0] record.

Response: Yit are the BP at 1 months intervals: [BP0] BP1 BP2 BP3 BP4

Duration 4 months follow-up from Baseline inwards.

Note: Data from ID1 was removed to create unbalanced design and show up difficulties in running within subject ANOVA..

Note that Baseline is one a covariate once as a real measure in time=0 and we will explore how this possibilities act for inferences and modelling.

Know your Data: Use Systematic reviewing

The data come form the book CLINICAL DATA ANALYSIS USING R (Chen & Peace , 2011) data extracted from the 1967 Trial: Some question arouse:
Does the author have copied partially the data? Does it exist an metadata of the DOE ?

Such questions must be answered before proceeding to the analysis.

Note that 20 id in Placebo group B and 20[-1]5 id in trt group [A] seems to be a phase II trial as n is low and the reader should bear in mind at this stage of analysis non significant result might come from the too low power of the study design, especially in longitudinal data.

In present study reader must be aware that regression to the mean might occur when :

1: When part of a population with abnormal value are selected

2: Random process occur under Normal law

3: In repeated measures RTM is exclusively noticeable

Note : could be attributed to the Placebo effect from practitioner

By RCT design we expect that RTM is the same magnitude in both arms and hence is accounted for in assignment of trt.

From the author:

We won’t account for sake of simplicity in the design, study of within between subject and LMM: They will be exposed in other blog hence Using lm in Longitudinal data is a flaw as RM are correlated: However coefficients are usually usable but the SE for inferences not.

We also try to use different plotting packages i.e :: ggplot2 and lattice to present the reader the pro and cons of each one.(let at your appraisal)

Data summary

## [1] "GROUP A= TRTEATMENT B= PLACEBO"
RAW DATA BP
id trt baseline bp1 bp2 bp3 bp4 age sex
2 Drug 116 113 112 103 101 51 M
3 Drug 119 115 113 104 98 48 F
4 Drug 115 113 112 109 101 42 F
5 Drug 116 112 107 104 105 49 M
6 Drug 117 112 113 104 102 47 M
7 Drug 118 111 100 109 99 50 F
8 Drug 120 115 113 102 102 61 M
9 Drug 114 112 113 109 103 43 M
10 Drug 115 113 108 106 97 51 M
11 Drug 117 112 110 109 101 47 F
12 Drug 116 115 113 109 102 45 M
13 Drug 119 117 110 106 104 54 F
14 Drug 118 115 113 102 99 52 M
15 Drug 115 112 108 105 102 42 M
16 Drug 114 111 111 107 100 44 F
17 Drug 117 114 110 108 102 48 M
18 Drug 120 115 113 107 103 63 F
19 Drug 114 113 109 104 100 41 M
20 Drug 117 115 113 109 101 51 M
21 Placebo 114 115 113 111 113 39 M
22 Placebo 116 114 114 109 110 40 F
23 Placebo 114 115 113 111 109 39 F
24 Placebo 114 115 113 114 115 38 M
25 Placebo 116 113 113 109 109 39 F
26 Placebo 114 115 114 111 110 41 M
27 Placebo 119 118 118 117 115 56 F
28 Placebo 118 117 117 116 112 56 M
29 Placebo 114 113 113 109 108 38 M
30 Placebo 120 115 113 113 113 57 M
31 Placebo 117 115 113 114 115 47 F
32 Placebo 118 114 112 109 110 48 M
33 Placebo 121 119 117 114 115 61 F
34 Placebo 116 115 116 114 111 49 M
35 Placebo 118 118 113 113 112 52 M
36 Placebo 119 115 115 114 111 55 F
37 Placebo 116 114 113 109 109 45 F
38 Placebo 116 115 114 114 112 42 M
39 Placebo 117 115 113 114 115 49 F
40 Placebo 118 114 114 114 115 50 F
SUMMARY WIDE DATA BP.CSV
id trt baseline bp1 bp2 bp3 bp4 age sex
Min. : 2.0 Drug :19 Min. :114.0 Min. :111.0 Min. :100.0 Min. :102.0 Min. : 97.0 Min. :38.00 Length:39
1st Qu.:11.5 Placebo:20 1st Qu.:115.0 1st Qu.:113.0 1st Qu.:112.0 1st Qu.:106.5 1st Qu.:101.5 1st Qu.:42.00 Class :character
Median :21.0 NA Median :117.0 Median :115.0 Median :113.0 Median :109.0 Median :108.0 Median :48.00 Mode :character
Mean :21.0 NA Mean :116.7 Mean :114.3 Mean :112.4 Mean :109.4 Mean :106.7 Mean :47.95 NA
3rd Qu.:30.5 NA 3rd Qu.:118.0 3rd Qu.:115.0 3rd Qu.:113.0 3rd Qu.:113.5 3rd Qu.:112.0 3rd Qu.:51.50 NA
Max. :40.0 NA Max. :121.0 Max. :119.0 Max. :118.0 Max. :117.0 Max. :115.0 Max. :63.00 NA
## [1] "How to process data from wide to long format creating a time variable in one RM variable SCORE is given in the attached code: Long format are desired in eased plotting and mixed models analysis"

About Baseline B0

PLOTING LONGITUDINAL DATA

xyplot by id faceted

  • Both trt result in lowering BP after 4M The magnitude is greater in trt Drug group.
  • Slope is lower in Placebo group
  • Linearity in both group might be a crude assumptions
  • Concave downwards occurred in Drug Group showing an accelerated effect
  • Inflection point seems to occur at 2 Months
  • ID 6 & / show erratic/antagonist pattern and might increase variance at that time point.

Spaghetti plot id trajectories

Longitudinal data show often an increased variances in Time due to trt effect, between id difference and within variances: To account for such “type” of variance is not an easy task and terminology between statistician not compatible.

Here we not a first phase a between id variance (“space between point”) B0 and at B2 we notciced some individualization

At time 2-3 the between variance as taken larger values and the 6-7 contribute to the pattern also

At the end of the study we see clustered trt individualization and a stable between patients variance.

Now i will present on lattice same plot faceted by trt:

Spaguetti plot: id trajectories | trt

Wiggly pattern occur on both groups

Pronounced slopping is obvious in trt Drug group

Clear group cluster occur after 4 Months. We will try in another blog with MDS techniques to catch that similarities pattern.

Flattening up (concave upwards) in the Placebo group is also noticeable vs concave down pattern in the Druag arm that is polynomial in LM might be expected; negative vs positive > 1 order coefficients to occurs .

Mean Plot

In the A group a step-down slop occurs after 2 months of active drug Conversely flattening occurs in the Placebo group after 2 months. A linear assumptions might be a crude assumptions but for a accurate modelling ; piece linear of polynomial trend should be envisioned to capture the pattern at 2-3 months periods.

Mean and difference between arm is given in the below table (mmHG):

Drug Placebo difference
baseline 116.6842 116.7500 0
bp1 113.4211 115.2000 -2
bp2 110.5789 114.0500 -4
bp3 106.1053 112.4500 -6
bp4 101.1579 111.9500 -10

Often student are face with difficulties and limited eased with statistical Technics:

Shall i used 2 RM & or T test or should i go wih advanced Technics?

We propose and will present stepped analysis form basic to advance (obviously more correct statistical procedure) using from eluded info to full information/power of data.

From Baseline to a 4 Months time points *[Naive*6] A 2RM

Some figures check to asses some of the assumptions for further inferences:

## [1] "BP baseline value"
##     Drug  Placebo 
## 116.6842 116.7500
## [1] "sd B0 value"
##     Drug  Placebo 
## 2.007297 2.438183
## [1] "Difference from baseline to 4M"

About the research question: The effect of TRT

##     Drug  Placebo 
## 15.56211  4.77000
## [1] "A drop of 15 mmHG might be expected by trt  vs 5 mmHG in Placebo arms"
  • Drop from baseline mean at 4 Month trt mean: B 4.77 / A 15.56 mmHG**

Pooled B0 SD about: 2.2 mmHG

That is:

  • Drop is greater than resp.pooled sd

  • High effect size might be expected even in PLA group.

  • Design experiment plans usually a >= 10 mmHg drop as first clinical intention (i.e Captopril ECA inhibitor).

Inferencial T-Test

Although not planned to discuss deeply in this blog (normality etc) we report two type of t.test:

  1. 2 sample T test pooled variance at 4Months [Naive approach]

  2. D-o-D T.test pooled variance

Lets graphs first the boxplot of the difference time 4M to baseline value:

Note he that taking a difference remove outlier and create a new RV. The eyes of the “JCVD aware statistician” can tell that if no overlapping(indentation of IQR segment occur a significant difference between arms is likely to occur: Let test it:

## [1] "T-test 4month point"
## 
##  Two Sample t-test
## 
## data:  BP$bp4 by BP$trt
## t = -15.046, df = 37, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group Drug and group Placebo is not equal to 0
## 95 percent confidence interval:
##  -12.245436  -9.338774
## sample estimates:
##    mean in group Drug mean in group Placebo 
##              101.1579              111.9500

Now a clever way to use baseline is to make a DO-D T test:

## [1] "T-test DOD difference [Baseline-4months] value score"
## 
##  Two Sample t-test
## 
## data:  BP$baseline - BP$bp4 by BP$trt
## t = 13.203, df = 37, p-value = 1.427e-15
## alternative hypothesis: true difference in means between group Drug and group Placebo is not equal to 0
## 95 percent confidence interval:
##   9.080235 12.372397
## sample estimates:
##    mean in group Drug mean in group Placebo 
##              15.52632               4.80000
## [1] "print making the difference between 2 RV (BBO-B4) remove covariance as pairing  the data within groups:Mistake Often seen: don't put Paired =true between two group as group are independant each other: that is only the RM obesrvations within an ID in group that is paired"

CONFINT: [9.34-12.24]

CONFINT: [9.08-12.37]

The interpretation is left at the reader : However note that usually we expect with DOD more precise and difference in the result but here not as much as expected. even less

What could be the explanation?

Looking at correlation / covariance in both arms presented below and which value is below <0.5 might explain why such result occurs.

Differentiating is not removing as much covariance from the DoD test VAR[X-Y] = VARX + VARY - 2 COV XY

This might be a sign also to researcher, that a linear assumptions between baseline and time point 4 might be doubtful due to low correlations (See xyplot by id above) and a CPS (Compound Symmetry structure) of the COV matrix might be doubtful.

Exploring Correlations and variability type:

Correlation B0-B4:

TRT COR B0-BP4M
A : Dru 0.10
B : Pla 0.45
Overall 0.12

and About the sd:

Sd by time
Drug Placebo
0 1.9 2.1
1 1.7 1.6
2 3.3 1.7
3 2.6 2.5
4 2.0 2.4


Linear model

Using BP4 for modelling [Naive]7

Here Baseline will be considered as a Fixed controlled co-variate, not a time co-variate,that is not changing with time.

Note: For sake of short we wont analysis the normality of errors and other assumptions

Note : Note on Contrasts:

To have a possible lowering trend value of the active trt contrast should be done as “TREATMENT” contrast to the reference Placebo group = B as reference level factor.We expect under this kind of contrast a negative regression coefficient for the active drug A if effective.

Remark:

If you want an orthogonal testing lm ANOVA type III, contrast must be set to sum!.

## [1] "confirm type of contrast set and change to PLACEBO 0 as refs"
##         Placebo
## Drug          0
## Placebo       1
##         Drug
## Placebo    0
## Drug       1

ANOVA like X=TRT vs additive ANCOVA X= TRT+B08

m1 = “lm(BP\(bp4~BP\)trt)”

m2 = “lm(BP\(bp4~BP\)trt+BP$baseline)”

On simple linear model as TRT is a factor the beta coefficients reflect the decrease in mean in BP from placebo to trt (contr trt ref PLA) and baseline , a continuous covariates represent a slope respectively.

What is special in this presented Technics here :

  • An Interaction in m2 between baseline(static Xi) and trt as no meaning due to randomization and equal value pf B0

- Baseline Wald test and value must not be interpreted.

- Including a baseline as a [usually] a massive impact on SE if cor TRT-B0 > 0.5

## 
## Call:
## lm(formula = BP$bp4 ~ BP$trt)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -4.158 -1.950  0.050  1.446  3.842 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 111.9500     0.5006  223.61   <2e-16 ***
## BP$trtDrug  -10.7921     0.7173  -15.05   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.239 on 37 degrees of freedom
## Multiple R-squared:  0.8595, Adjusted R-squared:  0.8557 
## F-statistic: 226.4 on 1 and 37 DF,  p-value: < 2.2e-16
## 
## Call:
## lm(formula = BP$bp4 ~ BP$trt + BP$baseline)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9210 -1.6971 -0.2505  1.5233  4.0676 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  73.4793    20.3855   3.604 0.000939 ***
## BP$trtDrug  -10.7704     0.6937 -15.525  < 2e-16 ***
## BP$baseline   0.3295     0.1746   1.888 0.067149 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.165 on 36 degrees of freedom
## Multiple R-squared:  0.8722, Adjusted R-squared:  0.8651 
## F-statistic: 122.8 on 2 and 36 DF,  p-value: < 2.2e-16

\[ \operatorname{\widehat{BP\$bp4}} = 111.95 - 10.79() \] \[ \operatorname{\widehat{BP\$bp4}} = 73.48 - 10.77() + 0.33(\operatorname{BP\$baseline}) \]

## [1] "confidence intervals of coeeficients m1 vs m2"
##              2.5 % 97.5 %
## (Intercept) 110.94 112.96
## BP$trtDrug  -12.25  -9.34
##              2.5 % 97.5 %
## (Intercept)  32.14 114.82
## BP$trtDrug  -12.18  -9.36
## BP$baseline  -0.02   0.68
  • Fitted value
## [1] "plot m1 fitted values"

## [1] "plot m2 fitted values"

TRT is highly significant in both models.

Recall: On simple linear model with TRT is a factor the beta coefficients reflect the decrease in mean in BP from placebo (contrast trt ref PLA)

The SE of the TRT including a baseline is a of little gain in precision hence Inference but usually when higher correlation TRT -B= exist SE are far more impressive.Now the lm is a conditional model for each Xi!

Note the T value for baseline is the same for anova model comparison

Note the Anova model comparison is a limited value here anova(m1,m2)

A little gain is done here in this dataset with but with prediction points of view a lot is done by adding a continuous covariates (ANCOVA sensus.lato) vs an ANOVA: lm as E(Y|X) is always better that the mean.

However the prediction of the drug A is fairly in accordance with true value.

  • Anova model comparison TYPE I vs III unbalanced design

We notice a slight but negligible difference in type I and III due to missing ID1 unbalanced:

## [1] "lm(BP$bp4~BP$baseline+BP$trt, contrasts=sum)"
## Anova Table (Type III tests)
## 
## Response: BP$bp4
##              Sum Sq Df  F value    Pr(>F)    
## (Intercept)   60.91  1  12.9924  0.000939 ***
## BP$baseline   16.71  1   3.5634  0.067149 .  
## BP$trt      1129.97  1 241.0299 < 2.2e-16 ***
## Residuals    168.77 36                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] "Type I"
##             Df Sum Sq Mean Sq F value Pr(>F)    
## BP$trt       1 1134.8  1134.8 242.067 <2e-16 ***
## BP$baseline  1   16.7    16.7   3.563 0.0671 .  
## Residuals   36  168.8     4.7                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

LM Model; Y response = Difference from baseline

Now lets explore an DOD Y | X = (BP4- BPbaseline) “like” regression with & without baseline in the X covariate

m3 = lm(BP\(bp4-BP\)Baseline~BP$trt)

m2 = lm(BP$bp4-BP$baseline~BP$trt+BP$baseline)

## 
## Call:
## lm(formula = BP$diff4b ~ BP$trt)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -5.474 -1.837 -0.200  1.526  5.800 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -4.8000     0.5670  -8.465 3.50e-10 ***
## BP$trtDrug  -10.7263     0.8124 -13.203 1.43e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.536 on 37 degrees of freedom
## Multiple R-squared:  0.8249, Adjusted R-squared:  0.8202 
## F-statistic: 174.3 on 1 and 37 DF,  p-value: 1.427e-15
## 
## Call:
## lm(formula = BP$diff4b ~ BP$baseline + BP$trt)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9210 -1.6971 -0.2505  1.5233  4.0676 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  73.4793    20.3855   3.604 0.000939 ***
## BP$baseline  -0.6705     0.1746  -3.841 0.000478 ***
## BP$trtDrug  -10.7704     0.6937 -15.525  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.165 on 36 degrees of freedom
## Multiple R-squared:  0.8758, Adjusted R-squared:  0.8689 
## F-statistic: 126.9 on 2 and 36 DF,  p-value: < 2.2e-16
##              2.5 % 97.5 %
## (Intercept)  -5.95  -3.65
## BP$trtDrug  -12.37  -9.08
##              2.5 % 97.5 %
## (Intercept)  32.14 114.82
## BP$baseline  -1.02  -0.32
## BP$trtDrug  -12.18  -9.36

\[ \operatorname{\widehat{BP\$bp4}} = 111.95 - 10.79() \] \[ \operatorname{\widehat{BP\$bp4}} = 73.48 - 10.77() + 0.33(\operatorname{BP\$baseline}) \]

  • Fitted values

  • Here nothing is really gain in R2 squared including a baseline in Xis (but nothing is really lost too)!

  • No co-linearity is observed in the hat matrix because it depends only on X (VIF ::car Variance inflation factor): However we usually check co-linearity with 2 continuous variables but including baseline left and right from the equation is not ill conditioned matrix result.We will comment how tha hat matrix behave in this parametrization in a next blog. VIF check:

    ## [1] "VIF m4"
    ## BP$baseline      BP$trt 
    ##    1.000274    1.000274

    Note : At this stage the proposal of robust estimator is not of interest no repeated measures designed are made here on Yis even subtraction baseline (correlation is removed).

Which simple lm model should we choose m2 vs m4 ? :

Lets summarize the models performance:

```
## 
## Call:
## lm(formula = BP$bp4 ~ BP$trt + BP$baseline)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9210 -1.6971 -0.2505  1.5233  4.0676 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  73.4793    20.3855   3.604 0.000939 ***
## BP$trtDrug  -10.7704     0.6937 -15.525  < 2e-16 ***
## BP$baseline   0.3295     0.1746   1.888 0.067149 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.165 on 36 degrees of freedom
## Multiple R-squared:  0.8722, Adjusted R-squared:  0.8651 
## F-statistic: 122.8 on 2 and 36 DF,  p-value: < 2.2e-16
```

```
## 
## Call:
## lm(formula = BP$diff4b ~ BP$baseline + BP$trt)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9210 -1.6971 -0.2505  1.5233  4.0676 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  73.4793    20.3855   3.604 0.000939 ***
## BP$baseline  -0.6705     0.1746  -3.841 0.000478 ***
## BP$trtDrug  -10.7704     0.6937 -15.525  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.165 on 36 degrees of freedom
## Multiple R-squared:  0.8758, Adjusted R-squared:  0.8689 
## F-statistic: 126.9 on 2 and 36 DF,  p-value: < 2.2e-16
```

Well R2 sq are similar , RMSE the same:

As advice choose the m2 model lm BP4~Baseline + trt in the original scale that the one mostly used in preliminary analysis.[see Zhang,2014]

The wrong way to do the analysis when I was a student…

Wide format data and BPt considered as a factor time!

summary(lm(BP\(bp4~BP\)bp1+BP\(bp3+BP\)baseline+BP$trt)) Not commented…

Preliminary conclusions :

Including baseline as covariate (X) improve definitely the prediction of your model and might characterize better the value of an effect but also provides you more precise Confint , SE of Coeff, especially if correlation is above 0.5.

LONGITUDINAL ANALYSIS: Full information of time effect

Let first explore the possibility of an interactions time * trt effect: As mentioned Interactions , that is slope in time with trt can be easily visualized as such on the interaction plot. Time*trt effect show how the magnitude of drugs acts in time (and induce a increase in overall variance )

Therefore it might be assessed that trt difference between arms is effective in time elapsed: (fan out sloping)

Before all you dataset must be revamped in long format and adding a static baseline in long format is not an easy task and should be checked against proceedings dataframe (dim/length fx)

id trt age sex bp Score time
2 Drug 51 M baseline 116 0
3 Drug 48 F baseline 119 0
4 Drug 42 F baseline 115 0
5 Drug 49 M baseline 116 0
6 Drug 47 M baseline 117 0
7 Drug 50 F baseline 118 0

1: Lets explore a basic longitudinal model where baseline is included as a dynamic time points:

  1. (ml1 Y~only time)

  2. ml2 Y~time+trt

  3. ml3 time*trt (ANCOVA)

## [1] "confirm type of contrast set and change to PLACEBO 0 as refs"
##         Drug
## Placebo    0
## Drug       1
## [1] "set PLACEBO=B AS REF [0;0]"
##         Drug
## Placebo    0
## Drug       1
## [1] "ml1"
## 
## Call:
## lm(formula = Score ~ time, data = new)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11.8923  -2.3897   0.1077   2.1051   8.1128 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 116.8974     0.4560  256.37   <2e-16 ***
## time         -2.5026     0.1861  -13.44   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.676 on 193 degrees of freedom
## Multiple R-squared:  0.4836, Adjusted R-squared:  0.4809 
## F-statistic: 180.7 on 1 and 193 DF,  p-value: < 2.2e-16
## [1] "ml2"
## 
## Call:
## lm(formula = Score ~ time + trt, data = new)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.5895 -1.8347 -0.0851  2.4054  5.9251 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 119.0851     0.4142  287.53   <2e-16 ***
## time         -2.5026     0.1474  -16.98   <2e-16 ***
## trtDrug      -4.4905     0.4169  -10.77   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.91 on 192 degrees of freedom
## Multiple R-squared:  0.6781, Adjusted R-squared:  0.6747 
## F-statistic: 202.2 on 2 and 192 DF,  p-value: < 2.2e-16
## [1] "ml3"
## 
## Call:
## lm(formula = Score ~ time * trt, data = new)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.5895 -1.4263 -0.2632  1.5737  4.4500 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  116.5500     0.3896 299.174  < 2e-16 ***
## time          -1.2350     0.1590  -7.765 4.84e-13 ***
## trtDrug        0.7132     0.5581   1.278    0.203    
## time:trtDrug  -2.6018     0.2279 -11.419  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.249 on 191 degrees of freedom
## Multiple R-squared:  0.8087, Adjusted R-squared:  0.8057 
## F-statistic: 269.1 on 3 and 191 DF,  p-value: < 2.2e-16
## [1] "conf:int ml1,2,3"
##                  2.5 %     97.5 %
## (Intercept) 115.998108 117.796764
## time         -2.869713  -2.135415
##                  2.5 %     97.5 %
## (Intercept) 118.268236 119.902020
## time         -2.793201  -2.211927
## trtDrug      -5.312843  -3.668210
##                    2.5 %      97.5 %
## (Intercept)  115.7815837 117.3184163
## time          -1.5487046  -0.9212954
## trtDrug       -0.3877528   1.8140685
## time:trtDrug  -3.0512870  -2.1523972
## [1] "anova ssq ml1,2,3"
## Analysis of Variance Table
## 
## Model 1: Score ~ time
## Model 2: Score ~ time + trt
## Model 3: Score ~ time * trt
##   Res.Df     RSS Df Sum of Sq      F    Pr(>F)    
## 1    193 2608.24                                  
## 2    192 1625.85  1    982.39 194.19 < 2.2e-16 ***
## 3    191  966.25  1    659.60 130.38 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] "sigma ml1,2,3"
## [1] 3.676163
## [1] 2.909975
## [1] 2.249196

ml1 as no meaning in RCT as TRT in not tested

We definitely see that ml3 is the convenient model (sigma,R squared) and is in accordance with the plot we saw preceedingly: In ANCOVA (contrast trt) the negative sign indicated that drugs reduce further each month the value of Drug patient of 2.60 mmHG in (linear) mean. We let the reader compute the confint of the interaction and trt effect value.

Note: In ANCOVA trt as marginal factor must be conserved for the OLS but is not of interpretation (see Fox,2015).

We report Type I.seq. ANOVA in ml3 model :

## Analysis of Variance Table
## 
## Response: Score
##            Df  Sum Sq Mean Sq F value    Pr(>F)    
## time        1 2442.50 2442.50  482.81 < 2.2e-16 ***
## trt         1  982.39  982.39  194.19 < 2.2e-16 ***
## time:trt    1  659.60  659.60  130.38 < 2.2e-16 ***
## Residuals 191  966.25    5.06                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The model matrix of ml3 look like this:

(Intercept) time trtDrug time:trtDrug
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0

Moreover we observed in the interaction plot the “non equal interval spacing” (fan out) in time and also on the by ID spaguetti plot , non linear pattern are obvious and reverse curvature from one group to another could be exploited:Therefore a growth model could be envisioned:

Growth model

One way to test this is by changing the time as an ordered factor: “factor(time,ordered=TRUE” and look for Wald test on polynomial trend:

## 
## Call:
## lm(formula = Score ~ factor(time, ordered = TRUE) * trt, data = new)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.5789  -1.4211  -0.1579   1.5789   4.5500 
## 
## Coefficients:
##                                         Estimate Std. Error t value Pr(>|t|)
## (Intercept)                            114.08000    0.22318 511.154  < 2e-16
## factor(time, ordered = TRUE).L          -3.90541    0.49905  -7.826 3.76e-13
## factor(time, ordered = TRUE).Q           0.44098    0.49905   0.884   0.3780
## factor(time, ordered = TRUE).C           0.22136    0.49905   0.444   0.6579
## factor(time, ordered = TRUE)^4           0.28685    0.49905   0.575   0.5661
## trtDrug                                 -4.49053    0.31975 -14.044  < 2e-16
## factor(time, ordered = TRUE).L:trtDrug  -8.22775    0.71499 -11.508  < 2e-16
## factor(time, ordered = TRUE).Q:trtDrug  -1.77729    0.71499  -2.486   0.0138
## factor(time, ordered = TRUE).C:trtDrug  -0.50430    0.71499  -0.705   0.4815
## factor(time, ordered = TRUE)^4:trtDrug   0.09688    0.71499   0.135   0.8924
##                                           
## (Intercept)                            ***
## factor(time, ordered = TRUE).L         ***
## factor(time, ordered = TRUE).Q            
## factor(time, ordered = TRUE).C            
## factor(time, ordered = TRUE)^4            
## trtDrug                                ***
## factor(time, ordered = TRUE).L:trtDrug ***
## factor(time, ordered = TRUE).Q:trtDrug *  
## factor(time, ordered = TRUE).C:trtDrug    
## factor(time, ordered = TRUE)^4:trtDrug    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.232 on 185 degrees of freedom
## Multiple R-squared:  0.8176, Adjusted R-squared:  0.8087 
## F-statistic: 92.11 on 9 and 185 DF,  p-value: < 2.2e-16

To asses what type of polynomial you need depends also on your goal but as seen on graph some concave up and concave down pattern might even required a third degree polynomial?!

## [1] "model polynomial 3 order in time"
## 
## Call:
## lm(formula = Score ~ poly(time, 3), data = new)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -12.119  -2.493   0.322   2.101   8.348 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    111.8923     0.2643 423.399   <2e-16 ***
## poly(time, 3)1 -49.4217     3.6904 -13.392   <2e-16 ***
## poly(time, 3)2  -2.6534     3.6904  -0.719    0.473    
## poly(time, 3)3  -0.1519     3.6904  -0.041    0.967    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.69 on 191 degrees of freedom
## Multiple R-squared:  0.485,  Adjusted R-squared:  0.4769 
## F-statistic: 59.96 on 3 and 191 DF,  p-value: < 2.2e-16
## [1] "model polynomial order 2 in the interactions"
## 
## Call:
## lm(formula = Score ~ poly(time, 2) * trt, data = new)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.3038  -1.5489  -0.1971   1.2729   4.2729 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            114.0800     0.2216 514.714  < 2e-16 ***
## poly(time, 2)1         -24.3893     3.0950  -7.880 2.51e-13 ***
## poly(time, 2)2           2.7539     3.0950   0.890   0.3747    
## trtDrug                 -4.4905     0.3175 -14.142  < 2e-16 ***
## poly(time, 2)1:trtDrug -51.3823     4.4342 -11.588  < 2e-16 ***
## poly(time, 2)2:trtDrug -11.0992     4.4342  -2.503   0.0132 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.216 on 189 degrees of freedom
## Multiple R-squared:  0.8162, Adjusted R-squared:  0.8113 
## F-statistic: 167.8 on 5 and 189 DF,  p-value: < 2.2e-16
## [1] "anova"
## Analysis of Variance Table
## 
## Model 1: Score ~ poly(time, 2) * trt
## Model 2: Score ~ poly(time, 3)
##   Res.Df     RSS Df Sum of Sq      F    Pr(>F)    
## 1    189  928.43                                  
## 2    191 2601.17 -2   -1672.7 170.26 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Probably a reasonable assumptions for other linear model is an order 2 polynomial with possibly trt*time of order 2 interaction too in order to account for change in simple curvature (concave up/down). Note:Use poly fx to ensure orthogonal polynomial. Piecewise linear spline could be tried too but watch out for degrees of freedom used up.

Until then we haven’t accounted for the RM correlations that is the SE are inflated and inference not precised hence should not be used for publications.

For those who are not used to LMM you can use a gls function and ask for a SE Robust Sandwich :: robust :: estimator of regression coefficients for your retained model (See Fox,2015),

Including B0 as static X covariate

Now will explore that baseline B0 as a static predictor removed from the dynamic time frame [Bp1,Bp2,Bp3,Bp4]. Therefore for each line of the model matrix the baseline B0 for each idrow must be repeated: This required a little bit of involvement in reshaping the data in R

## [1] "X matrix and dimension of restructed data"
##    id  trt age sex baseline  bp Score
## 1   2 Drug  51   M      116 bp1   113
## 2   3 Drug  48   F      119 bp1   115
## 3   4 Drug  42   F      115 bp1   113
## 4   5 Drug  49   M      116 bp1   112
## 5   6 Drug  47   M      117 bp1   112
## 6   7 Drug  50   F      118 bp1   111
## 7   8 Drug  61   M      120 bp1   115
## 8   9 Drug  43   M      114 bp1   112
## 9  10 Drug  51   M      115 bp1   113
## 10 11 Drug  47   F      117 bp1   112
## [1] 156   7
## [1] "X matrix and dimension of long format bp0,1,2,3,4 preceeding mdel datadata "
##    id  trt age sex       bp Score time
## 1   2 Drug  51   M baseline   116    0
## 2   3 Drug  48   F baseline   119    0
## 3   4 Drug  42   F baseline   115    0
## 4   5 Drug  49   M baseline   116    0
## 5   6 Drug  47   M baseline   117    0
## 6   7 Drug  50   F baseline   118    0
## 7   8 Drug  61   M baseline   120    0
## 8   9 Drug  43   M baseline   114    0
## 9  10 Drug  51   M baseline   115    0
## 10 11 Drug  47   F baseline   117    0
## [1] 195   7
## [1] "BP must be a time numeric value"
##    id  trt age sex baseline  bp Score time
## 1   2 Drug  51   M      116 bp1   113    1
## 2   3 Drug  48   F      119 bp1   115    1
## 3   4 Drug  42   F      115 bp1   113    1
## 4   5 Drug  49   M      116 bp1   112    1
## 5   6 Drug  47   M      117 bp1   112    1
## 6   7 Drug  50   F      118 bp1   111    1
## 7   8 Drug  61   M      120 bp1   115    1
## 8   9 Drug  43   M      114 bp1   112    1
## 9  10 Drug  51   M      115 bp1   113    1
## 10 11 Drug  47   F      117 bp1   112    1
##   id  trt baseline bp1 bp2 bp3 bp4 age sex
## 1  2 Drug      116 113 112 103 101  51   M
##   id  trt baseline bp1 bp2 bp3 bp4 age sex
## 9 10 Drug      115 113 108 106  97  51   M

Reshaping a data from wide to long and adding/deleting rows is always a tricky exercise and might result in crucial error: Always check that random rows between wide vs long df has the same figures!

## [1] "confirm type of contrast set and change to PLACEBO 0 as refs"
##         Drug
## Placebo    0
## Drug       1
## [1] "set PLACEBO=B AS REF"
## [1] "note If you messed up in cyour relvel factor in R interetation could be catastrophically wrong"
##         Drug
## Placebo    0
## Drug       1
## 
## Call:
## lm(formula = Score ~ time * trt + baseline, data = newb)
## 
## Coefficients:
##  (Intercept)          time       trtDrug      baseline  time:trtDrug  
##      79.2895       -1.1350        1.9024        0.3166       -2.9913
## [1] "Lets report the coefficient coefficients confint"
##                   2.5 %     97.5 %
## (Intercept)  58.7708090 99.8081592
## time         -1.5702558 -0.6997442
## trtDrug       0.1945924  3.6102205
## baseline      0.1411263  0.4920303
## time:trtDrug -3.6149071 -2.3677245

The retained model with a baseline as static predictor tell us that every month a linear difference of -2.99 mmHG for the drug occurs that is for a 4 Months treatment will reach about 12 mmHG *[ 14.4 : 9.48 ] of E(Y|X) difference from PLA to DRUG:Lets check the basic difference at time 4 mean value:

Drug Placebo difference
baseline 116.6842 116.7500 0
bp1 113.4211 115.2000 -2
bp2 110.5789 114.0500 -4
bp3 106.1053 112.4500 -6
bp4 101.1579 111.9500 -10

And from the the DoD TTest 10.72 mmHG [9.08 12.37]

The linear model gives higher difference result and for a DRUG that is the aim for !

You have to recall that in linear model the E(Y|X) is not the mean of group: It integrate the conditional linear trend within all months of experiment that the real power of regression MODEL.In Anova the empirical group mean is used instead.Of course now the main effect of time and trt in our lm cannot be interpreted promptly as J.Fox reported in 2015.

But in bio-statistic what is crucial is how much difference between group is accounted in time (each month) : Therefore the interaction term is the major focus on the model to detect an affect. Recall that contrast as been set to “trt” with ref PLA, that is the coefficient in model ml480 describe the real difference between arms

Now let see which of our two lm with B0 as time predictor and the other as static predictor is different:

## [1] "model with B0 as dynamic predictor"
## 
## Call:
## lm(formula = Score ~ time * trt, data = new)
## 
## Coefficients:
##  (Intercept)          time       trtDrug  time:trtDrug  
##     116.5500       -1.2350        0.7132       -2.6018
## [1] "effect is 10.40 MMHG drop in favour of DRUG"
## [1] "model with B0 as controlled X static predictor"
## 
## Call:
## lm(formula = Score ~ time * trt + baseline, data = newb)
## 
## Coefficients:
##  (Intercept)          time       trtDrug      baseline  time:trtDrug  
##      79.2895       -1.1350        1.9024        0.3166       -2.9913
## [1] "confint"
##               2.5 % 97.5 %
## (Intercept)  115.78 117.32
## time          -1.55  -0.92
## trtDrug       -0.39   1.81
## time:trtDrug  -3.05  -2.15
##              2.5 % 97.5 %
## (Intercept)  58.77  99.81
## time         -1.57  -0.70
## trtDrug       0.19   3.61
## baseline      0.14   0.49
## time:trtDrug -3.61  -2.37

In the the model ml3 : Score~time*trt the interaction effect is 10.40 mmHG 4*[3.05;2.6:2.15] mmHG drop in favor of DRUG after 4 months with BO as a dynamic part of time effect.

In the model ml4B0 the interaction effect is about 12mmHG 4[3.61;2.99: 2.37] drop in favor of DRUG after 4 months:There B0 is a static predictor for each row.

Conclusions on lm time model

Our Next blog:

Linear Mixed Model (LMM::nlme,lme4) will be presented in our next BLOG as well some demonstration why the hat matrix is influencing such in precision. We will also review some type of variability in this study.

STAY tuned

REFERENCES

Chen, D. ., Peace, K. E. (2011). Clinical Trial Data Analysis Using R. États-Unis: CRC Press.

Fox, J., & Weisberg, S. (2018). An R companion to applied regression. Sage publications.

Zhang, S., Paul, J.E., Nantha-Aree, M., Buckley, N., Shahzad, U., Cheng, J., Debeer, J., Winemaker, M.J., Wismer, D., Punthakee, D., Avram, V., & Thabane, L. (2014). Empirical comparison of four baseline covariate adjustment methods in analysis of continuous outcomes in randomized controlled trials. Clinical Epidemiology, 6, 227 - 235.

A nice overview of that topic is given in Senn paper too.


  1. A first approcach would be to use a robust estimateor of the COV matrix knwon as the sandwich / Hubert estimators↩︎

    • or Growth curve if ciurvature pattern
    ↩︎
  2. Large clinical trials have shown that combined treatment with reserpine plus a thiazide diuretic reduces mortality of people with hypertension..↩︎

  3. Back on tracking the history of this RCT (part of the job) it is not clear from source which treatment was tested either Resepinic or betaB…The intention here is to demonstrate the technical statistical aspect with repeated data not a biophysical full proof of a drug per se.↩︎

  4. Missing value will be replace by a Propensity score matching approach in this slight unbalanced design to make an repeated Anova and result compared.↩︎

  5. Naive because it doesn’t take into account repeated corrrelated measures hence partial information only Use LMM or GEE↩︎

  6. Because we use only one type of information at time 4! some study are so designed but be aware that slope information might be misleading if one to compare the baseline with each trt with low sample size such exposed in Captopril se xyplot study↩︎

  7. [Naive model] doesn’t take accout of RM.↩︎