library(readxl)
library(ggplot2)
library(CGPfunctions)
library(plotly)
library(lmtest)
#Definir directorio
setwd("G:/TRABAJO/CONSULTORIAS/TRABAJOS VARIOS/JORGE CHAVARRIA/analisis3")
data1 = read_excel("Bicuspid3.xlsx")
head(data1,5)
ANALISIS RELATIVE STENT EXPANSION
#Relacion entre Maximum Sinus Diameter Indexed vs Relative Stent Expansion %
g1=ggplot(data=data1,mapping=
aes(x=MaxSinAnnDcalc,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g1 + labs(title = "Relative Stent Expansion % vs Maximum Sinus Diameter Indexed",
x = "Maximum Sinus Diameter Indexed",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
correlation_test1 <- cor.test(data1$MaxSinAnnDcalc, data1$RelativeStentExpansion)
print(correlation_test1)
Pearson's product-moment correlation
data: data1$MaxSinAnnDcalc and data1$RelativeStentExpansion
t = 0.89077, df = 97, p-value = 0.3753
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.109279 0.282465
sample estimates:
cor
0.09007603
Podemos observar que no existe una correlacion significativa entre MaxSinAnnDcalc y RelativeStentExpansion
#Relacion entre Minimun Sinus Diameter Indexed vs Relative Stent Expansion %
g2=ggplot(data=data1,mapping=
aes(x=MinSinusAnnDcalc,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g2 + labs(title = "Relative Stent Expansion % vs Minimun Sinus Diameter Indexed",
x = "Minimun Sinus Diameter Indexed",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
correlation_test2 <- cor.test(data1$MinSinusAnnDcalc, data1$RelativeStentExpansion)
print(correlation_test2)
Pearson's product-moment correlation
data: data1$MinSinusAnnDcalc and data1$RelativeStentExpansion
t = 1.4692, df = 97, p-value = 0.145
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.05136679 0.33519012
sample estimates:
cor
0.1475412
#Relacion entre Postdilatation vs Relative Stent Expansion %
boxplot(data1$RelativeStentExpansion~data1$Postdilation,
xlab = 'Postdilation',
ylab = 'Relative Stent Expansion %',
title=('Postdilatation vs Relative Stent Expansion %'),
col= 'bisque')
t_test1 <- t.test(data1$RelativeStentExpansion ~ as.factor(data1$Postdilation))
print(t_test1)
Welch Two Sample t-test
data: data1$RelativeStentExpansion by as.factor(data1$Postdilation)
t = -4.3252, df = 43.026, p-value = 8.89e-05
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.04056690 -0.01476687
sample estimates:
mean in group 0 mean in group 1
0.8991558 0.9268227
Se evidencia una diferencia significativa de RelativeStentExpansion en funcion de la Postdilatacion, si postdilata aumenta la expacion relativa.
ggplot(data = data1) + geom_density(aes(x=RelativeStentExpansion,fill=factor(Postdilation)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
#Relacion entre Predilatation vs Relative Stent Expansion %
boxplot(data1$RelativeStentExpansion~data1$Predilatation,
xlab = 'Predilatation',
ylab = 'Relative Stent Expansion %',
title=('Predilatation vs Relative Stent Expansion %'),
col= 'bisque')
ggplot(data = data1) + geom_density(aes(x=RelativeStentExpansion,fill=factor(Predilatation)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
t_test2 <- t.test(data1$RelativeStentExpansion ~ as.factor(data1$Predilatation))
print(t_test2)
Welch Two Sample t-test
data: data1$RelativeStentExpansion by as.factor(data1$Predilatation)
t = -0.73773, df = 71.657, p-value = 0.4631
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.018353678 0.008439107
sample estimates:
mean in group 0 mean in group 1
0.9036015 0.9085588
No existe una diferencia significativa de RelativeStentExpansion en función de la Predilatation
#Relacion entre Raphe Calcification vs Relative Stent Expansion %
boxplot(data1$RelativeStentExpansion~data1$Raphaecalcification,
xlab = 'Raphae Calcification',
ylab = 'Relative Stent Expansion %',
title=('Raphae Calcification vs Relative Stent Expansion %'),
col= 'ivory')
ggplot(data = data1) + geom_density(aes(x=RelativeStentExpansion,fill=factor(Raphaecalcification)),
bins=10, position = "identity",alpha = 0.5)
Warning: Ignoring unknown parameters: bins
t_test3 <- t.test(data1$RelativeStentExpansion ~ as.factor(data1$Raphaecalcification))
print(t_test3)
Welch Two Sample t-test
data: data1$RelativeStentExpansion by as.factor(data1$Raphaecalcification)
t = 0.5185, df = 85.377, p-value = 0.6055
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.009547276 0.016283981
sample estimates:
mean in group 0 mean in group 1
0.9074135 0.9040452
No existe diferencia significativa de RelativeStentExpansion en función del RelativeStentExpansion
#Relacion entre AVAi vs Relative Stent Expansion %
g4=ggplot(data=data1,mapping=
aes(x=AVAi,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g4 + labs(title = "Relative Stent Expansion % vs AVAi",
x = "AVAi",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
Warning: Removed 24 rows containing non-finite values (stat_smooth).
Warning: Removed 24 rows containing missing values (geom_point).
correlation_test3 <- cor.test(data1$AVAi, data1$RelativeStentExpansion)
print(correlation_test3)
Pearson's product-moment correlation
data: data1$AVAi and data1$RelativeStentExpansion
t = 1.9905, df = 73, p-value = 0.05029
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-7.606249e-05 4.316249e-01
sample estimates:
cor
0.2268897
Existe correlacion positiva significativa entre AVAi y RelativeStentExpansion
#Relacion entre Mean Gradient (mmHg) vs Relative Stent Expansion %
g5=ggplot(data=data1,mapping=
aes(x=MeanGradientmmHg,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g5 + labs(title = "Relative Stent Expansion % vs Mean Gradient (mmHg)",
x = "Mean Gradient (mmHg)",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
correlation_test4 <- cor.test(data1$MeanGradientmmHg, data1$RelativeStentExpansion)
print(correlation_test4)
Pearson's product-moment correlation
data: data1$MeanGradientmmHg and data1$RelativeStentExpansion
t = -3.3768, df = 97, p-value = 0.001056
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.4903450 -0.1355981
sample estimates:
cor
-0.3243281
la correlacion entre MeanGradientmmHg y RelativeStentExpansion es negativa y significativa
#Relacion entre Relative Stent Expansion % (1;0) vs MeanGradientmmHg
boxplot(data1$MeanGradientmmHg~data1$RSEcalc,
xlab = 'RSE Calc',
ylab = 'MeanGradientmmHg',
title=('Relative Stent Expansion % (1;0) vs MeanGradientmmHg'),
col= 'ivory')
t_test4 <- t.test(data1$MeanGradientmmHg ~ as.factor(data1$RSEcalc))
print(t_test4)
Welch Two Sample t-test
data: data1$MeanGradientmmHg by as.factor(data1$RSEcalc)
t = 1.4598, df = 49.241, p-value = 0.1507
alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
95 percent confidence interval:
-0.6662386 4.2060294
sample estimates:
mean in group 0 mean in group 1
10.900541 9.130645
#Relacion entre ICD4mm_calc(IDC4mm/Area Derived Diameter) vs Relative Stent Expansion %
g6=ggplot(data=data1,mapping=
aes(x=ICD4mm_calc,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g6 + labs(title = "Relative Stent Expansion % vs Intercomisural Diameter at 4 mm Indexed",
x = "Intercomisural Diameter at 4 mm Indexed",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
correlation_test5 <- cor.test(data1$ICD4mm_calc, data1$RelativeStentExpansion)
print(correlation_test5)
Pearson's product-moment correlation
data: data1$ICD4mm_calc and data1$RelativeStentExpansion
t = 0.10038, df = 97, p-value = 0.9202
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.1875974 0.2071868
sample estimates:
cor
0.01019186
La correlacion es nula para estas variables
#Relacion entre CCV vs Relative Stent Expansion %
g7=ggplot(data=data1,mapping=
aes(x=CCV,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g7 + labs(title = "Relative Stent Expansion % vs Calcium contrast volume",
x = "Calcium contrast volume",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
correlation_test6 <- cor.test(data1$CCV, data1$RelativeStentExpansion)
print(correlation_test6)
Pearson's product-moment correlation
data: data1$CCV and data1$RelativeStentExpansion
t = 0.21294, df = 97, p-value = 0.8318
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.1765496 0.2180967
sample estimates:
cor
0.02161556
La correlacion entre CCV y RelativeStentExpansion es nula.
#Relacion entre SVDmax vs Relative Stent Expansion %
g8=ggplot(data=data1,mapping=
aes(x=SVDmax,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g8 + labs(title = "Relative Stent Expansion % vs SVDmax",
x = "SVDmax",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
correlation_test7 <- cor.test(data1$SVDmax, data1$RelativeStentExpansion)
print(correlation_test7)
Pearson's product-moment correlation
data: data1$SVDmax and data1$RelativeStentExpansion
t = 2.0889, df = 97, p-value = 0.03933
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.01049871 0.38896086
sample estimates:
cor
0.2074805
la correlacion entre SVDmax y RelativeSten expasion es significativa
#Relacion entre SVDmax vs Relative Stent Expansion %
g9=ggplot(data=data1,mapping=
aes(x=SVDmin,y=RelativeStentExpansion,))+geom_point()+theme_bw()+
geom_smooth(method = "lm")
g9 + labs(title = "Relative Stent Expansion % vs SVDmin",
x = "SVDmin",
y= "Relative Stent Expansion %")
`geom_smooth()` using formula 'y ~ x'
correlation_test8 <- cor.test(data1$SVDmin, data1$RelativeStentExpansion)
print(correlation_test8)
Pearson's product-moment correlation
data: data1$SVDmin and data1$RelativeStentExpansion
t = 2.5185, df = 97, p-value = 0.01342
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.05291916 0.42439847
sample estimates:
cor
0.2477429
la correlacion entre SVDmin y RelativeSten expasion es significativa
#Relacion entre CCV vs RSEcalc
boxplot(data1$CCV~data1$RSEcalc,
xlab = 'RSEcalc',
ylab = 'CCV',
title=('RSEcalc vs CCV'),
col= 'ivory')
REGRESION LINEAL EN FUNCION DE RELATIVE STENT EXPANSION
#Regresion inicial
mod1=lm(RelativeStentExpansion ~ Predilatation + Postdilation +
CCV + Raphaecalcification +
ICD4mm + SVDmax
,
data = data1)
summary(mod1)
Call:
lm(formula = RelativeStentExpansion ~ Predilatation + Postdilation +
CCV + Raphaecalcification + ICD4mm + SVDmax, data = data1)
Residuals:
Min 1Q Median 3Q Max
-0.095076 -0.009110 0.006183 0.015923 0.057555
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 8.184e-01 3.273e-02 25.002 < 2e-16 ***
Predilatation 3.359e-03 6.708e-03 0.501 0.617715
Postdilation 2.917e-02 7.373e-03 3.957 0.000149 ***
CCV -6.865e-06 6.108e-06 -1.124 0.263972
Raphaecalcification -1.790e-03 6.630e-03 -0.270 0.787762
ICD4mm 1.466e-03 1.618e-03 0.906 0.367438
SVDmax 1.232e-03 9.888e-04 1.246 0.215808
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.03005 on 92 degrees of freedom
Multiple R-squared: 0.1939, Adjusted R-squared: 0.1413
F-statistic: 3.688 on 6 and 92 DF, p-value: 0.002502
Calculos Intervalo de confianza coeficientes Regresion Lineal
# Obtener el resumen del modelo
summary_mod1 <- summary(mod1)
# Extraer los coeficientes
coefficients <- coef(summary_mod1)[, 1]
# Extraer los intervalos de confianza
conf_intervals <- confint(mod1)
# Extraer los p-values
p_values <- summary_mod1$coefficients[, 4]
# Crear el data frame consolidado
consolidado <- data.frame(Coefficient = coefficients,
Lower_CI = conf_intervals[, 1],
Upper_CI = conf_intervals[, 2],
p_value = p_values)
# Mostrar el data frame consolidado
print(consolidado)
NA
# Aplicar el procedimiento stepwise
mod1_1 <- step(mod1)
Start: AIC=-687.22
RelativeStentExpansion ~ Predilatation + Postdilation + CCV +
Raphaecalcification + ICD4mm + SVDmax
Df Sum of Sq RSS AIC
- Raphaecalcification 1 0.0000658 0.083152 -689.14
- Predilatation 1 0.0002265 0.083312 -688.95
- ICD4mm 1 0.0007409 0.083827 -688.34
- CCV 1 0.0011408 0.084227 -687.87
- SVDmax 1 0.0014028 0.084489 -687.56
<none> 0.083086 -687.22
- Postdilation 1 0.0141404 0.097226 -673.66
Step: AIC=-689.14
RelativeStentExpansion ~ Predilatation + Postdilation + CCV +
ICD4mm + SVDmax
Df Sum of Sq RSS AIC
- Predilatation 1 0.0002199 0.083372 -690.88
- ICD4mm 1 0.0008000 0.083952 -690.19
- SVDmax 1 0.0013865 0.084538 -689.50
- CCV 1 0.0014501 0.084602 -689.43
<none> 0.083152 -689.14
- Postdilation 1 0.0142979 0.097450 -675.43
Step: AIC=-690.88
RelativeStentExpansion ~ Postdilation + CCV + ICD4mm + SVDmax
Df Sum of Sq RSS AIC
- ICD4mm 1 0.0007859 0.084158 -691.95
- CCV 1 0.0012633 0.084635 -691.39
- SVDmax 1 0.0014588 0.084830 -691.16
<none> 0.083372 -690.88
- Postdilation 1 0.0144030 0.097775 -677.10
Step: AIC=-691.95
RelativeStentExpansion ~ Postdilation + CCV + SVDmax
Df Sum of Sq RSS AIC
- CCV 1 0.0008092 0.084967 -693.00
<none> 0.084158 -691.95
- SVDmax 1 0.0057460 0.089903 -687.41
- Postdilation 1 0.0137097 0.097867 -679.01
Step: AIC=-693
RelativeStentExpansion ~ Postdilation + SVDmax
Df Sum of Sq RSS AIC
<none> 0.084967 -693.00
- SVDmax 1 0.0050034 0.089970 -689.34
- Postdilation 1 0.0136643 0.098631 -680.24
summary(mod1_1)
Call:
lm(formula = RelativeStentExpansion ~ Postdilation + SVDmax,
data = data1)
Residuals:
Min 1Q Median 3Q Max
-0.09468 -0.01011 0.00591 0.01579 0.06160
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.8410974 0.0246528 34.118 < 2e-16 ***
Postdilation 0.0282769 0.0071966 3.929 0.000161 ***
SVDmax 0.0015349 0.0006456 2.378 0.019406 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.02975 on 96 degrees of freedom
Multiple R-squared: 0.1756, Adjusted R-squared: 0.1584
F-statistic: 10.23 on 2 and 96 DF, p-value: 9.419e-05
REGRESION LOGISTICA EN FUNCION DE RSEcalc(1;0)
#Modelo binario
mod2 <- glm(RSEcalc ~ Predilatation + Postdilation +
CCV + Raphaecalcification +
ICD4mm + SVDmax
,
data = data1, family = "binomial")
summary(mod2)
Call:
glm(formula = RSEcalc ~ Predilatation + Postdilation + CCV +
Raphaecalcification + ICD4mm + SVDmax, family = "binomial",
data = data1)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.8558 -0.9999 0.4974 0.9399 1.5382
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -7.5848759 2.6526375 -2.859 0.00424 **
Predilatation 0.1432666 0.5154728 0.278 0.78106
Postdilation 1.9870174 0.7142392 2.782 0.00540 **
CCV -0.0010839 0.0004925 -2.201 0.02775 *
Raphaecalcification 0.3676468 0.5113617 0.719 0.47217
ICD4mm 0.1931991 0.1264376 1.528 0.12651
SVDmax 0.0862144 0.0796681 1.082 0.27918
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 130.86 on 98 degrees of freedom
Residual deviance: 112.14 on 92 degrees of freedom
AIC: 126.14
Number of Fisher Scoring iterations: 4
# Aplicar el procedimiento stepwise
mod2_1 <- step(mod2)
Start: AIC=126.14
RSEcalc ~ Predilatation + Postdilation + CCV + Raphaecalcification +
ICD4mm + SVDmax
Df Deviance AIC
- Predilatation 1 112.22 124.22
- Raphaecalcification 1 112.66 124.66
- SVDmax 1 113.36 125.36
<none> 112.14 126.14
- ICD4mm 1 114.58 126.58
- CCV 1 117.42 129.42
- Postdilation 1 122.38 134.38
Step: AIC=124.22
RSEcalc ~ Postdilation + CCV + Raphaecalcification + ICD4mm +
SVDmax
Df Deviance AIC
- Raphaecalcification 1 112.72 122.72
- SVDmax 1 113.50 123.50
<none> 112.22 124.22
- ICD4mm 1 114.63 124.63
- CCV 1 117.48 127.48
- Postdilation 1 122.51 132.51
Step: AIC=122.73
RSEcalc ~ Postdilation + CCV + ICD4mm + SVDmax
Df Deviance AIC
- SVDmax 1 113.97 121.97
<none> 112.72 122.72
- ICD4mm 1 115.06 123.06
- CCV 1 117.48 125.48
- Postdilation 1 122.75 130.75
Step: AIC=121.96
RSEcalc ~ Postdilation + CCV + ICD4mm
Df Deviance AIC
<none> 113.97 121.97
- CCV 1 117.98 123.98
- ICD4mm 1 122.98 128.98
- Postdilation 1 124.44 130.44
summary(mod2_1)
Call:
glm(formula = RSEcalc ~ Postdilation + CCV + ICD4mm, family = "binomial",
data = data1)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.0277 -1.0723 0.5231 0.9297 1.5930
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -6.7111946 2.5587175 -2.623 0.00872 **
Postdilation 1.9734008 0.7017581 2.812 0.00492 **
CCV -0.0008416 0.0004300 -1.958 0.05029 .
ICD4mm 0.2784577 0.0992875 2.805 0.00504 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 130.86 on 98 degrees of freedom
Residual deviance: 113.96 on 95 degrees of freedom
AIC: 121.96
Number of Fisher Scoring iterations: 4
#Modelo binario RSE (1;0) final
mod2_final <- glm(formula = RSEcalc ~ Postdilation + CCV + ICD4mm,
family = "binomial", data = data1)
# Obtener el resumen del modelo
summary_mod2 <- summary(mod2_final)
summary_mod2
Call:
glm(formula = RSEcalc ~ Postdilation + CCV + ICD4mm, family = "binomial",
data = data1)
Deviance Residuals:
Min 1Q Median 3Q Max
-2.0277 -1.0723 0.5231 0.9297 1.5930
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -6.7111946 2.5587175 -2.623 0.00872 **
Postdilation 1.9734008 0.7017581 2.812 0.00492 **
CCV -0.0008416 0.0004300 -1.958 0.05029 .
ICD4mm 0.2784577 0.0992875 2.805 0.00504 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for binomial family taken to be 1)
Null deviance: 130.86 on 98 degrees of freedom
Residual deviance: 113.96 on 95 degrees of freedom
AIC: 121.96
Number of Fisher Scoring iterations: 4
Calculos de Odd Ratio
# Extraer los odds ratios
odds_ratios <- exp(summary_mod2$coefficients[, 1])
# Extraer los intervalos de confianza
conf_intervals <- exp(confint(mod2_final))
Waiting for profiling to be done...
# Extraer los p-values
p_values <- summary_mod2$coefficients[, 4]
# Crear el data frame consolidado
consolidado <- data.frame(Odds_Ratio = odds_ratios,
Lower_CI = conf_intervals[, 1],
Upper_CI = conf_intervals[, 2],
p_value = p_values)
# Mostrar el data frame consolidado
print(consolidado)
NA