Edad y colesterol

¿La edad es un predictor estadísticamente significativo del colesterol?

Primero, se limpió la base de datos eliminando los valores perdidos (NA), posteriormente se probaron las correlaciones del colesterol con variables como Edad, Thalch y Trestbps. Posteriormente, se probó un análisis de regresión lineal múltiple con estas tres variables como posibles predictoras; tal como se observó en las correlaciones, solo edad presentó correlación y predicción estadísticamente significativa. El modelo final muestra que la edad es un predictor estadísticamente significativo y positivo del colesterol, es decir, a mayor edad aumentan las probabilidades que los niveles de colesterol se eleven (como se aprecia en la gráfica de puntos rojos).

library(readxl)
data <- read_excel("a4_heart_disease_uci.xlsx")
View(data)

data_heart <- na.omit(data)

Colesterol <- data_heart$chol
Edad <- data_heart$age
Trestbps <- data_heart$trestbps
Thalch <- data_heart$thalch

library(Hmisc)
## Warning: package 'Hmisc' was built under R version 4.3.3
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
## 
##     format.pval, units
sub_data <- data.frame(Colesterol, Edad, Trestbps, Thalch)
rcorr(as.matrix(sub_data))
##            Colesterol  Edad Trestbps Thalch
## Colesterol       1.00  0.20     0.13   0.01
## Edad             0.20  1.00     0.29  -0.38
## Trestbps         0.13  0.29     1.00  -0.05
## Thalch           0.01 -0.38    -0.05   1.00
## 
## n= 299 
## 
## 
## P
##            Colesterol Edad   Trestbps Thalch
## Colesterol            0.0005 0.0202   0.7976
## Edad       0.0005            0.0000   0.0000
## Trestbps   0.0202     0.0000          0.3582
## Thalch     0.7976     0.0000 0.3582
modelo_inicial <- lm(Colesterol ~ Edad + Trestbps + Thalch)
summary(modelo_inicial)
## 
## Call:
## lm(formula = Colesterol ~ Edad + Trestbps + Thalch)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -139.143  -32.289   -4.612   27.189  302.893 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 113.2250    37.1843   3.045  0.00254 ** 
## Edad          1.2578     0.3724   3.378  0.00083 ***
## Trestbps      0.2303     0.1752   1.315  0.18964    
## Thalch        0.2320     0.1396   1.662  0.09752 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 51.33 on 295 degrees of freedom
## Multiple R-squared:  0.05505,    Adjusted R-squared:  0.04544 
## F-statistic: 5.729 on 3 and 295 DF,  p-value: 0.0008023
modelo_final <- lm(Colesterol ~ Edad)
summary(modelo_final)
## 
## Call:
## lm(formula = Colesterol ~ Edad)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -148.499  -32.534   -5.908   28.513  302.750 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 183.5863    18.2801  10.043  < 2e-16 ***
## Edad          1.1592     0.3308   3.504 0.000528 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 51.57 on 297 degrees of freedom
## Multiple R-squared:  0.0397, Adjusted R-squared:  0.03647 
## F-statistic: 12.28 on 1 and 297 DF,  p-value: 0.0005285
library(ggplot2)
ggplot(data_heart, aes(x=Edad, y=Colesterol)) +
  geom_point(alpha= 0.8, color ="red") +
  labs(title = "Edad como predictor de colesterol") +
  theme_minimal(base_size = 15) +
  theme(
    panel.grid = element_line(color = "black"),
    axis.text.x = element_text(angle = 55, hjust = 2)
  )