Los resultados muestran que la edad predice el colesterol de manera
estadísticamente significativa y negativa. Sin embargo, lo hace con un
efecto débil, lo que se puede apreciar en la inclinación de la
gráfica.
library(readxl)
data_heart <- read_excel("a4_heart_disease_uci.xlsx")
View(data_heart)
Colesterol <- data_heart$chol
Edad <- data_heart$age
modelo <- lm(Colesterol ~ Edad, data = data_heart)
summary(modelo)
##
## Call:
## lm(formula = Colesterol ~ Edad, data = data_heart)
##
## Residuals:
## Min 1Q Median 3Q Max
## -221.09 -26.43 25.27 69.01 404.30
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 253.6449 21.4568 11.821 <2e-16 ***
## Edad -1.0174 0.3945 -2.579 0.0101 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 110.4 on 888 degrees of freedom
## (30 observations deleted due to missingness)
## Multiple R-squared: 0.007436, Adjusted R-squared: 0.006319
## F-statistic: 6.653 on 1 and 888 DF, p-value: 0.01006
mse <- mean(residuals(modelo)^2)
rmse <- sqrt(mse)
mae <- mean(abs(residuals(modelo)))
library(ggplot2)
ggplot(data_heart, aes(x=Edad, y=Colesterol)) +
geom_point(alpha= 0.8, color ="green4") +
labs(title = "Edad como predictor de colesterol") +
theme_minimal(base_size = 14) +
theme(
panel.grid = element_line(color = "gray90"),
axis.text.x = element_text(angle = 45, hjust = 1)
)
## Warning: Removed 30 rows containing missing values or values outside the scale range
## (`geom_point()`).
