Loading packages
library(lme4)
## Carregando pacotes exigidos: Matrix
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(patchwork)
library(lmerTest)
##
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
##
## lmer
## The following object is masked from 'package:stats':
##
## step
#library("kableExtra")
Reading data
anamr=read.csv("C:\\Users\\gabri\\Downloads\\anaMR.csv",header=TRUE,sep=";")
anab=read.csv("C:\\Users\\gabri\\Downloads\\anaBasal.csv",header=TRUE,sep=";")
anac <- merge(anab, anamr, by = "id")
ana=subset(anac,anac$Exclude==FALSE)
ana$Group=as.factor(ana$Group)
ana$qCON=ana$BIS
Data summary
summary(ana)
## id Group Age Sex Weight
## Min. : 1.00 Bolus:168 Min. :35 Length:330 Min. : 41.00
## 1st Qu.:16.00 TCI :162 1st Qu.:39 Class :character 1st Qu.: 60.00
## Median :31.00 Median :46 Mode :character Median : 68.00
## Mean :30.95 Mean :45 Mean : 72.07
## 3rd Qu.:46.00 3rd Qu.:50 3rd Qu.: 83.00
## Max. :60.00 Max. :55 Max. :113.00
##
## Height Hypertension MAPBasal ASA
## Length:330 Mode :logical Min. : 69.00 Length:330
## Class :character FALSE:270 1st Qu.: 84.00 Class :character
## Mode :character TRUE :60 Median : 91.00 Mode :character
## Mean : 91.24
## 3rd Qu.: 96.00
## Max. :118.00
## NA's :6
## Ecluded NotIncluded Exclude tmin MAP
## Mode :logical Mode :logical Mode :logical Min. : 0 Min. : 53.00
## FALSE:330 FALSE:330 FALSE:330 1st Qu.: 2 1st Qu.: 78.25
## Median : 5 Median : 87.00
## Mean : 5 Mean : 88.25
## 3rd Qu.: 8 3rd Qu.: 98.00
## Max. :10 Max. :137.00
##
## BIS HR EtSevo SR
## Min. : 6.0 Min. : 37.00 Min. :0.00000 Min. : 0.000
## 1st Qu.:38.0 1st Qu.: 65.00 1st Qu.:0.00000 1st Qu.: 0.000
## Median :50.5 Median : 74.00 Median :0.00000 Median : 0.000
## Mean :55.3 Mean : 76.62 Mean :0.03364 Mean : 2.818
## 3rd Qu.:73.0 3rd Qu.: 87.00 3rd Qu.:0.00000 3rd Qu.: 0.000
## Max. :99.0 Max. :121.00 Max. :1.50000 Max. :72.000
##
## qCON
## Min. : 6.0
## 1st Qu.:38.0
## Median :50.5
## Mean :55.3
## 3rd Qu.:73.0
## Max. :99.0
##
summary(subset(ana,ana$Group=="Bolus"))
## id Group Age Sex
## Min. : 1.00 Bolus:168 Min. :35.00 Length:168
## 1st Qu.:14.00 TCI : 0 1st Qu.:39.75 Class :character
## Median :33.00 Median :47.50 Mode :character
## Mean :31.36 Mean :45.18
## 3rd Qu.:48.50 3rd Qu.:50.00
## Max. :60.00 Max. :55.00
##
## Weight Height Hypertension MAPBasal
## Min. : 52.00 Length:168 Mode :logical Min. : 69.00
## 1st Qu.: 61.50 Class :character FALSE:138 1st Qu.: 84.00
## Median : 75.00 Mode :character TRUE :30 Median : 88.00
## Mean : 75.36 Mean : 89.37
## 3rd Qu.: 86.75 3rd Qu.: 95.00
## Max. :113.00 Max. :118.00
## NA's :6
## ASA Ecluded NotIncluded Exclude
## Length:168 Mode :logical Mode :logical Mode :logical
## Class :character FALSE:168 FALSE:168 FALSE:168
## Mode :character
##
##
##
##
## tmin MAP BIS HR
## Min. : 0 Min. : 57.00 Min. : 6.00 Min. : 37.00
## 1st Qu.: 2 1st Qu.: 76.75 1st Qu.:34.00 1st Qu.: 65.00
## Median : 5 Median : 85.00 Median :44.00 Median : 74.00
## Mean : 5 Mean : 86.24 Mean :50.54 Mean : 76.26
## 3rd Qu.: 8 3rd Qu.: 95.00 3rd Qu.:70.00 3rd Qu.: 88.00
## Max. :10 Max. :129.00 Max. :99.00 Max. :121.00
##
## EtSevo SR qCON
## Min. :0.00000 Min. : 0.000 Min. : 6.00
## 1st Qu.:0.00000 1st Qu.: 0.000 1st Qu.:34.00
## Median :0.00000 Median : 0.000 Median :44.00
## Mean :0.06607 Mean : 5.518 Mean :50.54
## 3rd Qu.:0.00000 3rd Qu.: 0.000 3rd Qu.:70.00
## Max. :1.50000 Max. :72.000 Max. :99.00
##
summary(subset(ana,ana$Group=="TCI"))
## id Group Age Sex
## Min. : 6.00 Bolus: 0 Min. :35.00 Length:162
## 1st Qu.:19.00 TCI :162 1st Qu.:38.00 Class :character
## Median :30.00 Median :46.00 Mode :character
## Mean :30.52 Mean :44.81
## 3rd Qu.:39.00 3rd Qu.:51.00
## Max. :56.00 Max. :55.00
## Weight Height Hypertension MAPBasal
## Min. : 41.00 Length:162 Mode :logical Min. : 74.00
## 1st Qu.: 58.00 Class :character FALSE:132 1st Qu.: 83.00
## Median : 67.00 Mode :character TRUE :30 Median : 92.00
## Mean : 68.67 Mean : 93.11
## 3rd Qu.: 77.00 3rd Qu.:103.00
## Max. :112.00 Max. :111.00
## ASA Ecluded NotIncluded Exclude
## Length:162 Mode :logical Mode :logical Mode :logical
## Class :character FALSE:162 FALSE:162 FALSE:162
## Mode :character
##
##
##
## tmin MAP BIS HR EtSevo
## Min. : 0 Min. : 53.00 Min. :32.00 Min. : 55.00 Min. :0
## 1st Qu.: 2 1st Qu.: 80.00 1st Qu.:43.25 1st Qu.: 66.00 1st Qu.:0
## Median : 5 Median : 88.50 Median :55.00 Median : 74.00 Median :0
## Mean : 5 Mean : 90.33 Mean :60.25 Mean : 76.99 Mean :0
## 3rd Qu.: 8 3rd Qu.: 99.00 3rd Qu.:77.00 3rd Qu.: 85.75 3rd Qu.:0
## Max. :10 Max. :137.00 Max. :99.00 Max. :117.00 Max. :0
## SR qCON
## Min. :0.00000 Min. :32.00
## 1st Qu.:0.00000 1st Qu.:43.25
## Median :0.00000 Median :55.00
## Mean :0.01852 Mean :60.25
## 3rd Qu.:0.00000 3rd Qu.:77.00
## Max. :2.00000 Max. :99.00
Main outcome (MAP)
Calculate means by time and group
ana_stats <- ana %>%
group_by(tmin, Group) %>%
summarise(
MAP_mean = mean(MAP, na.rm = TRUE),
MAP_sd = sd(MAP, na.rm = TRUE),
.groups = 'drop'
)
Plot
p1=ggplot(ana_stats, aes(x = tmin, y = MAP_mean, group = Group, color = Group)) +
geom_errorbar(aes(ymin = MAP_mean - MAP_sd, ymax = MAP_mean + MAP_sd), width = 0.1, position = position_dodge(0.2), alpha = 0.6) +
geom_line(aes(linetype = Group), position = position_dodge(0.2)) +
geom_point(position = position_dodge(0.2), size = 3, alpha = 0.6) +
labs(x = "Time after induction (min)", y = "Mean arterial pressure (MAP)", color = "Group") +
theme_minimal() +
theme(legend.position = "bottom")
p1

Repeated measures analysis
# Modelo Linear Misto para MAP
modelo_map <- lmer(ana$MAP ~ ana$Group * ana$tmin + (1 | ana$id), data = ana, REML = TRUE)
summary(modelo_map)
Linear mixed model fit by REML. t-tests use Satterthwaite’s method [
lmerModLmerTest] Formula: ana\(MAP ~
ana\)Group * ana\(tmin + (1 |
ana\)id) Data: ana
REML criterion at convergence: 2623
Scaled residuals: Min 1Q Median 3Q Max -2.4052 -0.6969 -0.0806 0.5227
3.7781
Random effects: Groups Name Variance Std.Dev. ana\(id (Intercept) 67.29 8.203 Residual 135.02 11.620
Number of obs: 330, groups: ana\)id, 55
Fixed effects: Estimate Std. Error df t value Pr(>|t|)
(Intercept) 84.60884 2.22012 118.57178 38.110 <2e-16 *** ana\(GroupTCI 3.75624 3.16866 118.57178 1.185 0.238
ana\)tmin 0.32704 0.26246 273.00000 1.246 0.214
ana\(GroupTCI:ana\)tmin 0.06661 0.37460
273.00000 0.178 0.859
— Signif. codes: 0 ‘’ 0.001 ’’ 0.01 ’’ 0.05
‘.’ 0.1 ’ ’ 1
Correlation of Fixed Effects: (Intr) an\(GTCI an\)tmn ana\(GropTCI -0.701 ana\)tmin -0.591 0.414
an\(GrpTCI:\) 0.414 -0.591 -0.701
Secondary outcomes
qCON
Calculate means by time and group
ana_stats <- ana %>%
group_by(tmin, Group) %>%
summarise(
qCON_mean = mean(qCON, na.rm = TRUE),
qCON_sd = sd(qCON, na.rm = TRUE),
.groups = 'drop'
)
Plot
p2=ggplot(ana_stats, aes(x = tmin, y = qCON_mean, group = Group, color = Group)) +
geom_errorbar(aes(ymin = qCON_mean - qCON_sd, ymax = qCON_mean + qCON_sd), width = 0.1, position = position_dodge(0.2), alpha = 0.6) +
geom_line(aes(linetype = Group), position = position_dodge(0.2)) +
geom_point(position = position_dodge(0.2), size = 3, alpha = 0.6) +
labs(x = "Time after induction (min)", y = "qCON", color = "Group") +
theme_minimal() +
theme(legend.position = "bottom")
p2

Repeated measures analysis
# Modelo Linear Misto para qCON
modelo_qcon <- lmer(ana$qCON ~ ana$Group * ana$tmin + (1 | ana$id), data = ana, REML = TRUE)
summary(modelo_qcon)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ana$qCON ~ ana$Group * ana$tmin + (1 | ana$id)
## Data: ana
##
## REML criterion at convergence: 2741.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.1244 -0.6030 0.0697 0.6624 2.2193
##
## Random effects:
## Groups Name Variance Std.Dev.
## ana$id (Intercept) 13.51 3.676
## Residual 231.59 15.218
## Number of obs: 330, groups: ana$id, 55
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 72.3418 2.1943 238.2388 32.967 < 2e-16 ***
## ana$GroupTCI 10.5717 3.1319 238.2388 3.376 0.00086 ***
## ana$tmin -4.3612 0.3437 273.0000 -12.687 < 2e-16 ***
## ana$GroupTCI:ana$tmin -0.1721 0.4906 273.0000 -0.351 0.72600
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) an$GTCI an$tmn
## ana$GropTCI -0.701
## ana$tmin -0.783 0.549
## an$GrpTCI:$ 0.549 -0.783 -0.701
SR
Calculate means by time and group
ana_stats <- ana %>%
group_by(tmin, Group) %>%
summarise(
SR_mean = mean(SR, na.rm = TRUE),
SR_sd = sd(SR, na.rm = TRUE),
.groups = 'drop'
)
Plot
p3=ggplot(ana_stats, aes(x = tmin, y = SR_mean, group = Group, color = Group)) +
geom_errorbar(aes(ymin = SR_mean - SR_sd, ymax = SR_mean + SR_sd), width = 0.1, position = position_dodge(0.2), alpha = 0.6) +
geom_line(aes(linetype = Group), position = position_dodge(0.2)) +
geom_point(position = position_dodge(0.2), size = 3, alpha = 0.6) +
labs(x = "Time after induction (min)", y = "Suppression rate (SR)", color = "Group") +
theme_minimal() +
theme(legend.position = "bottom")
p3

Repeated measures analysis
# Modelo Linear Misto para SR
modelo_sr <- lmer(ana$SR ~ ana$Group * ana$tmin + (1 | ana$id), data = ana, REML = TRUE)
## boundary (singular) fit: see help('isSingular')
summary(modelo_sr)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ana$SR ~ ana$Group * ana$tmin + (1 | ana$id)
## Data: ana
##
## REML criterion at convergence: 2488.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -0.6464 -0.4469 -0.0035 -0.0007 6.2604
##
## Random effects:
## Groups Name Variance Std.Dev.
## ana$id (Intercept) 0.0 0.00
## Residual 111.9 10.58
## Number of obs: 330, groups: ana$id, 55
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 4.1990 1.4467 326.0000 2.902 0.00395 **
## ana$GroupTCI -4.1990 2.0648 326.0000 -2.034 0.04280 *
## ana$tmin 0.2638 0.2389 326.0000 1.104 0.27039
## ana$GroupTCI:ana$tmin -0.2601 0.3410 326.0000 -0.763 0.44620
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) an$GTCI an$tmn
## ana$GropTCI -0.701
## ana$tmin -0.826 0.579
## an$GrpTCI:$ 0.579 -0.826 -0.701
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
HR
Calculate means by time and group
ana_stats <- ana %>%
group_by(tmin, Group) %>%
summarise(
HR_mean = mean(HR, na.rm = TRUE),
HR_sd = sd(HR, na.rm = TRUE),
.groups = 'drop'
)
Plot
p4=ggplot(ana_stats, aes(x = tmin, y = HR_mean, group = Group, color = Group)) +
geom_errorbar(aes(ymin = HR_mean - HR_sd, ymax = HR_mean + HR_sd), width = 0.1, position = position_dodge(0.2), alpha = 0.6) +
geom_line(aes(linetype = Group), position = position_dodge(0.2)) +
geom_point(position = position_dodge(0.2), size = 3, alpha = 0.6) +
labs(x = "Time after induction (min)", y = "Heart Rate (HR)", color = "Group") +
theme_minimal() +
theme(legend.position = "bottom")
Repeated measures analysis
# Modelo Linear Misto para HR
modelo_hr <- lmer(ana$HR ~ ana$Group * ana$tmin + (1 | ana$id), data = ana, REML = TRUE)
summary(modelo_hr)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ana$HR ~ ana$Group * ana$tmin + (1 | ana$id)
## Data: ana
##
## REML criterion at convergence: 2555.9
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.2553 -0.6610 -0.1415 0.5814 2.8700
##
## Random effects:
## Groups Name Variance Std.Dev.
## ana$id (Intercept) 117.90 10.858
## Residual 97.67 9.883
## Number of obs: 330, groups: ana$id, 55
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 70.0986 2.4572 83.0474 28.528 < 2e-16 ***
## ana$GroupTCI 1.8202 3.5070 83.0474 0.519 0.605
## ana$tmin 1.2327 0.2232 273.0000 5.522 7.8e-08 ***
## ana$GroupTCI:ana$tmin -0.2189 0.3186 273.0000 -0.687 0.493
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) an$GTCI an$tmn
## ana$GropTCI -0.701
## ana$tmin -0.454 0.318
## an$GrpTCI:$ 0.318 -0.454 -0.701
Final table
## Variable p_Value_for_Initial_Group_Difference Group_Time_Interaction_p_Value
## 1 MAP 0.2382160639 0.8589978
## 2 SR 0.0428028138 0.4461999
## 3 qCON 0.0008600852 0.7260027
## 4 HR 0.6051262068 0.4926278